Results 1 to 10 of 10

Thread: how to correctly compile threads support?

  1. #1
    Join Date
    Jun 2006
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question how to correctly compile threads support?

    Hi all, I've just recently downloaded and attempted to compile the opensource version of qt4.1.3.
    The program that I'm trying to install which required qt says it must have thread support, in other words the library libqt-mt.
    I'm using SuSe 10.1, which has qt3 installed from an rpm, and there already exists the file libqt-mt.so.3 in my /usr/lib directory. BUT if I write a hello world program and try to link to it using -lqt-mt, ld gives me the error
    ld: skipping incompatible /usr/lib/libqt-mt.so when searching for -lqt-mt
    ld: cannot find -lqt-mt
    collect2: ld returned 1 exit status
    so there must be something either wrong with the library, or maybe I have to have a libqt-mt.a, or something.

    So here I am, trying to install the latest qt4, hoping that it will fix the problem. qt4 compiles just fine, with no errors, when I do this:
    ./configure
    gmake
    gmake install

    Now, if I may quote from http://doc.trolltech.com/3.3/threads.html, TrollTech's installation guide for enabling multithreading in qt3,

    On Mac OS X and Unix, thread support is enabled by adding the -thread option when running the configure script. On Unix platforms where multithreaded programs must be linked in special ways, such as with a special libc, installation will create a separate library, libqt-mt and hence threaded programs must be linked against this library (with -lqt-mt) rather than the standard Qt library.

    On both platforms, you should compile with the macro QT_THREAD_SUPPORT defined (e.g. compile with -DQT_THREAD_SUPPORT).

    However, when I execute the command
    ./configure -thread
    I get as a response
    -thread: invalid command-line switch
    I have also tried running
    ./configure
    gmake -DQT_THREAD_SUPPORT
    gmake install
    but this still does not result in the creation of a libqt-mt.a.

    The guide for installing qt4, http://doc.trolltech.com/4.1/install-x11.html, makes no mention of threads at all--so I'm guessing they are already included--so then why is there no libqt-mt created? Perhaps that program I'm trying to install (Kompose) must have qt3 not qt4?

    I would greatly appreciate any help you can give me!

  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: how to correctly compile threads support?

    Quote Originally Posted by srhlefty
    The program that I'm trying to install which required qt says it must have thread support, in other words the library libqt-mt.
    Most likely that program requires Qt3 and it won't run with Qt4.

    Quote Originally Posted by srhlefty
    ld: skipping incompatible /usr/lib/libqt-mt.so when searching for -lqt-mt
    ld: cannot find -lqt-mt
    For some reason it doesn't like that library. Do you have a 64-bit processor?

    Quote Originally Posted by srhlefty
    Now, if I may quote from TrollTech's installation guide for enabling multithreading in qt3
    ...
    However, when I execute the command
    ...
    but this still does not result in the creation of a libqt-mt.a.
    Qt4 libraries are always multithreaded, but Qt4 is not backward-compatible with Qt3, so you can't use it instead of Qt3. Instructions from Qt3 docs won't work with Qt4 either.

  3. #3
    Join Date
    Jun 2006
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to correctly compile threads support?

    Thanks for the info jacek!
    For some reason it doesn't like that library. Do you have a 64-bit processor?
    You guessed it! :D
    AMD dual core 64-bit, no less. What effect is this going to have on installing a different version of qt? This incompatibility trend seems to continually haunt me...maybe I should have installed SuSe for 32 bit instead..but that's a project for another day :)

    I assume this means I should be trying to compile qt3 instead, right? But maybe that won't work either because most of my libraries installed from rpm are 64 bit.

    I tried compiling this morning qt-x11-free-3.3.6, with the -thread option in configure, and it configured ok but upon a gmake I received compiler errors of the form:
    ./qcstring.o: In function `qChecksum(char const*, unsigned int)':
    qcstring.cpp:(.text+0x605): undefined reference to `qt_global_mutexpool'
    qcstring.cpp:(.text+0x61a): undefined reference to `QMutexPool::get(void*)'
    qcstring.cpp:(.text+0x62a): undefined reference to `QMutex::lock()'
    qcstring.cpp:(.text+0x640): undefined reference to `QMutex::unlock()'
    repeated over and over again in a bunch of different source files. These seem to indicate that although configure worked, there's some sort of missing threads library it can't seem to link to, so all the functions related to multithreading aren't linking properly.

    Any ideas here, or am I just beating a dead horse?

  4. #4
    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: how to correctly compile threads support?

    Quote Originally Posted by srhlefty
    AMD dual core 64-bit, no less.
    You must be very lucky.

    Quote Originally Posted by srhlefty
    I assume this means I should be trying to compile qt3 instead, right?
    In my distribution (PLD Linux) there is a package with Qt 3.3.6 for AMD 64, so it should be available in SuSE too.

    Quote Originally Posted by srhlefty
    I tried compiling this morning qt-x11-free-3.3.6, with the -thread option in configure, and it configured ok but upon a gmake I received compiler errors of the form:
    Could you try to find the first error message?

    Quote Originally Posted by srhlefty
    These seem to indicate that although configure worked, there's some sort of missing threads library it can't seem to link to, so all the functions related to multithreading aren't linking properly.
    You're right, probably you are missing a 64-bit version of some library that Qt depends on.

  5. #5
    Join Date
    Jun 2006
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to correctly compile threads support?

    In my distribution (PLD Linux) there is a package with Qt 3.3.6 for AMD 64, so it should be available in SuSE too.
    Here are the qt packages on my install DVD:
    qt3-32bit-3.3.5-58.x86_64.rpm
    qt3-3.3.5-58.x86_64.rpm
    qt3-devel-32bit-3.3.5-58.x86_64.rpm
    qt3-devel-3.3.5-58.x86_64.rpm
    qt3-devel-tools-3.3.5-58.x86_64.rpm
    qt3-examples-3.3.5-58.x86_64.rpm
    qt3-man-3.3.5-58.x86_64.rpm
    qt3-mysql-3.3.5-58.x86_64.rpm
    qt3-postgresql-3.3.5-58.x86_64.rpm
    qt3-sqlite-3.3.5-58.x86_64.rpm
    qt3-unixODBC-3.3.5-58.x86_64.rpm
    I opened up KPackage, and it appears that the ones that I have installed are
    qt3-devel-32bit-3.3.5-58.x86_64.rpm, and
    qt3-devel-3.3.5-58.x86_64.rpm
    Could it be that I need to install qt3-3.3.5-58.x86_64.rpm? If so, how do I make sure it installs it with the -thread option--I was under the impression that rpm's are already compiled, so if this particular build was not built with that option, it wouldn't matter if I had the correct rpm or not!

    Could you try to find the first error message?
    Actually, that is the first error message. Here's the full output:
    gmake[1]: Entering directory `/usr/local/qt3'
    cd qmake && gmake
    gmake[2]: Entering directory `/usr/local/qt3/qmake'
    gmake[2]: `qmake' is up to date.
    gmake[2]: Leaving directory `/usr/local/qt3/qmake'
    cd src/moc && gmake
    gmake[2]: Entering directory `/usr/local/qt3/src/moc'
    test -d ../../bin/ || mkdir -p ../../bin/
    g++ -o ../../bin/moc ./qbuffer.o ./qptrcollection.o ./qcstring.o ./qdatastream.o ./qdatetime.o ./qfile.o ./qdir.o ./qfileinfo.o ./qgarray.o ./qgdict.o ./qglist.o ./qglobal.o ./qgvector.o ./qiodevice.o ./qregexp.o ./qstring.o ./qlocale.o ./qunicodetables.o ./qstringlist.o ./qtextstream.o ./qbitarray.o ./qmap.o ./qgcache.o ./qtextcodec.o ./qutfcodec.o ./moc_yacc.o ./qfile_unix.o ./qdir_unix.o ./qfileinfo_unix.o
    ./qcstring.o: In function `qChecksum(char const*, unsigned int)':
    qcstring.cpp:(.text+0x605): undefined reference to `qt_global_mutexpool'
    qcstring.cpp:(.text+0x61a): undefined reference to `QMutexPool::get(void*)'
    qcstring.cpp:(.text+0x62a): undefined reference to `QMutex::lock()'
    qcstring.cpp:(.text+0x640): undefined reference to `QMutex::unlock()'
    ./qgarray.o: In function `QGArray::sort(unsigned int)':
    qgarray.cpp:(.text+0xdb3): undefined reference to `qt_global_mutexpool'
    qgarray.cpp:(.text+0xdc5): undefined reference to `QMutexPool::get(void*)'
    qgarray.cpp:(.text+0xdd5): undefined reference to `QMutex::lock()'
    qgarray.cpp:(.text+0xe4b): undefined reference to `QMutex::unlock()'
    ./qgarray.o: In function `QGArray::bsearch(char const*, unsigned int) const':
    qgarray.cpp:(.text+0xe97): undefined reference to `qt_global_mutexpool'
    qgarray.cpp:(.text+0xeaf): undefined reference to `QMutexPool::get(void*)'
    qgarray.cpp:(.text+0xec5): undefined reference to `QMutex::lock()'
    qgarray.cpp:(.text+0xf7a): undefined reference to `QMutex::unlock()'
    qgarray.cpp:(.text+0xfaf): undefined reference to `QMutex::unlock()'
    ./qgarray.o: In function `QGArray::sort(unsigned int)':
    qgarray.cpp:(.text+0xe17): undefined reference to `QMutex::unlock()'
    ./qgvector.o: In function `QGVector::sort()':
    qgvector.cpp:(.text+0xa2b): undefined reference to `qt_global_mutexpool'
    qgvector.cpp:(.text+0xa3c): undefined reference to `QMutexPool::get(void*)'
    qgvector.cpp:(.text+0xa4c): undefined reference to `QMutex::lock()'
    qgvector.cpp:(.text+0xac5): undefined reference to `QMutex::unlock()'
    qgvector.cpp:(.text+0xa8e): undefined reference to `QMutex::unlock()'
    ./qregexp.o: In function `regexpEngine(QRegExpEngine*&, QString const&, bool, bool)':
    qregexp.cpp:(.text+0x7a29): undefined reference to `QThreadInstance::current()'
    qregexp.cpp:(.text+0x7a3e): undefined reference to `QThreadStorageData::get() const'
    qregexp.cpp:(.text+0x7b3b): undefined reference to `QThreadStorageData::QThreadStorageData(void (*)(void*))'
    qregexp.cpp:(.text+0x7b9e): undefined reference to `QThreadStorageData::set(void*)'
    qregexp.cpp:(.text+0x7be8): undefined reference to `QThreadStorageData::set(void*)'
    ./qregexp.o: In function `__tcf_0':
    qregexp.cpp:(.text+0x206): undefined reference to `QThreadStorageData::~QThreadStorageData()'
    ./qtextcodec.o: In function `QTextCodec::deleteAllCodecs()':
    qtextcodec.cpp:(.text+0x9b7): undefined reference to `qt_global_mutexpool'
    qtextcodec.cpp:(.text+0x9c9): undefined reference to `QMutexPool::get(void*)'
    qtextcodec.cpp:(.text+0x9d9): undefined reference to `QMutex::lock()'
    qtextcodec.cpp:(.text+0xabd): undefined reference to `QMutex::unlock()'
    ./qtextcodec.o: In function `QTextCodec::QTextCodec()':
    qtextcodec.cpp:(.text+0x1964): undefined reference to `qt_global_mutexpool'
    qtextcodec.cpp:(.text+0x1975): undefined reference to `QMutexPool::get(void*)'
    qtextcodec.cpp:(.text+0x1985): undefined reference to `QMutex::lock()'
    qtextcodec.cpp:(.text+0x19a0): undefined reference to `QMutex::unlock()'
    qtextcodec.cpp:(.text+0x19c1): undefined reference to `QMutex::unlock()'
    ./qtextcodec.o: In function `QTextCodec::QTextCodec()':
    qtextcodec.cpp:(.text+0x21a4): undefined reference to `qt_global_mutexpool'
    qtextcodec.cpp:(.text+0x21b5): undefined reference to `QMutexPool::get(void*)'
    qtextcodec.cpp:(.text+0x21c5): undefined reference to `QMutex::lock()'
    qtextcodec.cpp:(.text+0x21e0): undefined reference to `QMutex::unlock()'
    qtextcodec.cpp:(.text+0x2201): undefined reference to `QMutex::unlock()'
    ./qtextcodec.o: In function `QTextCodec::codecForContent(char const*, int)':
    qtextcodec.cpp:(.text+0x2231): undefined reference to `qt_global_mutexpool'
    qtextcodec.cpp:(.text+0x2246): undefined reference to `QMutexPool::get(void*)'
    qtextcodec.cpp:(.text+0x2256): undefined reference to `QMutex::lock()'
    qtextcodec.cpp:(.text+0x2271): undefined reference to `QMutex::unlock()'
    qtextcodec.cpp:(.text+0x231a): undefined reference to `QMutex::unlock()'
    ./qtextcodec.o: In function `QTextCodec::codecForName(char const*, int)':
    qtextcodec.cpp:(.text+0x2408): undefined reference to `qt_global_mutexpool'
    qtextcodec.cpp:(.text+0x2419): undefined reference to `QMutexPool::get(void*)'
    qtextcodec.cpp:(.text+0x2429): undefined reference to `QMutex::lock()'
    qtextcodec.cpp:(.text+0x2444): undefined reference to `QMutex::unlock()'
    qtextcodec.cpp:(.text+0x2466): undefined reference to `QMutex::unlock()'
    ./qtextcodec.o: In function `QTextCodec::codecForLocale()':
    qtextcodec.cpp:(.text+0x254d): undefined reference to `qt_global_mutexpool'
    qtextcodec.cpp:(.text+0x255e): undefined reference to `QMutexPool::get(void*)'
    qtextcodec.cpp:(.text+0x256e): undefined reference to `QMutex::lock()'
    qtextcodec.cpp:(.text+0x2585): undefined reference to `QMutex::unlock()'
    qtextcodec.cpp:(.text+0x25ae): undefined reference to `QMutex::unlock()'
    ./qtextcodec.o: In function `QTextCodec::codecForMib(int)':
    qtextcodec.cpp:(.text+0x26e0): undefined reference to `qt_global_mutexpool'
    qtextcodec.cpp:(.text+0x26f1): undefined reference to `QMutexPool::get(void*)'
    qtextcodec.cpp:(.text+0x2701): undefined reference to `QMutex::lock()'
    qtextcodec.cpp:(.text+0x271c): undefined reference to `QMutex::unlock()'
    qtextcodec.cpp:(.text+0x2741): undefined reference to `QMutex::unlock()'
    ./qtextcodec.o: In function `QTextCodec::codecForIndex(int)':
    qtextcodec.cpp:(.text+0x2765): undefined reference to `qt_global_mutexpool'
    qtextcodec.cpp:(.text+0x2776): undefined reference to `QMutexPool::get(void*)'
    qtextcodec.cpp:(.text+0x2786): undefined reference to `QMutex::lock()'
    qtextcodec.cpp:(.text+0x279d): undefined reference to `QMutex::unlock()'
    qtextcodec.cpp:(.text+0x27f6): undefined reference to `QMutex::unlock()'
    ./qtextcodec.o: In function `QTextCodec::deleteAllCodecs()':
    qtextcodec.cpp:(.text+0xa88): undefined reference to `QMutex::unlock()'
    ./qdir_unix.o: In function `QDir::drives()':
    qdir_unix.cpp:(.text+0x29b): undefined reference to `qt_global_mutexpool'
    qdir_unix.cpp:(.text+0x2ac): undefined reference to `QMutexPool::get(void*)'
    qdir_unix.cpp:(.text+0x2bc): undefined reference to `QMutex::lock()'
    qdir_unix.cpp:(.text+0x2d3): undefined reference to `QMutex::unlock()'
    qdir_unix.cpp:(.text+0x386): undefined reference to `QMutex::unlock()'
    collect2: ld returned 1 exit status
    gmake[2]: *** [../../bin/moc] Error 1
    gmake[2]: Leaving directory `/usr/local/qt3/src/moc'
    gmake[1]: *** [src-moc] Error 2
    gmake[1]: Leaving directory `/usr/local/qt3'
    gmake: *** [init] Error 2

  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: how to correctly compile threads support?

    Quote Originally Posted by srhlefty
    it appears that the ones that I have installed are
    qt3-devel-32bit-3.3.5-58.x86_64.rpm, and
    qt3-devel-3.3.5-58.x86_64.rpm
    Then probably you also have all required libraries installed too.

    Quote Originally Posted by srhlefty
    Could it be that I need to install qt3-3.3.5-58.x86_64.rpm?
    Yes, but if you have a corresponding *-devel package, it should be already installed on your system. You can check it using rpm:
    $ rpm -qi qt3-3.3.5-58
    To see if you have a qt-mt library run:
    $ rpm -ql qt3-3.3.5-58 | grep qt-mt
    If for some reason you don't have qt3 package installed, you can see if it contains the qt-mt library using:
    $ rpm -qpl qt3-3.3.5-58.x86_64.rpm | grep qt-mt
    Since you have both 32-bit and 64-bit Qt installed, make sure that QTDIR environment variable is set correctly.

    Quote Originally Posted by srhlefty
    Actually, that is the first error message.
    This might mean that the problem lies in some macro definitions or the configuration.

  7. The following user says thank you to jacek for this useful post:

    srhlefty (24th June 2006)

  8. #7
    Join Date
    Jun 2006
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Thumbs up Re: how to correctly compile threads support?

    Both main qt3 rpm's are already installed.

    To see if you have a qt-mt library run:
    $ rpm -ql qt3-3.3.5-58 | grep qt-mt
    This returns
    /usr/lib/qt3/lib64/libqt-mt.so.3
    /usr/lib/qt3/lib64/libqt-mt.so.3.3
    /usr/lib/qt3/lib64/libqt-mt.so.3.3.5
    /usr/lib64/libqt-mt.so.3
    These are the same files returned by
    rpm -qpl qt3-3.3.5-58.x86_64.rpm | grep qt-mt
    My QTDIR is set to /usr/lib/qt3

    I know this seems a little like cutting my losses and moving on, but I just found an rpm of the program I wanted to install, and after finding a few other rpm's to satisfy dependencies it installed ok. So the binary qt libraries must be working ok with the binary program--it's just that I can't compile the program from source.
    So I don't think I'm going to fiddle with trying to get qt to compile correctly any more, but if you have more ideas I'll certainly give them a try.
    Thank you so much for your patience and advice, it gave me some insights as to how all this stuff is put together.

  9. #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: how to correctly compile threads support?

    Quote Originally Posted by srhlefty
    My QTDIR is set to /usr/lib/qt3
    How about QMAKESPEC variable? Is it set? Also check where $QTDIR/mkspecs/default link points to.

    If you are going to compile Qt again, try running:
    Qt Code:
    1. export QMAKESPEC=linux-g++-64
    To copy to clipboard, switch view to plain text mode 
    before the configure utility.
    Last edited by jacek; 24th June 2006 at 22:40.

  10. #9
    Join Date
    Jun 2006
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to correctly compile threads support?

    QMAKESPEC wasn't set, so I set it like you suggested, then ran configure again (after doing a gmake confclean of course). I checked where /usr/local/qt3/mkspecs/default points to, and it points to the linux-g++-64 folder. I'm guessing that means it doesn't matter what QMAKESPEC was set to anyway, since that's my arch?

    Gmake'ing gave the same set of errors.

  11. #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: how to correctly compile threads support?

    Then maybe configure utility has some problems with detecting that your system is 64-bit?

Similar Threads

  1. Static compile with jpg support
    By ksqt in forum Newbie
    Replies: 18
    Last Post: 11th May 2007, 05:43

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.