Frage

I've attempted to install QuantLib-1.4 on Cygwin along with Boost_1_55_0, mainly by following these steps: http://quantess.net/2012/09/26/quantlib-get-it-working-on-ubuntu/

After installation, I've ran quantlib's test cases with no error detected:

xxx@xxx /usr/local/lib/QuantLib-1.4/test-suite
$ ./quantlib-test-suite.exe
Running 567 test cases...

Tests completed in 15 m 20 s


*** No errors detected

However when I ran a simple code (main.cpp):

#include <ql/quantlib.hpp>

int main(){
    return 0;
}

Linker errors seems to occur.

xxx@xxx /usr/local/lib
$ g++ -lQuantLib main.cpp
/tmp/ccvjpqgC.o:main.cpp:(.text$_ZNK8QuantLib4DateplERKNS_6PeriodE[__ZNK8QuantLib4DateplERKNS_6PeriodE]+0x2e): undefined reference to `QuantLib::Date::advance(QuantLib::Date const&, int, QuantLib::TimeUnit)'
/tmp/ccvjpqgC.o:main.cpp:(.text$_ZN8QuantLib5ErrorD1Ev[__ZN8QuantLib5ErrorD1Ev]+0xd): undefined reference to `vtable for QuantLib::Error'
/usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld: /tmp/ccvjpqgC.o: bad reloc address 0xd in section `.text$_ZN8QuantLib5ErrorD1Ev[__ZN8QuantLib5ErrorD1Ev]'
collect2: error: ld returned 1 exit status

I have tried to add the INCLUDE_PATH and LIBRARY_PATH into windows's environment variables with little difference. Any help here? (I am pretty new to gcc & linux env... Thanks)

War es hilfreich?

Lösung

Sorry I'm this late to the party.

It's a quirk of gcc. Your command doesn't work, but

g++ main.cpp -lQuantLib

does instead (see, for instance, Why does the order in which libraries are linked sometimes cause errors in GCC? for a thourough explanation; in short, gcc scans arguments from left to right, and won't load anything from QuantLib if it's the first argument because no other code requested any of its functionality yet).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top