如何在mac os x 10.9.5上构建QuantLib

时间:2015-05-19 16:02:42

标签: c++ osx-mavericks quantlib

到目前为止,我无法按照官方说明http://quantlib.org/install/macosx.shtml

在os x 10.9.5上构建QuantLib 1.5
./configure --enable-static --with-boost-include=/opt/local/include/ \
        --with-boost-lib=/opt/local/lib/ --prefix=/opt/local/ \
        CXXFLAGS="-stlib=libstdc++ -mmacosx-version-min=10.6" \
        LDFLAGS="-stlib=libstdc++ -mmacosx-version-min=10.6"

configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type:  
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type:  
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... config/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gawk... (cached) awk
checking for -gcc... no
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `~/Downloads/qlib/QuantLib-1.5':
configure: error: C compiler cannot create executables
See `config.log' for more details

$ make && sudo make install
make: *** No targets specified and no makefile found.  Stop.

那么可能有什么不对?我该如何解决?

以下是Config日志的摘录:

## ----------- ##
## Core tests. ##
## ----------- ##

configure:2416: checking for a BSD-compatible install
configure:2484: result: /usr/bin/install -c
configure:2495: checking whether build environment is sane
configure:2550: result: yes
configure:2701: checking for a thread-safe mkdir -p
configure:2740: result: config/install-sh -c -d
configure:2747: checking for gawk
configure:2777: result: no
configure:2747: checking for mawk
configure:2777: result: no
configure:2747: checking for nawk
configure:2777: result: no
configure:2747: checking for awk
configure:2763: found /usr/bin/awk
configure:2774: result: awk
configure:2785: checking whether make sets $(MAKE)
configure:2807: result: yes
configure:2836: checking whether make supports nested variables
configure:2853: result: yes
configure:2987: checking for gawk
configure:3014: result: awk
configure:3069: checking for -gcc
configure:3099: result: no
configure:3109: checking for gcc
configure:3125: found /usr/bin/gcc
configure:3136: result: gcc
configure:3365: checking for C compiler version
configure:3374: gcc --version >&5
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
configure:3385: $? = 0
configure:3374: gcc -v >&5
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
configure:3385: $? = 0
configure:3374: gcc -V >&5
clang: error: argument to '-V' is missing (expected 1 value)
clang: error: no input files
configure:3385: $? = 1
configure:3374: gcc -qversion >&5
clang: error: unknown argument: '-qversion'
clang: error: no input files
configure:3385: $? = 1
configure:3405: checking whether the C compiler works
configure:3427: gcc   -I/opt/local/include -stlib=libstdc++ -mmacosx-version-min=10.6 -L/opt/local/lib conftest.c  >&5
clang: error: unknown argument: '-stlib=libstdc++'
configure:3431: $? = 1
configure:3469: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "QuantLib"
| #define PACKAGE_TARNAME "QuantLib"
| #define PACKAGE_VERSION "1.5"
| #define PACKAGE_STRING "QuantLib 1.5"
| #define PACKAGE_BUGREPORT "quantlib-dev@lists.sourceforge.net"
| #define PACKAGE_URL ""
| #define PACKAGE "QuantLib"
| #define VERSION "1.5"
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:3474: error: in `~/Downloads/qlib/QuantLib-1.5':
configure:3476: error: C compiler cannot create executables
See `config.log' for more details

3 个答案:

答案 0 :(得分:1)

如果您遇到此问题

checking whether the C compiler works... no

这意味着您尚未为Xcode正确安装命令行工具。请下载并安装它。

答案 1 :(得分:0)

你的线索在config.log中:" clang:错误:未知参数:' -stlib = libstdc ++' "

将-stlib更改为-stdlib,它应该编译和构建。

答案 2 :(得分:0)

请参阅this有关如何配置gcc的相关答案。原因是,和我一样,你可能用自制软件或其他东西安装了GCC,因此没有使用Apple的默认设置。

我用自制软件安装了GCC 5.3。

通过一起取出-stdlib选项为我工作。