Results 1 to 6 of 6

Thread: CMake and pthreads

  1. #1
    Join Date
    Jan 2006
    Location
    New Malden (near London)
    Posts
    32
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default CMake and pthreads

    Hi everyone,

    Does anyone know how to get CMake to configure properly without looking for a non-existent "pthreads" library? I'm using Qt 4.1.4 in packages on Fedora Core 5. My output reads as follows:

    Qt Code:
    1. -- Check for working C compiler: gcc
    2. -- Check for working C compiler: gcc -- works
    3. -- Check size of void*
    4. -- Check size of void* - done
    5. -- Check for working CXX compiler: c++
    6. -- Check for working CXX compiler: c++ -- works
    7. -- Looking for Q_WS_X11
    8. -- Looking for Q_WS_X11 - found
    9. -- Looking for Q_WS_MAC
    10. -- Looking for Q_WS_MAC - not found.
    11. -- Looking for Q_WS_WIN
    12. -- Looking for Q_WS_WIN - not found.
    13. -- Found Qt-Version 4.1.4
    14. -- Looking for XOpenDisplay in /usr/lib/libX11.so;/usr/lib/libXext.so
    15. -- Looking for XOpenDisplay in /usr/lib/libX11.so;/usr/lib/libXext.so - found
    16. -- Looking for gethostbyname
    17. -- Looking for gethostbyname - found
    18. -- Looking for connect
    19. -- Looking for connect - found
    20. -- Looking for remove
    21. -- Looking for remove - found
    22. -- Looking for shmat
    23. -- Looking for shmat - found
    24. -- Looking for IceConnectionNumber in ICE
    25. -- Looking for IceConnectionNumber in ICE - found
    26. -- Looking for pthread.h
    27. -- Looking for pthread.h - found
    28. -- Looking for pthread_create in pthreads
    29. -- Looking for pthread_create in pthreads - not found
    30. -- Looking for pthread_create in pthread
    31. -- Looking for pthread_create in pthread - found
    32. CMake Error: Attempt to add link library "-lpthread" to target "/usr/lib/libQtCore.so" which is not built by this project.
    33. CMake Error: Attempt to add link library "dl" to target "/usr/lib/libQtCore.so" which is not built by this project.
    34. CMake Error: Attempt to add link library "/usr/lib/libQtGui.so" to target "/usr/lib/libQtCore.so" which is not built by this project.
    35. CMake Error: Attempt to add link library "-lSM" to target "/usr/lib/libQtCore.so" which is not built by this project.
    36. CMake Error: Attempt to add link library "-lICE" to target "/usr/lib/libQtCore.so" which is not built by this project.
    37. CMake Error: Attempt to add link library "/usr/lib/libX11.so" to target "/usr/lib/libQtCore.so" which is not built by this project.
    38. CMake Error: Attempt to add link library "/usr/lib/libXext.so" to target "/usr/lib/libQtCore.so" which is not built by this project.
    39. CMake Error: Attempt to add link library "/usr/lib/libQtNetwork.so" to target "/usr/lib/libQtCore.so" which is not built by this project.
    40. CMake Error: Attempt to add link library "/usr/lib/libQtNetwork_debug.so" to target "/usr/lib/libQtCore.so" which is not built by this project.
    41. CMake Error: Attempt to add link library "/usr/lib/libQtXml.so" to target "/usr/lib/libQtCore.so" which is not built by this project.
    42. CMake Error: Attempt to add link library "/usr/lib/libQtXml_debug.so" to target "/usr/lib/libQtCore.so" which is not built by this project.
    43. -- Configuring done
    To copy to clipboard, switch view to plain text mode 

    And the relevant section in CMakeFiles/CMakeError.log reads as follows:

    Qt Code:
    1. Determining if the function pthread_create exists in the pthreads failed with the follow
    2. /usr/bin/gmake -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec
    3. gmake[1]: Entering directory `/home/indigojo/cvs/0.3/catkin-qtm/CMakeFiles/CMakeTmp'
    4. /usr/bin/cmake -E cmake_progress_report /home/indigojo/cvs/0.3/catkin-qtm/CMakeFiles/CMa
    5. Building C object CMakeFiles/cmTryCompileExec.dir/usr/share/cmake/Modules/CheckFunctionE
    6. /usr/bin/gcc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTryCompileExec.di
    7. Linking C executable cmTryCompileExec
    8. /usr/bin/cmake -P CMakeFiles/cmTryCompileExec.dir/cmake_clean_target.cmake
    9. /usr/bin/gcc -DCHECK_FUNCTION_EXISTS=pthread_create -fPIC "CMakeFiles/cmTryCompile
    10. /usr/bin/ld: cannot find -lpthreads
    11. collect2: ld returned 1 exit status
    12. gmake[1]: *** [cmTryCompileExec] Error 1
    13. gmake[1]: Leaving directory `/home/indigojo/cvs/0.3/catkin-qtm/CMakeFiles/CMakeTmp'
    14. gmake: *** [cmTryCompileExec/fast] Error 2
    To copy to clipboard, switch view to plain text mode 

    This is the first time I've actually written a CMakeLists.txt file and tried to run it, so I'm really quite new to the game, but I wanted to build an installable source bundle for my application. Is the solution to this to suppress the attempt to use the non-existent pthreads library, and if so how? If not, does anyone know what one does?

  2. #2
    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: CMake and pthreads

    AFAIK Qt requires pthreads, so it won't be possible to proceed without it.

  3. #3
    Join Date
    Jan 2006
    Location
    New Malden (near London)
    Posts
    32
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: CMake and pthreads

    Quote Originally Posted by wysota
    AFAIK Qt requires pthreads, so it won't be possible to proceed without it.
    I've been using QMake since the start, and the resulting binary has used -lpthread (no s on the end) and works fine.

  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: CMake and pthreads

    Quote Originally Posted by Matt Smith
    -- Looking for pthread_create in pthreads - not found
    -- Looking for pthread_create in pthread - found
    There's nothing wrong here. It didn't find the function it was looking for in libpthreads, so it used libpthread instead.

    Quote Originally Posted by Matt Smith
    CMake Error: Attempt to add link library "-lpthread" to target "/usr/lib/libQtCore.so" which is not built by this project.
    How does your TARGET_LINK_LIBRARIES line look like?
    Last edited by jacek; 3rd September 2006 at 21:24. Reason: typo

  5. #5
    Join Date
    Jan 2006
    Location
    New Malden (near London)
    Posts
    32
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: CMake and pthreads

    Quote Originally Posted by jacek
    There's nothing wrong here. It didn't find the function it was looking for in libpthreads, so it used libpthread instead.


    How does your TARGET_LINK_LIBRARIES line look like?
    Like this:

    Qt Code:
    1. TARGET_LINK_LIBRARIES(
    2. ${QT_LIBRARIES}
    3. ${QT_QTNETWORK_LIBRARIES}
    4. ${QT_QTXML_LIBRARIES}
    5. )
    To copy to clipboard, switch view to plain text mode 

  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: CMake and pthreads

    It should be:
    Qt Code:
    1. TARGET_LINK_LIBRARIES( program_name ${QT_LIBRARIES} )
    To copy to clipboard, switch view to plain text mode 
    and add
    Qt Code:
    1. SET( QT_USE_QTNETWORK TRUE )
    2. SET( QT_USE_QTXML TRUE )
    To copy to clipboard, switch view to plain text mode 
    before FIND_PACKAGE().

    http://wiki.qtcentre.org/index.php?t...pps_with_CMake

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

    Matt Smith (3rd September 2006)

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.