|
From: Matthew H. <mat...@gm...> - 2024-11-04 14:06:36
|
Hi Luigi,
Thanks for your response. I am attempting to build QuantLib myself to turn on higher-resolution dates for intraday analysis.
Here are the commands I am using to build QuantLib:
(base) matthew@Matthews-MacBook-Pro-5 Documents % tar xzvf QuantLib-1.36.tar.gz
(base) matthew@Matthews-MacBook-Pro-5 Documents % cd QuantLib-1.36
(base) matthew@Matthews-MacBook-Pro-5 QuantLib-1.36 % ./configure --with-boost-include=/opt/homebrew/include/ \
--prefix=${HOME}/Documents/QuantLib-1.36_build --disable-shared \
CXXFLAGS='-O2 -stdlib=libc++ -mmacosx-version-min=10.9' \
LDFLAGS='-stdlib=libc++ -mmacosx-version-min=10.9’
(base) matthew@Matthews-MacBook-Pro-5 QuantLib-1.36 % make -j8
(base) matthew@Matthews-MacBook-Pro-5 QuantLib-1.36 % make install
I can compile and run the C++ examples successfully.
I then try and build QuantLib-SWIG-1.36:
(base) matthew@Matthews-MacBook-Pro-5 Documents % tar xzf QuantLib-SWIG-1.36.tar.gz
(base) matthew@Matthews-MacBook-Pro-5 Documents % cd QuantLib-SWIG-1.36/Python
(base) matthew@Matthews-MacBook-Pro-5 QuantLib-SWIG-1.36 % export CXXFLAGS='-O2 -stdlib=libc++ -mmacosx-version-min=10.9’
(base) matthew@Matthews-MacBook-Pro-5 QuantLib-SWIG-1.36 % export LDFLAGS='-stdlib=libc++ -mmacosx-version-min=10.9’
Here I am using a conda python39 environment to build/install:
(py39) matthew@Matthews-MacBook-Pro-5 Python % /Users/matthew/opt/anaconda3/envs/py39/bin/python3 setup.py build
This generates some warnings related to compatibility between arm and x86 (I’m building on M1):
running build
running build_py
creating build/lib.macosx-10.15-x86_64-cpython-39/QuantLib
copying src/QuantLib/__init__.py -> build/lib.macosx-10.15-x86_64-cpython-39/QuantLib
copying src/QuantLib/QuantLib.py -> build/lib.macosx-10.15-x86_64-cpython-39/QuantLib
running build_ext
building 'QuantLib._QuantLib' extension
creating build/temp.macosx-10.15-x86_64-cpython-39/src/QuantLib
clang++ -O2 -stdlib=libc++ -mmacosx-version-min=10.9 -DPy_LIMITED_API=0x03080000 -DNDEBUG -I/Users/matthew/Documents/QuantLib-1.36_build/include -I/Users/matthew/opt/anaconda3/envs/py39/include/python3.9 -c src/QuantLib/quantlib_wrap.cpp -o build/temp.macosx-10.15-x86_64-cpython-39/src/QuantLib/quantlib_wrap.o -std=c++17 -Wno-unused -O2 -stdlib=libc++ -mmacosx-version-min=10.9
clang++ -O2 -stdlib=libc++ -mmacosx-version-min=10.9 -bundle -undefined dynamic_lookup -stdlib=libc++ -mmacosx-version-min=10.9 -O2 -stdlib=libc++ -mmacosx-version-min=10.9 build/temp.macosx-10.15-x86_64-cpython-39/src/QuantLib/quantlib_wrap.o -L/Users/matthew/Documents/QuantLib-1.36_build/lib -lQuantLib -o build/lib.macosx-10.15-x86_64-cpython-39/QuantLib/_QuantLib.abi3.so -stdlib=libc++ -mmacosx-version-min=10.9
ld: warning: ignoring file /Users/matthew/Documents/QuantLib-1.36_build/lib/libQuantLib.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
(py39) matthew@Matthews-MacBook-Pro-5 Python % /Users/matthew/opt/anaconda3/envs/py39/bin/python3 setup.py install
This appears to run successfully (though the package name contains x86):
Installed /Users/matthew/opt/anaconda3/envs/py39/lib/python3.9/site-packages/QuantLib-1.36-py3.9-macosx-10.15-x86_64.egg
Processing dependencies for QuantLib==1.36
Finished processing dependencies for QuantLib==1.36
Then trying to import QuantLib raises an error:
(py39) matthew@Matthews-MacBook-Pro-5 Python % python
Python 3.9.20 (main, Oct 3 2024, 02:27:54)
[Clang 14.0.6 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import QuantLib as ql
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/matthew/opt/anaconda3/envs/py39/lib/python3.9/site-packages/QuantLib-1.36-py3.9-macosx-10.15-x86_64.egg/QuantLib/__init__.py", line 19, in <module>
from .QuantLib import *
File "/Users/matthew/opt/anaconda3/envs/py39/lib/python3.9/site-packages/QuantLib-1.36-py3.9-macosx-10.15-x86_64.egg/QuantLib/QuantLib.py", line 10, in <module>
from . import _QuantLib
ImportError: dlopen(/Users/matthew/opt/anaconda3/envs/py39/lib/python3.9/site-packages/QuantLib-1.36-py3.9-macosx-10.15-x86_64.egg/QuantLib/_QuantLib.abi3.so, 0x0002): symbol not found in flat namespace ‘__ZN8QuantLib12SmileSection6updateEv'
Thanks for your help!
Best
Matthew
> On Nov 4, 2024, at 4:38 AM, Luigi Ballabio <lui...@gm...> wrote:
>
> Hi Matthew,
> I assume you've changed something in the library so you can't just use `pip install QuantLib`, correct?
> May you post the exact commands you're using to build the library and Python module? Thanks!
>
> Luigi
>
>
> On Sun, Nov 3, 2024 at 2:30 AM Matthew Hancock <mat...@gm... <mailto:mat...@gm...>> wrote:
>> Hi QuantLib team,
>>
>> I am running into an issue building QuantLib-SWIG-1.36 on a Mac M1 running Mac OS 10.14. I am using an Anaconda version of Python 3.8.
>>
>> I can build QuantLib-1.36 with no issue (I added the --disabled-shared flag).
>>
>> However, when I build QuantLib-SWIG-1.36 and try to import the Python library, I get an import error:
>>
>> >>> import QuantLib
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> File "/Users/matthew/opt/anaconda3/lib/python3.8/site-packages/QuantLib-1.36-py3.8-macosx-10.9-x86_64.egg/QuantLib/__init__.py", line 19, in <module>
>> from .QuantLib import *
>> File "/Users/matthew/opt/anaconda3/lib/python3.8/site-packages/QuantLib-1.36-py3.8-macosx-10.9-x86_64.egg/QuantLib/QuantLib.py", line 10, in <module>
>> from . import _QuantLib
>> ImportError: dlopen(/Users/matthew/opt/anaconda3/lib/python3.8/site-packages/QuantLib-1.36-py3.8-macosx-10.9-x86_64.egg/QuantLib/_QuantLib.abi3.so <http://quantlib.abi3.so/>, 0x0002): symbol not found in flat namespace '__ZN8QuantLib12SmileSection6updateEv'
>>
>> Any help would be much appreciated, thanks!
>>
>> Best
>> Matthew
>>
>> _______________________________________________
>> QuantLib-users mailing list
>> Qua...@li... <mailto:Qua...@li...>
>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
|