Results 1 to 10 of 10

Thread: Creating projects for different platforms

  1. #1
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default 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!

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Creating projects for different platforms

    Does this help?

    Or this?

  3. #3
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Creating projects for different platforms

    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!

  4. #4
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Creating projects for different platforms

    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"

  5. #5
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Creating projects for different platforms

    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!

  6. #6
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Creating projects for different platforms

    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?

  7. #7
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Creating projects for different platforms

    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!

  8. #8
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Creating projects for different platforms

    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.

  9. #9
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Creating projects for different platforms

    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).

  10. #10
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Creating projects for different platforms

    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!

Similar Threads

  1. Multiple platforms
    By ctote in forum Qt Programming
    Replies: 8
    Last Post: 15th February 2010, 19:48
  2. How to unify the QT style in different platforms?
    By yangyunzhao in forum Qt Programming
    Replies: 7
    Last Post: 5th August 2009, 11:23
  3. send OS signals to apps on all platforms
    By Morea in forum Qt Programming
    Replies: 3
    Last Post: 21st November 2008, 22:00
  4. What platforms are you using Qt on?
    By gfunk in forum Qt Programming
    Replies: 7
    Last Post: 8th February 2007, 15:47
  5. Compiling on different platforms
    By Tori in forum Newbie
    Replies: 1
    Last Post: 25th January 2006, 22:09

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.