View Full Version : Creating projects for different platforms
Hi! I have some projects which use libraries which are different from one platform to another. This means I have to link to different libraries and include different headers when I compile for different platforms.
I use qmake to create projects for different platforms and different IDEs. For instance, if I want to compile with VS2008 for wince I use qmake on my project to create a VS2008 project. The problem is that every time I use qmake I have that my additional includes and libraries for wince are replaced.
Is there any way to write a .pro file which have includes and libs for different platform, so that, when I qmake I get a VS project with the correct paths? I hope my post is clear.
Thanks!
SixDegrees
21st May 2010, 14:43
Does this (http://doc.qt.nokia.com/4.5/qmake-project-files.html#built-in-functions-and-control-flow)help?
Or this (http://doc.qt.nokia.com/4.5/qmake-advanced-usage.html#scopes)?
I placed this in my .pro file:
win32:LIBS += -L"C:\path\libs" -llib1 -llib2
but it seems it cannot link... The libraries are:
C:\path\lib1.lib
C:\path\lib2.lib
Any idea why it should not?
Thanks!
SixDegrees
21st May 2010, 17:42
Might be a quoting problem. Can you see what your actual build line looks like during compilation?
Try putting quotes around the whole expression:
win32:LIBS += "-L\"C:\path\libs\" -llib1 -llib2"
or
win32:LIBS += "-LC:\path\libs -llib1 -llib2"
Seems it's not working either ways... By build line I suppose you mean this:
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug\SCD.exe object_script.SCD.Debug -L"c:\Qt\2010.01\qt\lib" -lmingw32 -lqtmaind "-LC:\path\libs -llib1 -llib2" -lQtGuid4 -lQtCored4
This is a link problem right? Not an include issue. In fact qt creator finds the headers and autocompletion is working. Any other idea?
Thanks again!
SixDegrees
22nd May 2010, 12:53
So I can see from the build line that qmake is inserting your path and libraries, exactly as they occur in your project file. I'm still not sure about the quoting; if the preceding Qt linkage is working, I guess that would be the template to follow. But the string you put in your project file, at least, is getting spat out to the compiler, and I presume it is only spat out as shown here when building for win32.
Windows, however, isn't my long suit, so I don't know the peculiarities of path construction and quoting required on that platform. But it looks like everything is working as expected from a qmake standpoint.
If there's some other problem, can you describe exactly what it is?
I see I didn't report the problem exactly. I get:
C:\path2/main.cpp:14: undefined reference to `PLT_UPnP::PLT_UPnP(unsigned int, bool)'
C:\path2/main.cpp:31: undefined reference to `PLT_UPnP::~PLT_UPnP()'
C:\path2/main.cpp:31: undefined reference to `PLT_UPnP::~PLT_UPnP()'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\SCD.exe] Error 1
mingw32-make: *** [debug] Error 2
Exited with code 2.
Error while building project SCD
When executing build step 'Make'
This class is defined in lib1 but, as far as I can understand, the linker is not able to link it.
Thanks for your time!
I really suppose it's something related to the .pro file. I just tried to create the VS project, I added those two libraries to Visual Studio and the project was compiled and liked correctly.
The .lib files were created with Visual Studio and are static libraries. Maybe it isn't possible to link those in the qt project? Because in Visual Studio the project seems to work correctly, both compiled for win32 and wince (using of course the wince versions of the libraries).
In case anyone need it, I suppose the issue I was experiencing was related to the fact that I was trying to use a library compiled by Visual Studio with mingw, and this is not possible. Compiling my Qt code with Visual Studio as well solved the problems both on win32 and on wince.
Thanks!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.