2

I am trying to install QuantLib on my Mac running OSX 10.11.6. Installed Boost 1.59 via MacPorts and then followed these instructions.

I used these additional environment variables
./configure --with-boost-include=/opt/local/include/ \ --with-boost-lib=/opt/local/lib/ --prefix=/opt/local/ \ CXXFLAGS='-O2 -stdlib=libstdc++ -mmacosx-version-min=10.6' \ LDFLAGS='-stdlib=libstdc++ -mmacosx-version-min=10.6'
and then make && sudo make install.
However when I run the Bermuda Swaption test it gave me the same error described here.

Little premise: I don't know anything about C++. I need QuantLib to work on Python. So I read carefully the answer by SmallChess and tried to solve it by myself. As I read in his answer

You can't just compile BermudanSwaption.cpp and hope everything would be fine. You have to compile the entire QuantLib library and link with the generated library files. Please google "compiling and linking C++" for more information.
By far, the easiest way to make it happen on Mac is to do it with Xcode. You will need to create a new Xcode project, and import the entire Quantlib project files into it. Next, you will need to create a main() function. Xcode does the compiling and linking for your automatically.

This is what I exactly did:

  1. created a new project in Xcode (version 8.2.1)(file/new project/Command Line Tool/"HelloWorld"/Documents/create)
  2. selected Targets, Build Phases and Link Binary With Library. Added libQuantLib.0.dylib
  3. set libstdc++(GNUC++ standard library) as C++ Standard Library in Build Settings
  4. Modified Header Search Paths to include: /opt/local/include/, and Library Search Paths to include: /opt/local/lib
  5. C++ Language Dialect is set on Compiler Default.
  6. Dragged the ql folder onto the left window of the Xcode

Now, I managed to copy a simple code which includes the library and even if there are many warnings, it runs. Still when I run on the Terminal the command for the Bermuda Swaption test I get the same error. What am I doing wrong?

Additional info (may or may not be useful): if I change the C++ Standard Library setting on Xcode to libc++, I get on Xcode the same error I get when i try the Bermuda Swaption test (ld: symbol(s) not found for architecture x86_64).


Any help would be very much appreciated
Regards


EDIT: you can find a picture of the code at https://i.stack.imgur.com/1zhjO.png

iehrlich
  • 3,572
  • 4
  • 34
  • 43
R. Tomassetti
  • 21
  • 1
  • 4
  • The instructions at http://quantlib.org/install/macosx.shtml have changed recently, and now suggest different flags for Mac OS X 10.11. May you try them out? (This also goes for the ones for the Python wrappers, at http://quantlib.org/install/macosx-python.shtml) – Luigi Ballabio May 13 '17 at 21:51
  • Thank you Luigi. I am going to use the flags for MacOS X 10.11 and I'll let you know. I guess however that there is a little confusion in your [installation guide](http://quantlib.org/install/macosx.shtml). As you can see in the section regarding the necessary flags for each OSX version you indicated that ElCapitan is 10.10 and Sierra is 10.11, so I guess you forgot Yosemite which is 10.10 – R. Tomassetti May 14 '17 at 16:43
  • You're right, I've fixed those. Thanks. – Luigi Ballabio May 15 '17 at 08:23
  • The new flags works perfectly. I have followed the new instructions with the additional flags `--disable-shared --enable-static`. Thank you very much. – R. Tomassetti May 15 '17 at 14:26

0 Answers0