Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't build pyql on Mac #62

Closed
linkedrank opened this issue Sep 1, 2014 · 4 comments
Closed

Can't build pyql on Mac #62

linkedrank opened this issue Sep 1, 2014 · 4 comments

Comments

@linkedrank
Copy link
Contributor

Hello -

I get the error below. Can you help? I have setuptools installed, cython, and a c++ compiler (as I was able to compile and run the QuantLib example as specified here: http://quantlib.org/install/macosx.shtml

python setup.py build_ext --inplace
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/extension.py:133: UserWarning: Unknown Extension options: 'cython_directives'
warnings.warn(msg)
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/extension.py:133: UserWarning: Unknown Extension options: 'pyrex_directives'
warnings.warn(msg)
missing cimport in module 'quantlib.time': quantlib/instruments/credit_default_swap.pyx
missing cimport in module 'quantlib.pricingengines': quantlib/instruments/credit_default_swap.pyx
missing cimport in module 'quantlib.pricingengines': quantlib/instruments/option.pyx
running build_ext
building 'quantlib.cashflow' extension
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/usr/local/include -I/Users/marywilliamson1/Downloads/QuantLib-1.4 -I. -I./cpp_layer -I/Users/marywilliamson1/Documents/projects/pnlbooker/virtualenv/lib/python2.7/site-packages/numpy/core/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c quantlib/cashflow.cpp -o build/temp.macosx-10.9-intel-2.7/quantlib/cashflow.o
In file included from quantlib/cashflow.cpp:361:
/Users/marywilliamson1/Downloads/QuantLib-1.4/ql/time/date.hpp:276:30: warning: implicit
conversion loses integer precision: 'long' to 'Day' (aka 'int') [-Wshorten-64-to-32]
return serialNumber_ - yearOffset(year());
~~~~~~ ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
quantlib/cashflow.cpp:2083:18: warning: implicit conversion loses integer precision:
'size_type' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
__pyx_v_size = __pyx_v_leg.size();
~ ^~~~~~~~~~~~~~~~~~
quantlib/cashflow.cpp:2585:18: warning: implicit conversion loses integer precision:
'size_type' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
__pyx_v_size = __pyx_v_self->_thisptr->get()->size();
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
quantlib/cashflow.cpp:4778:28: warning: unused function '__Pyx_PyObject_AsString'
[-Wunused-function]
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
^
quantlib/cashflow.cpp:4775:32: warning: unused function '__Pyx_PyUnicode_FromString'
[-Wunused-function]
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
^
quantlib/cashflow.cpp:427:29: warning: unused function '__Pyx_Py_UNICODE_strlen'
[-Wunused-function]
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE _u)
^
quantlib/cashflow.cpp:4897:33: warning: unused function '__Pyx_PyIndex_AsSsize_t'
[-Wunused-function]
static CYTHON_INLINE Py_ssize_t _Pyx_PyIndex_AsSsize_t(PyObject b) {
^
quantlib/cashflow.cpp:4926:33: warning: unused function '__Pyx_PyInt_FromSize_t'
[-Wunused-function]
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
^
quantlib/cashflow.cpp:3613:27: warning: unused function '__Pyx_ErrFetch' [-Wunused-function]
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject *_type, PyObject *_value, PyObject *_tb) {
^
quantlib/cashflow.cpp:3956:32: warning: unused function '__Pyx_GetItemInt_List_Fast'
[-Wunused-function]
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
^
quantlib/cashflow.cpp:3970:32: warning: unused function '__Pyx_GetItemInt_Tuple_Fast'
[-Wunused-function]
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
^
quantlib/cashflow.cpp:4169:26: warning: function '__Pyx_PyInt_As_int' is not needed and will
not be emitted [-Wunneeded-internal-declaration]
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
^
quantlib/cashflow.cpp:4295:27: warning: function '__Pyx_PyInt_As_long' is not needed and will
not be emitted [-Wunneeded-internal-declaration]
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
^
13 warnings generated.
quantlib/cashflow.cpp:4778:28: warning: unused function '_Pyx_PyObject_AsString'
[-Wunused-function]
static CYTHON_INLINE char
__Pyx_PyObject_AsString(PyObject* o) {
^
quantlib/cashflow.cpp:4775:32: warning: unused function '__Pyx_PyUnicode_FromString'
[-Wunused-function]
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
^
quantlib/cashflow.cpp:427:29: warning: unused function '__Pyx_Py_UNICODE_strlen'
[-Wunused-function]
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE _u)
^
quantlib/cashflow.cpp:4897:33: warning: unused function '__Pyx_PyIndex_AsSsize_t'
[-Wunused-function]
static CYTHON_INLINE Py_ssize_t _Pyx_PyIndex_AsSsize_t(PyObject b) {
^
quantlib/cashflow.cpp:4926:33: warning: unused function '__Pyx_PyInt_FromSize_t'
[-Wunused-function]
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
^
quantlib/cashflow.cpp:3613:27: warning: unused function '__Pyx_ErrFetch' [-Wunused-function]
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject *_type, PyObject *_value, PyObject **tb) {
^
quantlib/cashflow.cpp:3956:32: warning: unused function '__Pyx_GetItemInt_List_Fast'
[-Wunused-function]
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
^
quantlib/cashflow.cpp:3970:32: warning: unused function '__Pyx_GetItemInt_Tuple_Fast'
[-Wunused-function]
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
^
quantlib/cashflow.cpp:4169:26: warning: function '__Pyx_PyInt_As_int' is not needed and will
not be emitted [-Wunneeded-internal-declaration]
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
^
quantlib/cashflow.cpp:4295:27: warning: function '__Pyx_PyInt_As_long' is not needed and will
not be emitted [-Wunneeded-internal-declaration]
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
^
10 warnings generated.
c++ -bundle -undefined dynamic_lookup -arch x86_64 -arch i386 -Wl,-F. -mmacosx-version-min=10.6 build/temp.macosx-10.9-intel-2.7/quantlib/cashflow.o -L/usr/local/lib -lQuantLib -o /Users/marywilliamson1/Downloads/pyql-master/quantlib/cashflow.so -stdlib=libstdc++ -mmacosx-version-min=10.6
ld: library not found for -lQuantLib
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'c++' failed with exit status 1
(virtualenv)marys-mbp:pyql-master marywilliamson1$ c++
clang: error: no input files

@jvkersch
Copy link
Contributor

jvkersch commented Sep 1, 2014

@linkedrank Do you have QuantLib installed in /usr/local/? The installation instructions that you quote refer to /opt/local/ and the linker error suggests that PyQL can't find the QuantLib library.

@linkedrank
Copy link
Contributor Author

Hi Joris - thanks for the response. I was able to successfully build the library after I fixed the path issue by modifying setup.py with the proper include and library paths. I was also able to run the examples in place in the original directory but when I copy or link the quantlib directory to my project directory, I get import errors. Any idea? I'm guessing I'm doing something stupid. (Obviously it's finding the directory itself and getting to quantlib.instruments.api but having trouble importing some of the classes)

import american_option

File "/Users/marywilliamson1/Documents/projects/pnlbooker/server/app/american_option.py", line 10, in
from quantlib.instruments.api import AmericanExercise, VanillaOption, Put
File "/Users/marywilliamson1/Documents/projects/pnlbooker/server/app/quantlib/instruments/api.py", line 1, in
from .bonds import FixedRateBond, ZeroCouponBond
ImportError: cannot import name FixedRateBond

@jvkersch
Copy link
Contributor

jvkersch commented Sep 2, 2014

when I copy or link the quantlib directory to my project directory, I get import errors. Any idea?

There should be no need to move the quantlib folder, you can just run make install (after doing make build). This will install PyQL in your site-packages folder, and after that, importing from quantlib should work fine.

@linkedrank
Copy link
Contributor Author

Thanks a lot - that worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants