Results 1 to 6 of 6

Thread: Platform dependent source files: what is best?

  1. #1
    ucomesdag Guest

    Question Platform dependent source files: what is best?

    I'm writting somthing that runs on windows/mac osx/linux.
    If got one set of source filles that is dependent on the platform ho do i best include them?
    Qt Code:
    1. win32 {
    2. #LIBS += ./WinMM.Lib
    3. HEADERS += ./windows/midiIO.h
    4. SOURCES += ./windows/midiIO.cpp
    5. message(Including Windows specifique headers and sources...)
    6. }
    7. unix {
    8. HEADERS += ./linux/midiIO.h
    9. SOURCES += ./linux/midiIO.cpp
    10. message(Including Linux specifique headers and sources...)
    11. }
    12. macx {
    13. HEADERS += ./macosx/midiIO.h
    14. SOURCES += ./macosx/midiIO.cpp
    15. message(Including Mac OS X specifique headers and sources...)
    16. }
    To copy to clipboard, switch view to plain text mode 
    If I put it like this in their own sub dir. it complains that it cant find #include "midiIO.h" when compiling so I have to include with the path to the sub dir. #include "windows/midiIO.h" so I have to change the include on every platform....?????

    I'm a bit lost....
    ....any advise???

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Platform dependent source files: what is best?

    this can help


    win32 {
    INCLUDEPATH += ./windows
    ...
    }

    unix {
    INCLUDEPATH += ./linux
    ...
    }

    macx {
    INCLUDEPATH += ./macosx
    ...
    }

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Platform dependent source files: what is best?

    You can write yourself a macro (function) which will expand differently depending on the platform. See qmake docs for details.

  4. #4
    ucomesdag Guest

    Question Re: Platform dependent source files: what is best?

    Is there a way to it without writting macros? It is still complaining about it can not finding the header files. Adding the path takes out the whole use fullness. Otherwise it's easier to replace manually the platfrom dependent files.

    BTW I cant find the part about writting macros in the qmake manual, can you please point me at it, cause google won't...

    I dont see the usefullness of telling qmake wich files to add if you have to write macros to include the correct file... Than a macro only would do it (if I could find the maco part in the manual)...

    Maybe I'm missing something? I would prefer to do it without macros but how? Anyone?

    Qt Code:
    1. win32 {
    2. LIBS += WinMM.Lib
    3. HEADERS += ./windows/midiIO.h
    4. SOURCES += ./windows/midiIO.cpp
    5. INCLUDEPATH += ./windows
    6. message(Including Windows specifique headers and sources...)
    7. }
    8. unix {
    9. HEADERS += ./linux/midiIO.h
    10. SOURCES += ./linux/midiIO.cpp
    11. INCLUDEPATH += ./unix
    12. message(Including Linux specifique headers and sources...)
    13. }
    14. macx {
    15. HEADERS += ./macosx/midiIO.h
    16. SOURCES += ./macosx/midiIO.cpp
    17. INCLUDEPATH += ./macosx
    18. message(Including Mac OS X specifique headers and sources...)
    19. }
    To copy to clipboard, switch view to plain text mode 

    adding INCLUDEPATH does the job... All fine now!
    Last edited by jacek; 27th November 2006 at 15:17. Reason: merged 3 posts

  5. #5
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Platform dependent source files: what is best?

    Quote Originally Posted by ucomesdag View Post
    I'm writting somthing that runs on windows/mac osx/linux.
    If got one set of source filles that is dependent on the platform ho do i best include them?
    Qt Code:
    1. win32 {
    2. }
    3. unix {
    4.  
    5. }
    6. macx {
    7.  
    8. }
    To copy to clipboard, switch view to plain text mode 
    If I put it like this in their own sub dir. it complains that it cant find #include "midiIO.h" when compiling so I have to include with the path to the sub dir. #include "windows/midiIO.h" so I have to change the include on every platform....?????

    I'm a bit lost....
    ....any advise???

    i use on pro file the include params...

    !include( win.pri ) : error( Unable to find win config )
    !include( mac.pri ) : error( Unable to find mac config )
    !include( linux.pri ) : error( Unable to find ubuntu config )

    so if i append on file or moore by
    qmake -project

    i must past only 3 line.... :-) and i can recycle the pri file contains os libs e other.... include dir...

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Platform dependent source files: what is best?

    Quote Originally Posted by ucomesdag View Post
    I would prefer to do it without macros but how? Anyone?
    By a macro I meant a qmake macro, not an #ifndef section... There is nothing wrong with such macros if they are to ease your job.

Similar Threads

  1. Replies: 5
    Last Post: 22nd September 2006, 08:04
  2. [Win32/VC++ 8.0] Strange problems with qrc_*.cpp files
    By mloskot in forum Installation and Deployment
    Replies: 6
    Last Post: 6th March 2006, 10:28

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.