Hi all,
I am a newbie to Quantlib as well as the Xcode IDE. I installed Quantlib on my Mac OS X 10.9.4 following the instructions on the official website http://quantlib.org/install/macosx.shtml. Everything works fine and I can use g++ -I/opt/local/include/ -I/opt/local/include/boost BermudanSwaption.cpp -o bermudanswaption -L/opt/local/lib/ -lQuantLib to compile and run in Terminal. I then created a new project in Xcode to see if I can make everything work in the IDE. As a start, I only have a "Hello World" main program which includes the quantLib header file. Below is the code of the main program: #include <ql/quantlib.hpp> #include <iostream> int main(int argc, const char * argv[]) { std::cout << "Hello, World!\n"; return 0; } I have configured Xcode such that it uses the libstdc++ standard C++ library. I also made sure that in build phases, I linked with libQuantLib.dylib. However, I still get the following build errors. I was able to successfully compile and run the main program in Terminal. So I guess I must have missed some settings in Xcode itself. I have been trying to figure this one out for the whole day but with no success. Any help will be greatly appreciated! Thank you. Ld /Users/yanjiapan/Library/Developer/Xcode/DerivedData/QuantLibTest-agtlucifijzmvggbdcsfvxmuzuak/Build/Products/Debug/QuantLibTest normal x86_64 cd /Users/yanjiapan/workspace/xcode/QuantLibTest export MACOSX_DEPLOYMENT_TARGET=10.9 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -L/Users/yanjiapan/Library/Developer/Xcode/DerivedData/QuantLibTest-agtlucifijzmvggbdcsfvxmuzuak/Build/Products/Debug -L/opt/local/lib -F/Users/yanjiapan/Library/Developer/Xcode/DerivedData/QuantLibTest-agtlucifijzmvggbdcsfvxmuzuak/Build/Products/Debug -filelist /Users/yanjiapan/Library/Developer/Xcode/DerivedData/QuantLibTest-agtlucifijzmvggbdcsfvxmuzuak/Build/Intermediates/QuantLibTest.build/Debug/QuantLibTest.build/Objects-normal/x86_64/QuantLibTest.LinkFileList -mmacosx-version-min=10.9 -stdlib=libstdc++ -lQuantLib.0 -Xlinker -dependency_info -Xlinker /Users/yanjiapan/Library/Developer/Xcode/DerivedData/QuantLibTest-agtlucifijzmvggbdcsfvxmuzuak/Build/Intermediates/QuantLibTest.build/Debug/QuantLibTest.build/Objects-normal/x86_64/QuantLibTest_dependency_info.dat -o /Users/yanjiapan/Library/Developer/Xcode/DerivedData/QuantLibTest-agtlucifijzmvggbdcsfvxmuzuak/Build/Products/Debug/QuantLibTest Undefined symbols for architecture x86_64: "QuantLib::MultiStepSwap::nextTimeStep(QuantLib::CurveState const&, std::vector<unsigned long, std::allocator<unsigned long> >&, std::vector<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> >, std::allocator<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> > > >&)", referenced from: vtable for QuantLib::MultiStepSwap in main.o "QuantLib::ExerciseAdapter::nextTimeStep(QuantLib::CurveState const&, std::vector<unsigned long, std::allocator<unsigned long> >&, std::vector<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> >, std::allocator<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> > > >&)", referenced from: vtable for QuantLib::ExerciseAdapter in main.o "QuantLib::OneStepForwards::nextTimeStep(QuantLib::CurveState const&, std::vector<unsigned long, std::allocator<unsigned long> >&, std::vector<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> >, std::allocator<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> > > >&)", referenced from: vtable for QuantLib::OneStepForwards in main.o "QuantLib::MultiStepNothing::nextTimeStep(QuantLib::CurveState const&, std::vector<unsigned long, std::allocator<unsigned long> >&, std::vector<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> >, std::allocator<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> > > >&)", referenced from: vtable for QuantLib::MultiStepNothing in main.o "QuantLib::MultiStepRatchet::nextTimeStep(QuantLib::CurveState const&, std::vector<unsigned long, std::allocator<unsigned long> >&, std::vector<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> >, std::allocator<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> > > >&)", referenced from: vtable for QuantLib::MultiStepRatchet in main.o "QuantLib::MultiStepForwards::nextTimeStep(QuantLib::CurveState const&, std::vector<unsigned long, std::allocator<unsigned long> >&, std::vector<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> >, std::allocator<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> > > >&)", referenced from: vtable for QuantLib::MultiStepForwards in main.o "QuantLib::MultiStepSwaption::nextTimeStep(QuantLib::CurveState const&, std::vector<unsigned long, std::allocator<unsigned long> >&, std::vector<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> >, std::allocator<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> > > >&)", referenced from: vtable for QuantLib::MultiStepSwaption in main.o "QuantLib::OneStepOptionlets::nextTimeStep(QuantLib::CurveState const&, std::vector<unsigned long, std::allocator<unsigned long> >&, std::vector<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> >, std::allocator<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> > > >&)", referenced from: vtable for QuantLib::OneStepOptionlets in main.o "QuantLib::MultiStepOptionlets::nextTimeStep(QuantLib::CurveState const&, std::vector<unsigned long, std::allocator<unsigned long> >&, std::vector<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> >, std::allocator<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> > > >&)", referenced from: vtable for QuantLib::MultiStepOptionlets in main.o "QuantLib::OneStepCoinitialSwaps::nextTimeStep(QuantLib::CurveState const&, std::vector<unsigned long, std::allocator<unsigned long> >&, std::vector<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> >, std::allocator<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> > > >&)", referenced from: vtable for QuantLib::OneStepCoinitialSwaps in main.o "QuantLib::OneStepCoterminalSwaps::nextTimeStep(QuantLib::CurveState const&, std::vector<unsigned long, std::allocator<unsigned long> >&, std::vector<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> >, std::allocator<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> > > >&)", referenced from: vtable for QuantLib::OneStepCoterminalSwaps in main.o "QuantLib::MultiStepCoinitialSwaps::nextTimeStep(QuantLib::CurveState const&, std::vector<unsigned long, std::allocator<unsigned long> >&, std::vector<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> >, std::allocator<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> > > >&)", referenced from: vtable for QuantLib::MultiStepCoinitialSwaps in main.o "QuantLib::MultiStepInverseFloater::nextTimeStep(QuantLib::CurveState const&, std::vector<unsigned long, std::allocator<unsigned long> >&, std::vector<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> >, std::allocator<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> > > >&)", referenced from: vtable for QuantLib::MultiStepInverseFloater in main.o "QuantLib::MultiStepCoterminalSwaps::nextTimeStep(QuantLib::CurveState const&, std::vector<unsigned long, std::allocator<unsigned long> >&, std::vector<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> >, std::allocator<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> > > >&)", referenced from: vtable for QuantLib::MultiStepCoterminalSwaps in main.o "QuantLib::MultiStepCoterminalSwaptions::nextTimeStep(QuantLib::CurveState const&, std::vector<unsigned long, std::allocator<unsigned long> >&, std::vector<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> >, std::allocator<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> > > >&)", referenced from: vtable for QuantLib::MultiStepCoterminalSwaptions in main.o "QuantLib::MultiStepPeriodCapletSwaptions::nextTimeStep(QuantLib::CurveState const&, std::vector<unsigned long, std::allocator<unsigned long> >&, std::vector<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> >, std::allocator<std::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::allocator<QuantLib::MarketModelMultiProduct::CashFlow> > > >&)", referenced from: vtable for QuantLib::MultiStepPeriodCapletSwaptions in main.o "QuantLib::Error::Error(std::string const&, long, std::string const&, std::string const&)", referenced from: QuantLib::DiscretizedOption::reset(unsigned long) in main.o QuantLib::Observable::notifyObservers() in main.o QuantLib::Instrument::setupArguments(QuantLib::PricingEngine::arguments*) const in main.o QuantLib::Option::setupArguments(QuantLib::PricingEngine::arguments*) const in main.o QuantLib::Payoff::accept(QuantLib::AcyclicVisitor&) in main.o QuantLib::BlackVolTermStructure::accept(QuantLib::AcyclicVisitor&) in main.o QuantLib::SimpleQuote::value() const in main.o ... "QuantLib::operator<<(std::ostream&, QuantLib::Date const&)", referenced from: QuantLib::InterestRateIndex::valueDate(QuantLib::Date const&) const in main.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) |
Dear Kristine, This is how I configured Xcode when I was compiling Quantlib examples on it. If one wants to build an example in Xcode, he needs to follow the steps given below. Here it is assumed that Xcode has been configured in that C++ coding is supported. 1. Create a Xcode project 2. Add the example cpp file to this project. 3. Important: - setting path for other Quantlib and Boost headers and Quantlib libraries. 1) Go to Build Settings of the project. Under Search Paths, add path /opt/local/include/ and path /opt/local/include/boost to Header Search Paths. 2) Also under Search Paths, add path /opt/local/lib/ to Library Search Paths. 3) For all the three paths, select non-recursive when each of them is added. 4) Go to Linking. Add -lQuantLib to Other Linker Flags. Then, the example will be able to built and run in Xcode.
Hope it helps.
Regards,
Bo On 9 August 2014 13:14, kristine pan <[hidden email]> wrote: Hi all, ------------------------------------------------------------------------------ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Bo,
Thank you so much for your detailed instructions. They are very clear and easy to follow. I am able to successfully build the project now. Before, I did set the header search and library search paths, but instead of setting linking under other linker flags, I used the Linking Binary with Libraries setting under Build Phase instead. Maybe that is what makes the difference. Thank you very much for your help! Regards, Yanjia |
I did some further investigation. Contrary to information I saw under other posts reporting similar issues, setting C++ Standard Library to libstdc++ actually cause build errors in my case. I was able to build successfully leaving the value as the default libc++. Maybe this only applies to Xcode 5.1.
|
In reply to this post by kristine pan
Dear Yanjia, Great. It's good to hear that. Regards, Bo On 11 August 2014 14:05, kristine pan <[hidden email]> wrote: Hi Bo, ------------------------------------------------------------------------------ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |