PDA

View Full Version : linking qt3 to a library



thebra
8th November 2006, 20:08
Hi everyone,
I have a code written in C++ (code.cpp) which uses a library called minuit. I usually compile it with a command line:
g++ -g -O2 -o code.out -I/home/Minuit-1_7_6/include -L/home/Minuit-1_7_6/lib -llcg_Minuit code.cpp
Now I made a GUI to do the same thing , and I have rewritten code.ui.h to do what code.cpp used to do. But I am not able to change code.pro (which generates the Makefile using qmake) to link to the minuit library . Could anyone, please, help me to solve this problem? Thanks
---------------------------------------------------------code.pro---------------------------------------------
TEMPLATE = app
DEPENDPATH += header
INCLUDEPATH += . header
TMAKE_CXXFLAGS = -g
INCLUDEPATH += /home/Minuit-1_7_6/include
LIBS += -L/home/Minuit-1_7_6/lib -llcg_Minuit
CONFIG = qt warn_off release
# Input
HEADERS += code.ui.h \
version.h
INTERFACES += code.ui
SOURCES += main.cpp

jacek
8th November 2006, 20:14
INCLUDEPATH += /home/Minuit-1_7_6/include
LIBS += -L/home/Minuit-1_7_6/lib -llcg_Minuit
It looks OK. Did you remember to rerun qmake to get a new Makefile?

thebra
8th November 2006, 20:21
yes I did using qmake -o Makefile code.pro and then make

jacek
8th November 2006, 20:50
Can you post the exact error message?

thebra
8th November 2006, 21:03
Thanks for your replies. After I type make I get the following (where the MODEL functions below are defined in minuit library)
----------------------------------------------------------------------------------------------------------------------------
g++ -c -g -w -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fomit-frame-pointer -march=i586 -mtune=pentiumpro -DQT_NO_DEBUG -I/usr/lib/qt3/mkspecs/default -I. -I. -Iheader -I/home/Minuit-1_7_6/include -I/usr/lib/qt3//include -o code.o code.cpp
In file included from code.cpp:28:
code.ui.h: In member function `virtual void Code::test()':
code.ui.h:1931: error: no matching function for call to `MODEL::MODEL(std::vector<double, std::allocator<double> >&, <unknown type>, std::vector<double, std::allocator<double> >&)'
header/version.h:5: error: candidates are: MODEL::MODEL(const MODEL&)
header/version.h:12: error: MODEL::MODEL(const std::vector<double, std::allocator<double> >&, const std::vector<double, std::allocator<double> >&, const std::vector<double, std::allocator<double> >&)
{standard input}: Assembler messages:
{standard input}:146100: Error: Local symbol `.LTHUNK0' can't be equated to undefined symbol `_ZN4BnmrD1Ev'
{standard input}:146100: Error: Local symbol `.LTHUNK1' can't be equated to undefined symbol `_ZN4BnmrD0Ev'
make: *** [bnmr.o] Error 1
------------------------------------------------------------------------------------------------------------------------------

jacek
8th November 2006, 21:12
code.ui.h:1931: error: no matching function for call to `MODEL::MODEL( ... <unknown type> ...)'
header/version.h:5: error: candidates are: MODEL::MODEL(const MODEL&)
header/version.h:12: error: MODEL::MODEL(...)
It looks like something on line 1931 in code.ui.h is causing troubles. What do you have there?


{standard input}:146100: Error: Local symbol `.LTHUNK0' can't be equated to undefined symbol `_ZN4BnmrD1Ev'
{standard input}:146100: Error: Local symbol `.LTHUNK1' can't be equated to undefined symbol `_ZN4BnmrD0Ev'
Do you use Bnmr class somewhere? It looks like you have declared a Bnmr::~Bnmr() destructor, but you didn't implement it.

thebra
8th November 2006, 21:26
MODEL function is defined in the minuit library and called in version.h. Bnmr was defined in the header file as well. In fact the code compiles fine without linking to the minuit library ( as I remove the line 1931).

jacek
8th November 2006, 21:32
MODEL function is defined in the minuit library and called in version.h.
Judging from the compiler error, you just use it in a wrong way, or the header file is wrong --- note the "<unknown type>" in the error message. What parameter are you trying to pass to MODEL::MODEL()?

thebra
8th November 2006, 21:47
I am trying to pass data in form of ( x, y, dy) to be fitted using the minuit library. The code works perfect when compiled using a command line. But it doesn't when adjusted to fit in a GUI. Is it linking problem or just problems with unknown classes? I will check that again. But do you think there is nothing wrong with code.pro? Thanks

jacek
8th November 2006, 21:58
Is it linking problem or just problems with unknown classes?
That error message comes from the compiler, not linker, so either you have some typo in your code or missing #include directive.


But do you think there is nothing wrong with code.pro?
Yes, it looks OK.

thebra
11th November 2006, 01:25
I figured it out and it had to do with how classes of the C++ code were defined. Thanks for your help.