Qt-mac-free-3.3.4 on Mac OS X Tiger

Hint

If you don’t need specifically qt-mac-free-3.3.4 but any 3.3.x would do it, you might want to check out Trolltech’s recently published Version 3.3.5. If you ever wondered – like me – where you can still download the 3.3.x branch have a look at

ftp://ftp.trolltech.com/qt/source/

It seems that you can’t find any more download links for 3.3.x at Trolltech’s webpage.

Issue

When I tried to compile Qt for Mac 3.3.4 from source on Max OS X Tiger 10.4.2 with gcc-4.0.0 the compiler complained:

kernel/qaccessible_mac.cpp:189: error: non-local variable 
'<anonymous struct> text_bindings [][10]' uses anonymous 
type
make[2]: *** [.obj/release-shared/qaccessible_mac.o] Error 1
make[1]: *** [sub-src] Error 2
make: *** [init] Error 2

and

network/qsocketdevice_unix.cpp: In function `int qt_socket_accept(int, 
sockaddr*, int*)':
network/qsocketdevice_unix.cpp:47: error: invalid conversion from 'int*' to 
'socklen_t*'
network/qsocketdevice_unix.cpp:47: error:   initializing argument 3 of 'int 
accept(int, sockaddr*, socklen_t*)'
network/qsocketdevice_unix.cpp: In member function `QSocketDevice::Protocol 
QSocketDevice::getProtocol() const':
network/qsocketdevice_unix.cpp:132: error: invalid conversion from 'int*' 
to 'socklen_t*'
network/qsocketdevice_unix.cpp:132: error:   initializing argument 3 of 
'int getsockname(int, sockaddr*, socklen_t*)'
network/qsocketdevice_unix.cpp: In member function `int 
QSocketDevice::option(QSocketDevice::Option) const':
network/qsocketdevice_unix.cpp:324: error: invalid conversion from 'int*' 
to 'socklen_t*'
network/qsocketdevice_unix.cpp:324: error:   initializing argument 5 of 'int 
getsockopt(int, int, int, void*, socklen_t*)'
network/qsocketdevice_unix.cpp: In member function `virtual Q_LONG 
QSocketDevice::readBlock(char*, Q_ULONG)':
network/qsocketdevice_unix.cpp:784: error: invalid conversion from 'int*' 
to 'socklen_t*'
network/qsocketdevice_unix.cpp:784: error:   initializing argument 6 of 
'ssize_t recvfrom(int, void*, size_t, int, sockaddr*, socklen_t*)
network/qsocketdevice_unix.cpp: In member function `void 
QSocketDevice::fetchConnectionParameters()':
network/qsocketdevice_unix.cpp:1053: error: invalid conversion from 'int*' 
to 'socklen_t*'
network/qsocketdevice_unix.cpp:1053: error:   initializing argument 3 of 
'int getsockname(int, sockaddr*, socklen_t*)'
network/qsocketdevice_unix.cpp:1057: error: invalid conversion from 'int*' 
to 'socklen_t*'
network/qsocketdevice_unix.cpp:1057: error:   initializing argument 3 of 
'int getpeername(int, sockaddr*, socklen_t*)'
make[2]: *** [.obj/release-shared/qsocketdevice_unix.o] Error 1
make[1]: *** [sub-src] Error 2
make: *** [init] Error 2

Additionally with both compilers gcc 4.0 and gcc 3.3 linking an application against qt-mac-free-3.3.4 resulted in warning messages like the following, because Mac OS X Tiger comes with additional dynamic library handling functions which now conflict with qt:

/usr/bin/ld: warning multiple definitions of symbol _dlsym
/usr/lib/gcc/powerpc-apple-darwin8/4.0.0/../../../libpthread.dylib
(dyldAPIsInLibSystem.o) definition of _dlsym
/usr/local/lib/libqt-mt.dylib(dlfcn.o) definition of _dlsym
/usr/bin/ld: warning multiple definitions of symbol _dladdr
/usr/lib/gcc/powerpc-apple-darwin8/4.0.0/../../../libpthread.dylib
(dyldAPIsInLibSystem.o) definition of _dladdr
/usr/local/lib/libqt-mt.dylib(dlfcn.o) definition of _dladdr
/usr/bin/ld: warning multiple definitions of symbol _dlclose
/usr/lib/gcc/powerpc-apple-darwin8/4.0.0/../../../libpthread.dylib
(dyldAPIsInLibSystem.o) definition of _dlclose
/usr/local/lib/libqt-mt.dylib(dlfcn.o) definition of _dlclose
/usr/bin/ld: warning multiple definitions of symbol _dlerror
/usr/lib/gcc/powerpc-apple-darwin8/4.0.0/../../../libpthread.dylib
(dyldAPIsInLibSystem.o) definition of _dlerror
/usr/local/lib/libqt-mt.dylib(dlfcn.o) definition of _dlerror
/usr/bin/ld: warning multiple definitions of symbol _dlopen
/usr/lib/gcc/powerpc-apple-darwin8/4.0.0/../../../libpthread.dylib
(dyldAPIsInLibSystem.o) definition of _dlopen
/usr/local/lib/libqt-mt.dylib(dlfcn.o) definition of _dlopen
/usr/bin/ld: warning suggest use of -bind_at_load, as lazy binding 
may result in errors or different symbols being used
symbol _dladdr used from dynamic library /usr/lib/gcc/
powerpc-apple-darwin8/4.0.0/../../../libpthread.dylib
(dyldAPIsInLibSystem.o) not from earlier dynamic library 
libqt-mt.3.dylib(dlfcn.o)
symbol _dlclose used from dynamic library /usr/lib/gcc/
powerpc-apple-darwin8/4.0.0/../../../libpthread.dylib
(dyldAPIsInLibSystem.o) not from earlier dynamic library 
libqt-mt.3.dylib(dlfcn.o)
symbol _dlerror used from dynamic library /usr/lib/gcc/
powerpc-apple-darwin8/4.0.0/../../../libpthread.dylib
(dyldAPIsInLibSystem.o) not from earlier dynamic library 
libqt-mt.3.dylib(dlfcn.o)
symbol _dlopen used from dynamic library /usr/lib/gcc/
powerpc-apple-darwin8/4.0.0/../../../libpthread.dylib
(dyldAPIsInLibSystem.o) not from earlier dynamic library 
libqt-mt.3.dylib(dlfcn.o)
symbol _dlsym used from dynamic library /usr/lib/gcc/
powerpc-apple-darwin8/4.0.0/../../../libpthread.dylib
(dyldAPIsInLibSystem.o) not from earlier dynamic library 
libqt-mt.3.dylib(dlfcn.o)

Solution

Apply the following patch:

qt-mac-free-3.3.4-tiger.diff

Patch instructions

Extract sources and apply patch:

tar xjf qt-mac-free-3.3.4.tar.bz2
cd qt-mac-free-3.3.4
patch -p1 <../qt-mac-free-3.3.4-tiger.diff

Please make sure that the paths are adjusted to your system. Follow the official build instructions afterwards. After applying the little patch qt-mac-free-3.3.4 and applications linked to it should build fine with gcc 4.0 and gcc 3.3.

References

My patch is based on the following Articles: