如何在mac os x 10.9.5上构建QuantLib

How to build QuantLib on mac os x 10.9.5

本文关键字:构建 QuantLib mac os      更新时间:2023-10-16

到目前为止,我无法按照官方说明http://quantlib.org/install/macosx.shtml在osx 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.

那么可能是什么问题呢?我该怎么补救呢?

这是配置日志的摘录:

## ----------- ##
## 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

如果您有这个问题

checking whether the C compiler works... no

这意味着你没有为你的Xcode正确安装命令行工具。请下载并安装

你的线索在config.log: "clang: error: unknown argument: '-stlib=libstdc++' "

将-stdlib更改为-stdlib,它应该可以编译并构建。

查看如何配置gcc的相关答案。原因是,像我一样,您可能使用自制软件或其他东西安装了GCC,因此没有使用Apple的默认值。

我安装了GCC 5.3 with homebrew.

为我工作,只是把-stdlib选项一起。