PDA

View Full Version : [Help] Problems about QT links to MSVC *.lib



eric970119
18th June 2010, 06:37
Hello~ all...
I'm new with QT and program in windows
Recently I download an openSource *.lib from http://code.google.com/p/asmlibrary/downloads/list
The fileis "asmlibrary-5.0.tar.gz " ...
After extracting it and run the project in MSVC 2008, it works fine...
Now I try to create GUI with QT and link to MSVC library ...

the compile error is shown as below...
-------------------------------------------------------------------------------------------------------------
debug/camGL.o: In function `CamGL':
D:\QT_Project\AR\ASM/camGL.cpp:6: undefined reference to `asmfitting::asmfitting()'
D:\QT_Project\AR\ASM/camGL.cpp:28: undefined reference to `asmfitting::~asmfitting()'
D:\QT_Project\AR\ASM/camGL.cpp:6: undefined reference to `asmfitting::asmfitting()'
D:\QT_Project\AR\ASM/camGL.cpp:28: undefined reference to `asmfitting::~asmfitting()'
debug/camGL.o: In function `~CamGL':
D:\QT_Project\AR\ASM/camGL.cpp:33: undefined reference to `asmfitting::~asmfitting()'
D:\QT_Project\AR\ASM/camGL.cpp:33: undefined reference to `asmfitting::~asmfitting()'
D:\QT_Project\AR\ASM/camGL.cpp:33: undefined reference to `asmfitting::~asmfitting()'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\CameraGL.exe] Error 1
mingw32-make: *** [debug] Error 2
Exited with code 2.
Error while building project CameraGL
When executing build step 'Make'
--------------------------------------------------------------------------------------------------------------------------------------

Then I google and find an article "MSVC and MinGW DLLs" :cool:
http://www.mingw.org/wiki/MSVC_and_MinGW_DLLs

So I followed the steps in QT Command Prompt (without gcc steps...)
1.reimp testdll.lib
2.pexports testdll.dll | sed "s/^_//" > testdll.def
3.dlltool -U -d testdll.def -l libtestdll.a
I wish I can modify the MSVC *.lib to MinGW library ...
But nothing happened....:mad:

I've solved for 2 days...
Does anyone know how to solve this problem...~?
Thanks for your reply ...:D

high_flyer
18th June 2010, 08:40
You have compile errors, not link errors.
Probably the include path for 'asmfitting' is not defined in your project, and maybeother paths as well.
Make sure all the include paths are defined.

eric970119
23rd June 2010, 07:21
I put the asmfitting.h in my project ...
when I key #include <> ... and the popup window can show my asmfitting.h
But after I define a var with asmfitting class ...
the error as I said in my first post ....

I also try to link cygasmlibrary-4.dll ...
It can be compiled successfully ...but the window will be closed immediately and nothing happended...
and the error message shows ...
.. ASM_test.exe exited with code -1073741511

Please ~~~~ help me ... :(

ChrisW67
24th June 2010, 00:43
You will not be able to easily link a DLL built using MSVC to a program built using MingW if the DLL is exporting C++ classes (no problem for pure C interfaces). The most straightforward approaches are to;

rebuild the library with MingW, or
rebuild your application with MSVC.
This way the binary interfaces are compatible.

eric970119
26th June 2010, 07:21
Appreciation for your suggestion ...

how sad that I didn't have the source code...can
But the file has the *.lib compiled by Cygwin ...
Originally I guess it could be run with QT (MinGW) ...
But it still can't work ...

So... The QT can't compatible with Cygwin *lib ~???
Thanks~~~! ^^ :)

ChrisW67
26th June 2010, 09:06
Qt is not the issue here. You have a binary form of the C++ asmlibrary built with MSVC. You cannot link that to a binary created with MingW (i.e. gcc) except under specific circumstances that you don't have. The Cygwin binary might be usable but I cannot say I have ever tried that.

Asmlibrary should come with source code** that should be buildable with the MingW suite with a bit of tweaking.

You other option is to build Qt with MSVC so that its binaries are compatible with the asmlibrary (and I assume OpenCV) libraries. Then build your Qt app with that Qt version.

** Seems it doesn't... I thought Google Code was hosting for open source projects ?

squidge
26th June 2010, 09:35
It is. You can request the source from the author. If they don't respond or say you can't have it, you contact Google and they ask for you, which normally means one of two things: They publish the source, or they close the site.