Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

cmake in linux ubuntu



  • Hi,
    this is my code now:

      message (STATUS "Defaulting to Linux build environment.")
      set(CMAKE_INCLUDE_CURRENT_DIR ON)
    
    file(WRITE "${librosco} ${CMAKE_STATIC_LIBRARY_PREFIX}LIBROSCO ${CMAKE_STATIC_LIBRARY_SUFFIX}.dll" )
      find_file( "${librosco}"
        NAMES ${CMAKE_SHARED_LIBRARY_PREFIX}LIBROSCO ${CMAKE_SHARED_LIBRARY_SUFFIX}.dll
      HINTS "${CMAKE_SOURCE_DIR}/lib"
      NO_DEFAULT_PATH
      NO_CMAKE_PATH
      NO_CMAKE_SYSTEM_PATH
      NO_Package_ROOT_PATH )
    
      # check if we found the library
       message(STATUS "LIB_ROSCO: [${LIBROSCO}]")
    
      target_link_libraries (${PNAME} ${LIBROSCO} Qt5::Widgets)
    

    cmake is running without failure but librosco is not found

    
    Defaulting to Linux build environment.
    LIB_ROSCO: []
    Configuring done
    Generating done
    Das CMake-Projekt wurde erfolgreich ausgewertet.
    

    what can i do next?


  • Lifetime Qt Champion

    Hi,

    .dll files are only for Windows. Do you have a Linux build of that library ?



  • Hi SGaist,
    thank you, at first glance this was easy.Now I have a librosco.so, librosco.so.2 and librosco.so.2.0.0 in my source folder and /source/lib they are set to rwx/rwx/rw but files are not found.



  • librosco is built and installed with cmake so it is super easy.
    After you built librosco just call sudo make install then add the path where the library was installed to CMAKE_PREFIX_PATH if it's not a directory already in your PATH variable.
    Now you can just use find_package(librosco)



  • Hi Vronin,
    I could install librosco but when I search for the package i get this answer
    :```
    Detecting CXX compiler ABI info - done
    Detecting CXX compile features
    Detecting CXX compile features - done
    Defaulting to Linux build environment.
    CMake Warning at CMakeLists.txt:229 (find_package):
    By not providing "FindLIBROSCO.cmake" in CMAKE_MODULE_PATH this project has
    asked CMake to find a package configuration file provided by "LIBROSCO",
    but CMake did not find one.

    Could not find a package configuration file provided by "LIBROSCO" with any
    of the following names:

    LIBROSCOConfig.cmake
    librosco-config.cmake
    

    Add the installation prefix of "LIBROSCO" to CMAKE_PREFIX_PATH or set
    "LIBROSCO_DIR" to a directory containing one of the above files. If
    "LIBROSCO" provides a separate development package or SDK, be sure it has
    been installed.

    when I search for the library i get this fault:
    

    CMake Error at CMakeLists.txt:229 (find_library):
    find_library called with incorrect number of arguments

    the same when i write find_file.
    When i read the man for  find_library or find_file  only one argument is needed , the rest is optional. Am I right?


  • @Leopold said in cmake in linux ubuntu:

    I could install librosco

    In what folder?

    I think you missed this part:

    @VRonin said in cmake in linux ubuntu:

    add the path where the library was installed to CMAKE_PREFIX_PATH if it's not a directory already in your PATH variable.



  • Hi I did the sudo make install in the librosco build folder there it was the makefile
    adding to LD_LIBRARY_PATH was activated.
    I do not know where it is installed.


  • Lifetime Qt Champion

    @Leopold said in cmake in linux ubuntu:

    I do not know where it is installed

    You should see the path in the output of "make install"



  • i found them in /usr/lib



  • I exported /usr/lib to my path
    no help


  • Lifetime Qt Champion

    Are you using CMAKE_PREFIX_PATH as @VRonin suggested ?



  • Yes, i have it in the code

        message (STATUS "Defaulting to Linux build environment.")
        set(CMAKE_INCLUDE_CURRENT_DIR ON)
        set( CMAKE_PREFIX_PATH =/usr/lib)
      #  file(WRITE "${LIBROSCO} )#${CMAKE_STATIC_LIBRARY_PREFIX}librosco ${CMAKE_STATIC_LIBRARY_SUFFIX}so*" )
        find_library([${LIBROSCO}]
                     HINTS /usr/lib)
    
    
        # check if we found the library
         message(STATUS "LIB_ROSCO:${LIBROSCO}")
          message(PATH "LIB_ROSCO:${LIBROSCO}")
    
        target_link_libraries (${PNAME} ${LIBROSCO} Qt5::Widgets)
    

    this didn help so I exported the command and have it there```
    leopold@leopold-Mint:~$ export
    declare -x CINNAMON_VERSION="4.4.8"
    declare -x CMAKE_PREFIX_PATH="/usr/lib"
    declare -x COLORTERM="truecolor"
    declare -x DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus"
    declare -x DEFAULTS_PATH="/usr/share/gconf/cinnamon.default.path"
    declare -x DESKTOP_SESSION="cinnamon"
    declare -x DISPLAY=":0"
    declare -x GDMSESSION="cinnamon"
    declare -x GDM_LANG="de_DE"
    declare -x GJS_DEBUG_OUTPUT="stderr"
    declare -x GJS_DEBUG_TOPICS="JS ERROR;JS LOG"
    declare -x GNOME_DESKTOP_SESSION_ID="this-is-deprecated"
    declare -x GNOME_TERMINAL_SCREEN="/org/gnome/Terminal/screen/3383bf57_7307_4aea_ada8_299ad807e660"
    declare -x GNOME_TERMINAL_SERVICE=":1.74"
    declare -x GPG_AGENT_INFO="/run/user/1000/gnupg/S.gpg-agent:0:1"
    declare -x GTK_MODULES="gail:atk-bridge"
    declare -x GTK_OVERLAY_SCROLLING="1"

    no help again
    and have it as rwx/rwx/rwx in /usr/lib
    
    still:
    

    Defaulting to Linux build environment.
    LIB_ROSCO:LIBROSCO-NOTFOUND
    PATHLIB_ROSCO:LIBROSCO-NOTFOUND
    CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
    Please set them or make sure they are set and tested correctly in the CMake files:
    LIBROSCO
    linked by target "mems-rosco2.2.6" in directory /home/leopold/QT-examples/mems-rosco2.2.6

    Configuring incomplete, errors occurred!

    Now my question: Is this caused by an other entry in the cmakelists file?
    Here it is:

    cmake_minimum_required (VERSION 2.8.11)
    set (CMAKE_COMPILER_IS_GNUCC)
    set (PROJECTNAME "MEMS-rosco2.2.6")
    
    string (TOLOWER ${PROJECTNAME} PNAME)
    project (${PNAME})
    add_definitions (-DPROJECTNAME=\"${PROJECTNAME}\")
    
    set (VER_MAJOR 0)
    set (VER_MINOR 5)
    set (VER_PATCH 0)
    
    SET (Qt5LinguistTools_DIR /opt/Qt/5.12.2/gcc_64/lib/cmake/Qt5LinguistTools CACHE PATH "Qt5LinguistTools_DIR")
    
    FIND_PACKAGE( Qt5LinguistTools )
    
    set (LANGUAGES
    		transfile_en
    		transfile_esp
    		transfile_fr
    		transfile_ge
    	)
    set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1)
    qt5_create_translation(TRANSLATION_MESSAGES ${FILES_TO_TRANSLATE} ${TRANSLATION_FILES})
    qt5_add_translation(TRANSLATION_QM ${TRANSLATION_FILES})
    add_custom_target(translations_update DEPENDS ${TRANSLATION_MESSAGES})
    add_custom_target(translations DEPENDS ${TRANSLATION_QM})
    
    set (CMAKE_INCLUDE_CURRENT_DIR ON)
    set (CMAKE_AUTOMOC ON)
    
    set (CPACK_SOURCE_GENERATOR "TGZ")
    set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}-src")
    set (CPACK_SOURCE_IGNORE_FILES
          ".*~$"
          ".git"
          ".gitignore"
          ".*swp$"
          ".*zip$"
          ".*gz$"
          ".*deb$"
          "Makefile.*"
          "moc_"
          "qrc_"
          "^CPack.*"
          "_CPack_Packages"
          "CPackConfig.cmake"
          "CPackSourceConfig.cmake"
          "CMakeFiles"
          "CMakeCache.txt"
          "CMakeLists.txt.user*"
          "cmake_install.cmake"
          "install_manifest.txt"
          "README.TXT"
          "LICENSE.TXT"
          "build/"
          "build-win32/"
          "settings.ini"
          "debug"
          "release"
          "object_script.*")
    
    configure_file (
      "help.html.in"
      "${CMAKE_SOURCE_DIR}/help.html"
      )
    
    set(CMAKE_INSTALL_RPATH "/usr/local/lib")
    set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
    
    find_package (Qt5Widgets REQUIRED)
    
    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
    
    					 
    					 include_directories ("${CMAKE_SOURCE_DIR}"
                         "${CMAKE_SOURCE_DIR}/lib"
                         "${CMAKE_SOURCE_DIR}/qledindicator"
                         "${CMAKE_SOURCE_DIR}/analogwidgets"
                         "${CMAKE_CURRENT_BINARY_DIR}"
                         "${Qt5Widgets_INCLUDE_DIRS}"
    					 )
    
    
    qt5_wrap_ui (UI_SOURCE mainwindow.ui)
    qt5_add_resources (RG_RESOURCE resources.qrc)
    
    add_definitions ("-DVER_MAJOR=${VER_MAJOR}"
                     "-DVER_MINOR=${VER_MINOR}"
                     "-DVER_PATCH=${VER_PATCH}")
    
    add_executable (${PNAME} main.cpp
                             memsinterface.cpp
                             helpviewer.cpp
                             logger.cpp
                             serialdevenumerator.cpp
                             mainwindow.cpp
                             aboutbox.cpp
                             optionsdialog.cpp
                             qledindicator/qledindicator.cpp
                             analogwidgets/led.cpp
                             analogwidgets/functions.cpp
                             analogwidgets/widgetwithbackground.cpp
                             analogwidgets/manometer.cpp
                             analogwidgets/abstractmeter.cpp
    
    
    
                             ${UI_SOURCE}
                             ${RG_RESOURCE})
    
     #set (LIBROSCO_PATH "../librosco")
     #include_directories ("${LIBROSCO_PATH}/include")
    
    if (MINGW)
      message (STATUS "Found Windows/MinGW platform.")
    
      # prevent the final executable from launching a terminal window in parallel with the main GUI
      set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mwindows")
    
      # -fPIC appears to be redundant when building win32 binaries, so disable that flag
      string (REGEX REPLACE "-fPIC" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
    
      set (LIBROSCO_PATH "$ENV{SystemDrive}/mems-rosco")
      include_directories ("${LIBROSCO_PATH}/include")
      include_directories ("/usr/local/lib/include")
    
      message (STATUS "Defaulting installation path to: $ENV{SystemDrive}/${PNAME}")
      set (CMAKE_INSTALL_PREFIX "$ENV{SystemDrive}/${PNAME}")
      set (EXE_FILE "${CMAKE_CURRENT_BINARY_DIR}/${PNAME}.exe")
    
      # When we call find_library() below, we're only looking for DLLs, so set the suffix list appropriately
      set (CMAKE_FIND_LIBRARY_SUFFIXES ".dll")
      message (STATUS "Limiting find_library() suffixes to ${CMAKE_FIND_LIBRARY_SUFFIXES}")
    
      find_library (LIBGCC NAMES libgcc_s_sjlj-1 libgcc_s_seh-1 libgcc_s_dw2-1)
    	  if (LIBGCC)
    		message (STATUS "Found libgcc at ${LIBGCC}")
    	  else ()
    		message (SEND_ERROR "Could not find libgcc!")
    	  endif ()
    
      find_library (LIBSTDCPP libstdc++-6)
    	  if (LIBSTDCPP)
    		message (STATUS "Found libstdc++ at ${LIBSTDCPP}")
    	  else ()
    		message (SEND_ERROR "Could not find libstdc++!")
    	  endif ()
    
      find_library (ZLIB zlib1)
    	  if (ZLIB)
    		message (STATUS "Found zlib1 at ${ZLIB}")
    	  else ()
    		message (SEND_ERROR "Could not find zlib1!")
    	  endif ()
    
      find_library (QTCORE_DLL Qt5Core)
    	  if (QTCORE_DLL)
    		message (STATUS "Found QtCore at ${QTCORE_DLL}")
    	  else ()
    		message (SEND_ERROR "Could not find Qt5Core.dll! Check that the Qt5 bin/ directory (or the qtbase/bin/ directory) is in your PATH.")
    	  endif ()
    
      find_library (QTGUI_DLL Qt5Gui)
    	  if (QTGUI_DLL)
    		message (STATUS "Found QtGui at ${QTGUI_DLL}")
    	  else ()
    		message (SEND_ERROR "Could not find Qt5Gui.dll! Check that the Qt5 bin/ directory (or the qtbase/bin/ directory) is in your PATH.")
    	  endif ()
    
      find_library (QTWIDGETS_DLL Qt5Widgets)
    	  if (QTGUI_DLL)
    		message (STATUS "Found QtWidgets at ${QTWIDGETS_DLL}")
    	  else ()
    		message (SEND_ERROR "Could not find Qt5Widgets.dll! Check that the Qt5 bin/ directory (or the qtbase/bin/ directory) is in your PATH.")
    	  endif ()
    
      find_library (QWINDOWS_DLL qwindows)
    	  if (QWINDOWS_DLL)
    		message (STATUS "Found Qt qwindows platform plugin at ${QWINDOWS_DLL}")
    	  else ()
    		message (SEND_ERROR "Could not find Qt qwindows platform plugin!")
    	  endif ()
      
        find_library (LIPWINPTREAD libwinpthread-1)
    	  if (LIPWINPTREAD)
    		message (STATUS "Found libwinptread plugin at ${LIPWINPTREAD}")
    	  else ()
    		message (SEND_ERROR "Could not find winptread platform plugin!")
    	  endif ()
    
      find_library(LIBROSCO_DLL librosco PATHS ${LIBROSCO_PATH} ${CMAKE_INSTALL_PREFIX})
    	  if (LIBROSCO_DLL)
    		message (STATUS "Found librosco at ${LIBROSCO_DLL}")
    	  else ()
    		message (SEND_ERROR "Could not find librosco.dll! Check that it exists in one of the directories in your PATH.")
    	  endif ()
    
      #target_link_libraries (${PNAME} ${LIBROSCO_DLL} Qt5::Widgets)
    
      # convert Unix-style newline characters into Windows-style
      configure_file ("${CMAKE_SOURCE_DIR}/README" "${CMAKE_BINARY_DIR}/README.TXT" NEWLINE_STYLE WIN32)
      configure_file ("${CMAKE_SOURCE_DIR}/LICENSE" "${CMAKE_BINARY_DIR}/LICENSE.TXT" NEWLINE_STYLE WIN32)
    
      install (FILES "${CMAKE_BINARY_DIR}/README.TXT" "${CMAKE_BINARY_DIR}/LICENSE.TXT" DESTINATION "doc")
      install (FILES ${EXE_FILE}
                     ${LIBGCC}
                     ${LIBSTDCPP}
                     ${QTCORE_DLL}
                     ${QTGUI_DLL}
                     ${QTWIDGETS_DLL}
                     ${LIBROSCO_DLL}
             ${LIPWINPTREAD}
                     ${ZLIB}
               DESTINATION ".")
      install (FILES ${QWINDOWS_DLL} DESTINATION "platforms")
    
      set (CPACK_GENERATOR "ZIP")
      set (CPACK_PACKAGE_NAME ${PROJECT_NAME})
      set (CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
      set (CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}-${CMAKE_SYSTEM_NAME}")
      include (CPack)
    
    else()
        message (STATUS "Defaulting to Linux build environment.")
        set(CMAKE_INCLUDE_CURRENT_DIR ON)
        set( CMAKE_PREFIX_PATH =/usr/lib)
      #  file(WRITE "${LIBROSCO} )#${CMAKE_STATIC_LIBRARY_PREFIX}librosco ${CMAKE_STATIC_LIBRARY_SUFFIX}so*" )
        find_library([${LIBROSCO}]
                     HINTS /usr/lib)
    
        # check if we found the library
         message(STATUS "LIB_ROSCO:${LIBROSCO}")
          message(PATH "LIB_ROSCO:${LIBROSCO}")
    
        target_link_libraries (${PNAME} ${LIBROSCO} Qt5::Widgets)
    
      set (CMAKE_SKIP_RPATH TRUE)
      set (CMAKE_INSTALL_PREFIX "/usr")
      set (EXE_FILE "${CMAKE_CURRENT_BINARY_DIR}/${PNAME}")
    
      # set the installation destinations for the header files,
      # shared library binaries, and reference utility
      install (FILES ${EXE_FILE} DESTINATION "bin"
               PERMISSIONS
                OWNER_READ OWNER_EXECUTE OWNER_WRITE
                GROUP_READ GROUP_EXECUTE
                WORLD_READ WORLD_EXECUTE)
    
      install (DIRECTORY DESTINATION "share/doc/${PNAME}" DIRECTORY_PERMISSIONS
                OWNER_READ OWNER_EXECUTE OWNER_WRITE
                GROUP_READ GROUP_EXECUTE
                WORLD_READ WORLD_EXECUTE)
    
      install (FILES "${CMAKE_SOURCE_DIR}/README"
                     "${CMAKE_SOURCE_DIR}/LICENSE"
               DESTINATION "share/doc/${PNAME}"
               PERMISSIONS
                OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
    
      # set the architecture flag that will be used by the Debian package builder
      if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
        set (CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64)
      elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
        set (CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386)
      endif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
    
      set (CPACK_GENERATOR "DEB")
      set (CPACK_PACKAGE_NAME ${PROJECT_NAME})
      set (CPACK_PACKAGE_VERSION_MAJOR ${VER_MAJOR})
      set (CPACK_PACKAGE_VERSION_MINOR ${VER_MINOR})
      set (CPACK_PACKAGE_VERSION_PATCH ${VER_PATCH})
      set (CPACK_DEBIAN_PACKAGE_MAINTAINER "Colin Bourassa <colin.bourassa@gmail.com>")
      set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Graphical display for data read from Rover MEMS 1.6 (Modular Engine Management System)")
      set (CPACK_DEBIAN_PACKAGE_SECTION "Science")
      set (CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.13), libstdc++6 (>= 4.6.3), librosco (>= 0.1.0), libqt5core5a (>= 5.0.2), libqt5gui5 (>= 5.0.2), libqt5widgets5 (>= 5.0.2)")
      set (CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}-${CMAKE_SYSTEM_NAME}-${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
      set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
      set (CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README")
    
      include(CPack)
    
    endif()
    
    

  • Lifetime Qt Champion

    @Leopold said in cmake in linux ubuntu:

    find_library([${LIBROSCO}]

    This is wrong. See the documentation - you need to pass a variable, not the content of a variable


  • Lifetime Qt Champion

    @Leopold said in cmake in linux ubuntu:

    set( CMAKE_PREFIX_PATH =/usr/lib)

    That's an invalid path.



  • Hi both,
    as I tried the path with quotation marks as well and as variable only librosco in small letters (I have tried all forms of writing) and nothing helped , could you please give me the examples.



  • As I said:

    @VRonin said in cmake in linux ubuntu:

    use find_package(librosco)

    You are using find_library that tryes to link to a dll (which is already wrong) and it contains no infos on the dependancies


    set( CMAKE_PREFIX_PATH =/usr/lib)

    Remove this line, it just creates a mess as it might remove search paths. CMAKE_PREFIX_PATH should be set on the command line (if you are using Qt Creator you have to set it in the project configuration, on the left vertical bar, the wrench icon). /usr/lib is already in PATH so you should actually do nothing



  • Hi VRonin
    I did that```
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
    find_package(librosco)
    # check if we found the library
    message(PATH "LIB_ROSCO: ${librosco}" )
    message(STATUS "LIB_ROSCO:${librosco}" )

    how do i have to write the message command


  • If I configure directly with cmake I get this error:

    CMake Warning at CMakeLists.txt:234 (find_package):
      By not providing "Findlibrosco.cmake" in CMAKE_MODULE_PATH this project has
      asked CMake to find a package configuration file provided by "librosco",
      but CMake did not find one.
    
      Could not find a package configuration file provided by "librosco" with any
      of the following names:
    
        libroscoConfig.cmake
        librosco-config.cmake
    
      Add the installation prefix of "librosco" to CMAKE_PREFIX_PATH or set
      "librosco_DIR" to a directory containing one of the above files.  If
      "librosco" provides a separate development package or SDK, be sure it has
      been installed.
    
    
    PATHLIB_ROSCO: 
    LIB_ROSCO:
    Configuring done
    


  • I can not find those files myself. Do I have to add a command in the cmakelists.txt for librosco



  • what are the contents of /usr/lib/librosco?



  • I have no folder /usr/lib/librosco but
    in /usr/lib there are the three librosco.so ,librosco.so.2 and librosco.so.2.0.0


Log in to reply