I have the following code in my Makefile.am that works fine for simple programs:
bin_PROGRAMS=test
test_SOURCES=test.cpp
so, when I run 'make test', it runs the following command:
g++ -o test test.cpp
however, when I tried to run a program that includes the QuantLib library, I have to give the following command:
g++ -o test test.cpp -L/usr/lib -lQuantLib
so, I modified my Makefile.am to include the following:
test_LDADD = /usr/lib/libQuantLib.so
but that doesn't work; it gives me the same bunch of errors as it does if I only ran my test program without the -L and -l flags.
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....I believe it is a linking error
I'm not at all an expert on makefiles, but I think maybe the problem is the order in which you pass arguments to g++. I'm not sure though. but try this: (be careful with copy-paste as the indention is off)
bin_PROGRAMS does not refer to ${bin_PROGRAMS}, so your output will be an executable named bin_PROGRAM. You are actually not using the ${bin_PROGRAMS} variable. When you refer to $@ you refer to the target:
Ahh, it seems I did not read your first post thoroughly enough. :-)
What you need to do is:
Rename MakeFile.am to MakeFile and try it again.
When you run
make test
the Make utility looks for a file named MakeFile. It does not look for a MakeFile.am. MakeFile.am is a file generated by automake. So in your case, it does not find a Makefile and it just do a standard compilation of test.cpp
An easy way to test this is to issue
make
instead of
make [target]
The latter command is only used if you have more than one MakeFile in your working directory.