Quantlib-SWIG for Python错误,在MacOS Sierra上缺少Quantlib / quantlib_wrap.cpp

时间:2017-05-03 21:43:35

标签: python quantlib quantlib-swig

我从Sourceforge下载了Qauntlib-SWIG v1.9,也尝试了github master分支,按照official page上的说明,但在这两种情况下我都留下了以下错误消息。

我正在运行MacOS Sierra / Python 3.6 / boost版本1.64.0_1,gcc以下版本。我用quantlib安装了Homebrew v1.9.2。

$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

我怀疑错误是由下面的第一个语句引起的:python -c++ ...它似乎不是python的有效标志,它给出了错误消息(在命令提示符中尝试python -c++,得到了同样的错误)。

知道这面旗帜的来源/位置是什么?谢谢。

错误讯息:

(py36) me:QuantLib-SWIG $ make -C Python
python -c++ -modern -outdir QuantLib \
            -o QuantLib/quantlib_wrap.cpp ../SWIG/quantlib.i
  File "<string>", line 1
    ++
     ^
SyntaxError: invalid syntax
make: [QuantLib/quantlib_wrap.cpp] Error 1 (ignored)
python -c++ -modern -outdir QuantLib \
            -o QuantLib/quantlib_wrap.cpp ../SWIG/quantlib.i
  File "<string>", line 1
    ++
     ^
SyntaxError: invalid syntax
make: [QuantLib/QuantLib.py] Error 1 (ignored)
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-am
python -c++ -modern -outdir QuantLib \
            -o QuantLib/quantlib_wrap.cpp ../SWIG/quantlib.i
  File "<string>", line 1
    ++
     ^
SyntaxError: invalid syntax
make[1]: [QuantLib/quantlib_wrap.cpp] Error 1 (ignored)
python -c++ -modern -outdir QuantLib \
            -o QuantLib/quantlib_wrap.cpp ../SWIG/quantlib.i
  File "<string>", line 1
    ++
     ^
SyntaxError: invalid syntax
make[1]: [QuantLib/QuantLib.py] Error 1 (ignored)
CXXFLAGS="-O2 -stdlib=libstdc++ -mmacosx-version-min=10.6 -fno-strict-aliasing -Wno-unused -Wno-uninitialized -Wno-sign-compare -Wno-write-strings" CC="gcc" CXX="g++" /Users/me/anaconda/envs/py36/bin/python setup.py build
running build
running build_py
file QuantLib/QuantLib.py (for module QuantLib.QuantLib) not found
file QuantLib/QuantLib.py (for module QuantLib.QuantLib) not found
running build_ext
building 'QuantLib._QuantLib' extension
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/me/anaconda/envs/py36/include -arch x86_64 -I/Users/me/anaconda/envs/py36/include -arch x86_64 -I/Users/me/anaconda/envs/py36/include/python3.6m -I/usr/local/Cellar/quantlib/1.9.2/include -c QuantLib/quantlib_wrap.cpp -o build/temp.macosx-10.7-x86_64-3.6/QuantLib/quantlib_wrap.o -Wno-unused -O2 -stdlib=libstdc++ -mmacosx-version-min=10.6 -fno-strict-aliasing -Wno-unused -Wno-uninitialized -Wno-sign-compare -Wno-write-strings
clang: error: no such file or directory: 'QuantLib/quantlib_wrap.cpp'
clang: error: no input files
error: command 'gcc' failed with exit status 1
make[1]: *** [.build-stamp] Error 1
make: *** [all] Error 2
(py36) me:QuantLib-SWIG $ 

1 个答案:

答案 0 :(得分:0)

弄清楚为什么会这样。 Grepped Makefile。事实上它正在寻找SWIG。因此brew install swig解决了这个问题。

即使官方安装网页不需要swig,但最终还是需要它。