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

Compilation Error on MacOS High Sierra #229

Open
michaelnowotny opened this issue Apr 15, 2018 · 15 comments
Open

Compilation Error on MacOS High Sierra #229

michaelnowotny opened this issue Apr 15, 2018 · 15 comments

Comments

@michaelnowotny
Copy link

Dear pyql developers,

I am experiencing the following compilation error on my platform:

quantlib/time/date.cpp:1722:80: error: no type named 'Hour' in namespace
'QuantLib'
...PyObject* __Pyx_PyInt_From_QuantLib_3a__3a_Hour(QuantLib::Hour value);
~~~~~~~~~~^
quantlib/time/date.cpp:1725:82: error: no type named 'Minute' in namespace
'QuantLib'
...PyObject* __Pyx_PyInt_From_QuantLib_3a__3a_Minute(QuantLib::Minute value);
~~~~~~~~~~^
quantlib/time/date.cpp:1728:82: error: no type named 'Second' in namespace
'QuantLib'
...PyObject* __Pyx_PyInt_From_QuantLib_3a__3a_Second(QuantLib::Second value);
~~~~~~~~~~^
quantlib/time/date.cpp:1731:87: error: no type named 'Millisecond' in namespace
'QuantLib'
...PyObject* __Pyx_PyInt_From_QuantLib_3a__3a_Millisecond(QuantLib::Millise...
~~~~~~~~~~^
quantlib/time/date.cpp:1734:87: error: no type named 'Microsecond' in namespace
'QuantLib'
...PyObject* __Pyx_PyInt_From_QuantLib_3a__3a_Microsecond(QuantLib::Microse...
~~~~~~~~~~^
quantlib/time/date.cpp:1758:32: error: no type named 'Hour' in namespace
'QuantLib'
static CYTHON_INLINE QuantLib::Hour __Pyx_PyInt_As_QuantLib_3a__3a_Hour(...
~~~~~~~~~~^
quantlib/time/date.cpp:1761:32: error: no type named 'Minute' in namespace
'QuantLib'
static CYTHON_INLINE QuantLib::Minute __Pyx_PyInt_As_QuantLib_3a__3a_Min...
~~~~~~~~~~^
quantlib/time/date.cpp:1764:32: error: no type named 'Second' in namespace
'QuantLib'
static CYTHON_INLINE QuantLib::Second __Pyx_PyInt_As_QuantLib_3a__3a_Sec...
~~~~~~~~~~^
quantlib/time/date.cpp:1767:32: error: no type named 'Millisecond' in namespace
'QuantLib'
static CYTHON_INLINE QuantLib::Millisecond __Pyx_PyInt_As_QuantLib_3a__3...
~~~~~~~~~~^
quantlib/time/date.cpp:1770:32: error: no type named 'Microsecond' in namespace
'QuantLib'
static CYTHON_INLINE QuantLib::Microsecond __Pyx_PyInt_As_QuantLib_3a__3...
~~~~~~~~~~^
quantlib/time/date.cpp:5119:13: error: no type named 'Hour' in namespace
'QuantLib'
QuantLib::Hour __pyx_t_17;

quantlib/time/date.cpp:5120:13: error: no type named 'Minute' in namespace
    'QuantLib'
QuantLib::Minute __pyx_t_18;
~~~~~~~~~~^
quantlib/time/date.cpp:5121:13: error: no type named 'Second' in namespace
    'QuantLib'
QuantLib::Second __pyx_t_19;
~~~~~~~~~~^
quantlib/time/date.cpp:5123:13: error: no type named 'Millisecond' in namespace
    'QuantLib'
QuantLib::Millisecond __pyx_t_21;
~~~~~~~~~~^
quantlib/time/date.cpp:5125:13: error: no type named 'Microsecond' in namespace
    'QuantLib'
QuantLib::Microsecond __pyx_t_23;
~~~~~~~~~~^
quantlib/time/date.cpp:5438:110: error: no member named 'Hour' in namespace
    'QuantLib'; did you mean 'Hours'?
...if (unlikely((__pyx_t_17 == ((QuantLib::Hour)-1)) && PyErr_Occurred())) ...
                                 ~~~~~~~~~~^~~~
                                           Hours
quantlib/time/date.cpp:823:43: note: expanded from macro 'unlikely'
#define unlikely(x) __builtin_expect(!!(x), 0)
                                        ^
/usr/local/include/ql/time/timeunit.hpp:41:21: note: 'Hours' declared here
                  Hours,
                  ^
quantlib/time/date.cpp:5439:114: error: no member named 'Minute' in namespace
    'QuantLib'; did you mean 'Minutes'?
...if (unlikely((__pyx_t_18 == ((QuantLib::Minute)-1)) && PyErr_Occurred())...
                                 ~~~~~~~~~~^~~~~~
                                           Minutes
quantlib/time/date.cpp:823:43: note: expanded from macro 'unlikely'
#define unlikely(x) __builtin_expect(!!(x), 0)
                                        ^
/usr/local/include/ql/time/timeunit.hpp:42:21: note: 'Minutes' declared here
                  Minutes,
                  ^
quantlib/time/date.cpp:5440:114: error: no member named 'Second' in namespace
    'QuantLib'; did you mean 'Seconds'?
...if (unlikely((__pyx_t_19 == ((QuantLib::Second)-1)) && PyErr_Occurred())...
                                 ~~~~~~~~~~^~~~~~
                                           Seconds
quantlib/time/date.cpp:823:43: note: expanded from macro 'unlikely'
#define unlikely(x) __builtin_expect(!!(x), 0)
                                        ^
/usr/local/include/ql/time/timeunit.hpp:43:21: note: 'Seconds' declared here
                  Seconds,
                  ^
quantlib/time/date.cpp:5449:162: error: expected ')'
...((QuantLib::Year)__pyx_t_8), ((QuantLib::Hour)__pyx_t_17), ((QuantLib::M...
                                                 ^
quantlib/time/date.cpp:5449:145: note: to match this '('
...((enum QuantLib::Month)__pyx_t_7), ((QuantLib::Year)__pyx_t_8), ((QuantL...
                                                                   ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
error: command 'gcc' failed with exit status 1
make: *** [build3] Error 1
----------------------------------------------------------------
I am using quantlib 1.12 and boost 1.66 installed via homebrew and Python 3.6.5. via Anaconda.
GCC is Apple LLVM version 9.1.0 (clang-902.0.39.1). 

Your help is very much appreciated!

Thank you,

Michael
@thrasibule
Copy link
Collaborator

It's probably a missing path issue somewhere in setup.py. In date.cpp do you have a line saying #include "ql/time/date.hpp" ?
And what's the compiler command used to compile date.cpp? If it contains -I/usr/local/include this should compile fine.

@michaelnowotny
Copy link
Author

Yes, on line 620 in date.cpp, I have the following include:
#include "ql/time/date.hpp"

The compiler command is as follows (from a different machine with MacOS on which I get the same error):
building 'quantlib.time.date' extension
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/michaelnowotny/anaconda/include -arch x86_64 -I/Users/michaelnowotny/anaconda/include -arch x86_64 -I/usr/local/include -I. -I../sources/boost_1_55_0 -I./cpp_layer -I/Users/michaelnowotny/anaconda/lib/python3.6/site-packages/numpy/core/include -I/Users/michaelnowotny/anaconda/include/python3.6m -c quantlib/time/date.cpp -o build/temp.macosx-10.7-x86_64-3.6/quantlib/time/date.o

@dpinte
Copy link
Member

dpinte commented Apr 17, 2018

Any chance that you haven't defined QL_HIGH_RESOLUTION_DATE ? That would explain why the intraday part of the dates are not defined.

@thrasibule
Copy link
Collaborator

@dpinte is right of course, this must be the issue. You need to configure quantlib with --enable-intraday, same as issue #200

@michaelnowotny
Copy link
Author

Thank you very much for your advice @thrasibule and @dpinte!

I had indeed not defined this option. The name of the option in homebrew is "--with-intraday" (rather than "--enable-intraday") and this enables QL_HIGH_RESOLUTION_DATE. The compilation goes through, but when running the unit tests via
"make tests3" or "make tests"
I get a segmentation fault:

python -m unittest discover -v
make: *** [tests] Segmentation fault: 11

This happens on two macs I have tried it on (one with Sierra and the other one with High Sierra).

Any idea what might be causing this?

Thanks,

Michael

@michaelnowotny
Copy link
Author

BTW: I am getting these clang warnings when compiling pyql:

clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: warning: object file (build/temp.macosx-10.7-x86_64-3.6/quantlib/time_series.o) was built for newer OSX version (10.7) than being linked (10.6)

@thrasibule
Copy link
Collaborator

The segfaults happens right away?? no tests at all go through?
From the directory you compiled pyql can you import quantlib at least? For instance try something like that.

from quantlib.time.date import today
today()

@michaelnowotny
Copy link
Author

If I run the code above in the Python interpreter, I get the following error:

from quantlib.time.date import today
Traceback (most recent call last):
File "", line 1, in
ImportError: dlopen(/Volumes/GIT/pyql/quantlib/time/date.cpython-36m-darwin.so, 2): Symbol not found: _ZN8QuantLib10DateParser14parseFormattedERKSsS2
Referenced from: /Volumes/GIT/pyql/quantlib/time/date.cpython-36m-darwin.so
Expected in: flat namespace
in /Volumes/GIT/pyql/quantlib/time/date.cpython-36m-darwin.so

This happens on both Macs. I am going to try this on a third Mac which has Python installed via homebrew rather than Anaconda.

@michaelnowotny
Copy link
Author

Ok, unit tests are running on the third Mac that does not use Anaconda. I am getting the same clang warnings:

clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: warning: object file (build/temp.macosx-10.13-x86_64-3.6/quantlib/time/calendars/united_states.o) was built for newer OSX version (10.13) than being linked (10.6)

So these can not be causing the problem on the other computers. Any ideas what can be going on?

@michaelnowotny
Copy link
Author

A few unit tests are failing but this is likely not connected:

======================================================================
ERROR: test_zero_rate (quantlib.test.test_mlab.MLabTestCase)

Traceback (most recent call last):
File "/Volumes/GIT/pyql/quantlib/test/test_mlab.py", line 198, in test_zero_rate
maturity_dates=None)
File "/Volumes/GIT/pyql/quantlib/mlab/term_structure.py", line 68, in zbt_libor_yield
calendar=TARGET())
File "quantlib/time/schedule.pyx", line 63, in quantlib.time.schedule.Schedule.init
self._thisptr = new _schedule.Schedule(
RuntimeError: null termination date

======================================================================
ERROR: test_bump_yieldcurve (quantlib.test.test_piecewise_yield_curve.PiecewiseYieldCurveTestCase)

Traceback (most recent call last):
File "/Volumes/GIT/pyql/quantlib/test/test_piecewise_yield_curve.py", line 154, in test_bump_yieldcurve
old_discount = ts.discount(ts.max_date)
File "quantlib/termstructures/yield_term_structure.pyx", line 161, in quantlib.termstructures.yield_term_structure.YieldTermStructure.discount
discount_value = term_structure.discount(
RuntimeError: year 1900 out of bound. It must be in [1901,2199]

======================================================================
FAIL: test_extrapolation (quantlib.test.test_zero_coupon.ZeroCouponTestCase)

Traceback (most recent call last):
File "/Volumes/GIT/pyql/quantlib/test/test_zero_coupon.py", line 110, in test_extrapolation
"1st iteration: failed at 2nd alive instrument"))
AssertionError: False is not true


@dpinte
Copy link
Member

dpinte commented Apr 18, 2018

@michaelnowotny do you know how brew build quantlib? You need to make sure it has been built with -stdlib=libc++ -mmacosx-version-min=10.9 (see http://www.quantlib.org/install/macosx.shtml) and same when building pyql.

This message seem to indicate it's not the case:

clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: warning: object file (build/temp.macosx-10.7-x86_64-3.6/quantlib/time_series.o) was built for newer OSX version (10.7) than being linked (10.6)

@michaelnowotny
Copy link
Author

Hi @dpinte,

I do not know specifically know how quantlib is built in homebrew. The clang error message appears on all three macs I have tried it, including the one where everything works. The issue seems to be related to Anaconda. The issue appears on both computers which use Anaconda.

Furthermore, I have uninstalled Anaconda on one of the Macs and installed Python via hombrew. After that everything works. So there must be some issue with Anaconda. I will uninstall Python from homebrew and reinstall Anaconda. Who knows, perhaps the installation had been referring to an out-of-date compiler, even though I kept conda up-to-date.

But at this point, the problem seems to be unlikely to be causes by pyql or quantlib.

Thank you both for your help!

Michael

@michaelnowotny
Copy link
Author

Installed Anaconda again from scratch and the segmentation fault reappears. This is very likely an issue with Anaconda on the Mac.

@dpinte
Copy link
Member

dpinte commented Apr 19, 2018

@michaelnowotny I can suggest using edm which is known to work as expected (https://www.enthought.com/product/enthought-deployment-manager).

@michaelnowotny
Copy link
Author

Thank you @dpinte. I will take a closer look. It is currently not clear to me if this will work with Anaconda or is an alternative to Anaconda. For the time being, I can simply keep using hombrew on Mac.

Thanks again for your help!

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

3 participants