简体   繁体   中英

Quantlib-SWIG for Python error, missing Quantlib/quantlib_wrap.cpp on MacOS Sierra

I downloaded Qauntlib-SWIG v1.9 from Sourceforge, also tried github master branch, followed instructions on the official page , but in both cases I'm left with the following error message.

I'm running MacOS Sierra / Python 3.6 / boost version 1.64.0_1, gcc version below. I installed quantlib v1.9.2 with Homebrew .

$ 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

I suspect the error is caused by the first statement below: python -c++ ... It doesn't seem to be a valid flag for python, which gave the error message (tried python -c++ in command prompt, got the same error).

Any idea how / where this flag came from? Thank you.

Error message:

(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 $ 

Figured out why this was happening. Grepped the Makefile. If fact it was looking for SWIG. So a brew install swig resolved this issue.

Even though the official installation webpage said swig was not required, it was required in the end.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM