-lQuantLib tells the linker to link the file libQuantLib.a, that is a static library, not a dynamic one (shared object) .so, which, being a dynamic
lib, would get loaded at runtime. Just specify the -lQuantLib in the rule:
should do the trick, although /usr/lib should be in the default path to check for libs, and shouldn't need to be explicitly defined.
Obviously, file libQuantLib.a needs to be present in /usr/lib.
test.o:(.rodata._ZTIN8QuantLib13TermStructureE[typeinfo for QuantLib::TermStructure]+0x0): undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
test.o:(.rodata._ZTIN8QuantLib12ExtrapolatorE[typeinfo for QuantLib::Extrapolator]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
test.o:(.rodata._ZTIN8QuantLib19StochasticProcess1D14discretizationE[typeinfo for QuantLib::StochasticProcess1D::discretization]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
test.o:(.rodata._ZTIN8QuantLib17StochasticProcess14discretizationE[typeinfo for QuantLib::StochasticProcess::discretization]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
test.o:(.rodata._ZTIN8QuantLib5QuoteE[typeinfo for QuantLib::Quote]+0x0): undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
test.o:(.rodata._ZTIN8QuantLib7VisitorINS_6PayoffEEE[typeinfo for QuantLib::Visitor<QuantLib::Payoff>]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
when at the $ prompt, I give the following command:
g++ -o test test.cpp -L/usr/lib -lQuantLib
it works perfectly fine??
The plus and equal need to be together, it's one operator, just like in C.
To debug Makefile, you should look at the command that's executed when you run 'make'. The command that's being run is echoed on stdout. Look carefully at that command -- it should be exactly what you want:
g++ -L/usr/lib -o test test.cpp -lQuantLib
Since you are getting the errors, you will see something else:
it'll be missing either the -L/usr/lib or -lQuantLib.
Also, just to be safe, delete the old object file test.o before recompiling.
hi mirni,
thanks for the correction.
I was getting an error message with LD_FLAGS, wherein automake warned me to use AM_LDFLAGS since LD_FLAGS is a user defined variable. then I got warned to use = for AM_LDFLAGS before using +=, so I rewrote Makefile.am as:
Sorry bacpp, I mistakenly thought you were writing a Makefile and using GNU make. My advice was for that case.
Usage of GNU automake and Makefile.am is different, and I don't have experience with writing Makefile.am myself, but from automake it seems that all you need is:
Is there a reason you are using automake? It requires you have configure.ac set-up and is a tool for complex projects.
When invoking 'make test', you are invoking GNU make, and that can't find any Makefile, so is applying a default rule.
Maybe you want to write a Makefile instead of using automake.
---------- Post updated at 05:35 AM ---------- Previous update was at 05:31 AM ----------
Is there a reason you are using automake? for learning-sake...I have setup configure.ac, and my Makefile.in file has also been created, so I wanted to test it out.
When invoking 'make test', you are invoking GNU make, and that can't find any Makefile, so is applying a default rule. ....I see....there should be a way to fix that, right....
There's nothing to fix. You're mixing apples and oranges. You want to run 'automake' not 'make'.
Also, there is a section 'programming' on this forum, where your post would be more appropriate and would be looked at by competent people, that, unlike myself, have experience with automake.
In any case, good luck!
I am obviously not doing something right then....I basically followed the steps for automake from Automake - Wikipedia, the free encyclopedia
after creating the Makefile.am, I ran automake, and then ./configure, followed by 'make test'...and that's where it started...
this might be a dumb thing I did, but nevertheless, when I type 'automake test', it returns:
automake: no Automake input file found for `test'
automake: no input file found among supplied arguments
So your Makefile has been generated? And since you're getting the error, the library hasn't been included in there, right? So you'll have to go back, and fix <something> to have the correct rule (with the lib) in generated Makefile.
thanks mirni,
yes, it has been generated and just got that fixed....I had to rename Makefile.am to Makefile, and it worked.
here's what I have in my Makefile: