specify all the .lib files as library inputs(also specify the library files path) and place all the required/corresponding dlls folder path in env PATH variable such that exe can link with the dlls during runtime.
specify all the .lib files as library inputs(also specify the library files path) and place all the required/corresponding dlls folder path in env PATH variable such that exe can link with the dlls during runtime.
Last edited by nikhilqt; 21st April 2010 at 06:35.
babygal (27th April 2010)
Hi, Thank you for the reply.
Could you please give me examples for :
"specify all the .lib files as library inputs(also specify the library files path)"
and "place all the required/corresponding dlls folder path in env PATH variable"
?
Thank you.
Hi, I forgot to mention that the app.exe was created/built using QT environment and proj.dll, proj.lib and the header files were created/built using VS2005 environment...
Okay, so your app.exe was linked at compile time with corresponding proj.lib, yes?
If yes, then add path to the directory containing your proj.dll to the PATH environment variable or simply copy proj.dll to the same directory where app.exe is.
EDIT:
If you want to load a library at runtime without compile time linking, then use QLibrary.
But I understand that you want to link it in compile time with .lib and run with .dll, which is simple.
But can you explain what does it mean "Qt environment"? Qt does not contain any C++ compiler, so if you have compiled it on the same PC as proj.dll then you probably used your VS compiler, or you have Qt SDK with MinGW installed so it uses MinGW for compiling, so then you need proj.a instead of proj.lib.
Can you show us what have you tried?
Last edited by faldzip; 21st April 2010 at 09:22. Reason: updated contents
babygal (27th April 2010)
Hi , below are my answers,
1>>>"Okay, so your app.exe was linked at compile time with corresponding proj.lib, yes?"
- I think app.exe is not linked at compile time with corresponding proj.lib.by the way, how can I confirm this?
2>>But can you explain what does it mean "Qt environment"? Qt does not contain any C++ compiler, so if you have compiled it on the same PC as proj.dll then you probably used your VS compiler, or you have Qt SDK with MinGW installed so it uses MinGW for compiling, so then you need proj.a instead of proj.lib.
QT environment - I was referring to QT creator.
No, the app.exe and proj.dll are compiled on different PCs.The proj.dll is built using VS compiler,whereas,
the app.exe is built using MinGW.
Q: Do I need a proj.a instead of proj.lib?I don't understand.
================================================== =======================
Here is an extract of my app.pro file: ( .\lib contains ((CAT_DLL.lib) == (proj.lib)) and app.exe and ((CAT_DLL.dll)==(proj.dll)) are in same folder which is the \Debug folder.
================================================== =======================
TEMPLATE = app
LIBS += -L/./lib -lCAT_DLL
CONFIG += dll CAT_DLL.dll
INCLUDEPATH += ./lib
INCLUDEPATH += ./Debug
INCLUDEPATH += ./Temp (Temp folder contains few header files which is supposed to be for the proj.dll )
HEADERS += ...all header files
FORMS += mainwindow.ui
SOURCES += ...all source files
RESOURCES += cardiacprocessingtoolkit.qrc
================================================== ==================
>>Compile output:
c:/qt/2010.02.1/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cannot find -lCAT_DLL
collect2: ld returned 1 exit status
mingw32-make[1]: Leaving directory `C:/Documents and Settings/muniandyu/My Documents/Visual Studio 2005/Projects/Work/Cardiac_CAT DLL_WIP/Cardiac'
mingw32-make[1]: *** [debug\Cardiac.exe] Error 1
mingw32-make: Leaving directory `C:/Documents and Settings/muniandyu/My Documents/Visual Studio 2005/Projects/Work/Cardiac_CAT DLL_WIP/Cardiac'
mingw32-make: *** [debug] Error 2
Exited with code 2.
Error while building project Cardiac
When executing build step 'Make'
Last edited by babygal; 21st April 2010 at 10:12.
okay, so:
1. LIBS qmake variable describes with which libraries your target (in your case app.exe) should be linked. But this means (on Windows) that you need two files describing your library:
- proj.lib, proj.dll - if you are compiling with VS. Then .lib is the file to link with during compilation and .dll is a file used during runtime and loaded automatically if you linked with .lib while compiling
- proj.a (or libproj.a - not sure about this), proj.dll - when using MinGW - similar to VS: .a - for linking at compile time, .dll - for loading at runtime.
2. To link at compile time you have to add to your .pro:
Qt Code:
LIBS += -Lpath/to/library -lnameoflibraryTo copy to clipboard, switch view to plain text mode
3. remove CONFIG += dll CAT_DLL.dll as your target is not a dll but executable file!
4. your compiler said that it cannot find your library, check path and check if there is required CAT_DLL.a (or libCAT_DLL.a) file.
babygal (27th April 2010)
Hi, Thank you so much for the reply.
Just to confirm,in my case, I need proj.lib or proj.a ?
Thank you.
GCC uses .a
VC uses .lib
babygal (27th April 2010)
Hi,
Could you explain further?
My app.exe is compiled using MinGW and proj.dll is compiled using VS.
and I wish to link my app.exe with the proj.dll.(however, i wish to compile and link both using MinGW)
So am I doing it correctly now,or I need a proj.a to link with my app.exe?(by the way can VS output *.a file?)
bit confused *-)
Last edited by babygal; 22nd April 2010 at 08:20.
If you compile your app.exe with MinGW then all libraries you link to has to be .a
So you have to convert your proj.lib to proj.a (or as I said it can be libproj.a - not sure about it).
Search the net or forum to find how to do it. It was mentioned some days ago in some post here on QtCentre, AFAIR the tools are 'dlltool' and reimp or something like this.
babygal (27th April 2010)
It is difficult to link MVSC DLL to GCC executable by using static stub.
The easiest way would be to use QLibrary in this instance, then you don't need .a or .lib files, just the DLL.
babygal (27th April 2010)
So another solution might be to use VisualStudio Express Edition and compile Qt with it :] (I don't remember if there is WindowsSDK or rather PlatformSDK needed for this)
babygal (27th April 2010)
Bookmarks