Results 1 to 16 of 16

Thread: Qt4 MacOSX UB Xcode and a static Qt build?

  1. #1
    Join Date
    Mar 2007
    Posts
    17
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Exclamation Qt4 MacOSX UB Xcode and a static Qt build?

    As the forum says: I am a Qt newbie and not a Mac developer whiz (most of my development experience is Amiga/MSDOS/Windows+Java), so please bear with my naive ignorance.

    Alright, I have an Intel mac with MacOS 10.4.9 and Xcode 2.4.1 installed. I've just finished installing Qt and making the static Qt so that the project app can be a consolidated unit. All that I have for this project is the source code as provided by the developer who wrote this for Windows - I am attempting to port it to Mac (gulp).

    I ran 'qmake -spec macx-xcode (project).pro' to get a .pro for the source. The resulting .xcodeproject is opened with Xcode but there is no static Qt lib added - only the frameworks. Do I need to specify a set of the Qt static libs - in addition to or instead of the Qt frameworks?

    Also, there are warnings and errors - the errors are ALL about OpenGL type 'const GLuint*'. OpenGL is specified in the .pro file (QT += opengl) and the OpenGL frameworks are included: OpenGL and QtOpenGL.

    It seems that there is diminishing information concerning Mac Qt builds - especially for how to accomplish a static app from Xcode. Would the built examples help at all (from 'sudo make install')? I am not someone who likes command line build for development - NetBeans, SunOne, VS, Xcode, CodeWarrior - give me an IDE not a stack of commands and configuration files.

    Thank you very much,

    Robert

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt4 MacOSX UB Xcode and a static Qt build?

    Quote Originally Posted by kuroyume0161 View Post
    Also, there are warnings and errors - the errors are ALL about OpenGL type 'const GLuint*'. OpenGL is specified in the .pro file (QT += opengl) and the OpenGL frameworks are included: OpenGL and QtOpenGL.
    Do you have the OpenGL library and its headers installed on your system?

  3. #3
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt4 MacOSX UB Xcode and a static Qt build?

    Quote Originally Posted by kuroyume0161 View Post
    Alright, I have an Intel mac with MacOS 10.4.9 and Xcode 2.4.1 installed. I've just finished installing Qt and making the static Qt so that the project app can be a consolidated unit. All that I have for this project is the source code as provided by the developer who wrote this for Windows - I am attempting to port it to Mac (gulp).
    You can find some helpful information on the Assistant pages "Deploying an Application on Qt/Mac" and "Qt/Mac-Specific Issues".

    I have lots more advice for building statically linked Mac applications, but I only know how to do it from the command line. So I'm afraid I can't help you there.

  4. #4
    Join Date
    Mar 2007
    Posts
    17
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Qt4 MacOSX UB Xcode and a static Qt build?

    Quote Originally Posted by jacek View Post
    Do you have the OpenGL library and its headers installed on your system?
    How do I know? I have Xcode 2.4.1 which contains all of the frameworks/includes/libs for building Mac applications.

    This is difficult since the Wiki-Build Systems here for "Building static Qt on Mac" is empty.

  5. #5
    Join Date
    Mar 2007
    Posts
    17
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Qt4 MacOSX UB Xcode and a static Qt build?

    Quote Originally Posted by Brandybuck View Post
    You can find some helpful information on the Assistant pages "Deploying an Application on Qt/Mac" and "Qt/Mac-Specific Issues".

    I have lots more advice for building statically linked Mac applications, but I only know how to do it from the command line. So I'm afraid I can't help you there.
    You can go ahead and provide the advice as it seems that building with Xcode is not recommended (nor is it described in any detail).

    For instance, here is my .pro file. Whenever I run 'qmake -makefile -o makefile my.pro', it produces an xcode project - for the command line I would think that I want a makefile for make, correct?

    ################################################## ####################
    # Automatically generated by qmake (2.01a) Fri Mar 16 01:30:51 2007
    ################################################## ####################

    TEMPLATE = app
    DESTDIR = /Users/RobertTempleton/Data/IvyGenerator/IvyGenerator/bin
    TARGET = ivygenerator
    DEPENDPATH += .
    INCLUDEPATH += .
    QT += opengl
    # QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk
    CONFIG += qt release static x86 ppc
    QMAKE_LIBS_QT =
    QMAKE_LIBS_QT_THREAD =
    LIBS += $(QTDIR)/lib/libqtcore.a $(QTDIR)/lib/libqtgui.a $(QTDIR)/lib/libqtopengl.a -lz -framework Carbon


    # Input
    HEADERS += BasicMesh.h \
    Camera.h \
    Common.h \
    GLee.h \
    Ivy.h \
    ivygenerator.h \
    OBJLoader.h \
    OBJWriter.h \
    RenderWidget.h \
    SetupWidget.h \
    Vector2d.h \
    Vector3d.h
    SOURCES += BasicMesh.cpp \
    Camera.cpp \
    Common.cpp \
    GLee.c \
    Ivy.cpp \
    ivygenerator.cpp \
    main.cpp \
    OBJLoader.cpp \
    OBJWriter.cpp \
    RenderWidget.cpp \
    SetupWidget.cpp


    Just for clarity's sake, I did make a universal static release build of the Qt libs.

    Thanks, Robert

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt4 MacOSX UB Xcode and a static Qt build?

    Quote Originally Posted by kuroyume0161 View Post
    How do I know?
    Sorry, by I don't have a slightest idea. I would look for OpenGL headers, for example gl.h.

    Quote Originally Posted by kuroyume0161 View Post
    "Building static Qt on Mac" is empty.
    It looks like you will have to fill it.

  7. #7
    Join Date
    Mar 2007
    Posts
    17
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Qt4 MacOSX UB Xcode and a static Qt build?

    Quote Originally Posted by jacek View Post
    Sorry, by I don't have a slightest idea. I would look for OpenGL headers, for example gl.h.
    The only place that I've found the OpenGL headers/libs is under X11 - I suspect that these are the ones that need to be considered somehow. How, I have no clue. I would have figured that the QT+=opengl would have considered this for MacOS development - but guess not.

    It looks like you will have to fill it.


    Some more fiddling to do...

    Thanks,
    Robert

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt4 MacOSX UB Xcode and a static Qt build?

    Quote Originally Posted by kuroyume0161 View Post
    I would have figured that the QT+=opengl would have considered this for MacOS development - but guess not.
    This would work only if those headers were in a standard place. According to $QTDIR/mkspecs/macx-xcode/qmake.conf, qmake will look for them in /System/Library/Frameworks/OpenGL.framework/Headers and /System/Library/Frameworks/AGL.framework/Headers.

  9. #9
    Join Date
    Mar 2007
    Posts
    17
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Qt4 MacOSX UB Xcode and a static Qt build?

    Quote Originally Posted by jacek View Post
    This would work only if those headers were in a standard place. According to $QTDIR/mkspecs/macx-xcode/qmake.conf, qmake will look for them in /System/Library/Frameworks/OpenGL.framework/Headers and /System/Library/Frameworks/AGL.framework/Headers.
    Hmmm - and there they are: gl.h, glext.h, glu.h. And these will also be available in /Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/... for Xcode.

    I've not been able to get this to work with either make or XCode (note that to make a makefile and not an Xcode project, needed to do 'qmake -spec macx-g++' instead of 'qmake -spec macx-xcode' - so now I have both at my disposal). The same errors on const GLuint* which doesn't make sense.

    Now, to fill this in a little. This project does use GLee - I am not using the library just the source. Could it be GLee creating difficulties? Though I suspect that glDeleteTextures() is an OpenGL, not a GLee, call.

    Thanks,
    Robert

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt4 MacOSX UB Xcode and a static Qt build?

    Quote Originally Posted by kuroyume0161 View Post
    The same errors on const GLuint* which doesn't make sense.
    Could you post the exact error message (the first one)?

  11. #11
    Join Date
    Mar 2007
    Posts
    17
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Qt4 MacOSX UB Xcode and a static Qt build?

    Quote Originally Posted by jacek View Post
    Could you post the exact error message (the first one)?
    I don't need to!

    Hmmm, lemme see. The typedef is to GLuint which one would suppose to be an unsigned int, right? And obviously it worked for the originator in Windows. But, noooo, for Apple it is typedef'd as an unsigned long - and that is all it took to generate these errors!

    Sweet mama of yeshua! No problems with OpenGL or anything else - it's simply a matter of casting the bastard values.

    Still some errors to work out - like QFrame not being a class or namespace. At least it's now down to Qt related stuff.

    I'll be back if things like that can't be resolved.

    Thanks!
    Robert

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt4 MacOSX UB Xcode and a static Qt build?

    Quote Originally Posted by kuroyume0161 View Post
    it's simply a matter of casting the bastard values
    It depends on whether you are casting unsigned int to GLuint or vice versa. What if sizeof(unsigned long) > sizeof(unsigned int)? I haven't seen your code, but maybe using GLuint instead of casting will be a safer solution?

  13. #13
    Join Date
    Mar 2007
    Posts
    17
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Qt4 MacOSX UB Xcode and a static Qt build?

    Quote Originally Posted by jacek View Post
    It depends on whether you are casting unsigned int to GLuint or vice versa. What if sizeof(unsigned long) > sizeof(unsigned int)? I haven't seen your code, but maybe using GLuint instead of casting will be a safer solution?
    I'm trying not to change *any* of his code - this is not my application, I'm just porting it to Mac since he cannot.

    Should not cause any problems as the variable texobj is unsigned int and the cast is to (const GLuint*)&m->texobj. But if it does, I might be able to get away with changing the variable to unsigned long.

    Now my problem is this line:

    splitter->setFrameShadow(QFrame::Shadow::Sunken);

    is generating a compiler error:

    error: 'class QFrame::Shadow' is not a class or namespace

    (?) It can't possibly be because QtGui is not included (it is both as static lib and #include <QtGui>) as just above it is a mention of QWidget and QSplitter - no errors on them. The compiler doesn't appear to like that QFrame is being used in a static mode to get to these enums. Any ideas?

    Thanks,
    Robert

  14. #14
    Join Date
    Mar 2007
    Posts
    17
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Qt4 MacOSX UB Xcode and a static Qt build?

    My thinking here on the QFrame::Shadow and QFrame::Shape errors is that gcc might not be understandin' the concept of something like this:

    Qt Code:
    1. class QFrame
    2. {
    3. enum Shape
    4. {
    5. ...
    6. Panel = 0x0002,
    7. ...
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 

    I guess that Visual Studio has no problems with the construct causing the error, but Xcode don't like it.

    Should I just hard code the value (yuck) or is there another way to dereference the enum within the class (something that I'm not too familiar with - my enums are always global).

    Thanks,
    Robert

  15. #15
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt4 MacOSX UB Xcode and a static Qt build?

    Quote Originally Posted by kuroyume0161 View Post
    You can go ahead and provide the advice as it seems that building with Xcode is not recommended (nor is it described in any detail).
    Okay. The main problem is that the Mac always wants to link with the frameworks if they are present. The Trolltech "solution" is to move the frameworks out of the way, so that the static libs will be used. I find this annoying for a variety of reasons. What I do instead is to have two separate Qt installations, one with shared frameworks for development, and one with static libs for deployment. Most the time I used the regular framework version, but switch to the other when it's time to bundle stuff up for a release.

    Assuming you have a shared framework version installed and working, the next thing to do is to build a static version of Qt. You don't want to build everything though, as you'll use up dozens of gigabytes. You already have Designer, Assistant, etc. in your shared version, so there's no need to build them again. All you want to do now is to build the static libraries and the basic build tools (qmake, moc, uic, rcc).

    Download the sources (qt-mac-opensource-src-4.2.3.tar.gz, for this example) and have them in your home directory. Open up a Terminal window. Then extract them to the installation destination with the following commands. I'm using standard directory locations, but you can vary to taste:

    sudo mkdir -p /usr/local/Trolltech
    cd /usr/local/Trolltech
    sudo tar xvzf ~/qt-mac-opensource-src-4.2.3.tar.gz
    sudo mv qt-mac-opensource-src-4.2.3 Qt-4.2.3-static
    cd Qt-4.2.3-static

    Now you need to configure and build for static linking. You may need more configure options that I have used:

    sudo ./configure -static -prefix /usr/local/Trolltech/Qt-4.2.3-static -universal -sdk /Developer/SDKs/MacOSX10.4u.sdk
    sudo make sub-src

    Finally, to easily switch to the static environment, create a short shell script in your home directory. Use a text editor and create a "qtstatic.sh" file with the following:

    #!/bin/sh
    QMAKESPEC=macx-g++
    QTDIR=/usr/local/Trolltech/Qt-4.2.3-static
    PATH=$QTDIR/bin:$PATH
    export QMAKESPEC QTDIR PATH

    Now you're ready to build your app. You have to do this from a Terminal. Replace "src" with the appropriate application source directory:

    cd src
    . ~/qtstatic.sh
    qmake application.pro
    make

    Statically linked applications need to be stripped, especially those gargantuan universal apps. Replace both "myapplication" with the appropriate app name:

    strip myapplication.app/Contents/MacOS/myapplication

    To run the application bundle from the command line (should you wish), use the "open" command:

    open myapplication.app

    I hope this helps. If anyone is ambitious, feel free to clean up these notes and put them on the wiki.

  16. #16
    Join Date
    Mar 2007
    Posts
    17
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Qt4 MacOSX UB Xcode and a static Qt build?

    Thanks for the info, Brandybuck!

    I've already successfully built Qt as a static release universal lib. Since I'm on an Intel Mac, it went smoothly (if not lengthy including the examples).

    Thankfully, these compiler errors forced me to dig deeper into qmake and the .pro file so that setup was more suitable for the desired result. It turns out that all of the errors are related to the difference between what Windows and MacOS will allow for certain areas. Once I cast the 'const GLuint*', turned an int into a more proper GLint, and worked around the QFrame::Shadow:: enum stuff the build was successful - in Xcode! And the app runs and works.

    A couple of notes about Xcode and the static Qt lib (still waiting for confirmation on the app working on other systems including PPC, so take with grain of salt and parsley for the time being):

    0. I used Xcode 2.4.1 and Qt 4.2.3 on MacOS 10.4.9, Intel Mac

    1. Remove the Qt frameworks from the xcode project outright and Replace them with the Qt static libs.

    2. In the Target Build settings (target->Get Info), remove the header paths to the Qt frameworks and Replace with the general Qt header paths (qt/include - recursive works here).

    3. In the same place, change -DQT_SHARED with -DQT_STATIC for both C and C++.

    4. Make sure that Library Search Paths includes, for instance, "/Developer/qt/lib". Might not be necessary, but ensures that they are found even though included in the project directly.

    The app is 15.5MB (as compared to the 3.2MB Windows app with static Qt lib) so I'm optimistic that it didn't do the Qt frameworks. We'll see whether this is the case from some volunteers.

    Thank you all very much and I'll be back if success spills to failure.

    Robert

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.