Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How do I setup Qt 6.2 on Linux Mint to use GLEW / GLFW
Forum Updated to NodeBB v4.3 + New Features

How do I setup Qt 6.2 on Linux Mint to use GLEW / GLFW

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 598 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Colins2
    wrote on last edited by
    #1

    Hi,
    Having spent a fruitless afternoon trying to find an answer to this, I'm hoping someone here can help.
    I want to use GLFW / GLEW because I am following a course. (I am fully aware that Qt has it's own GL implementation)
    I am assuming that I can use the Qt Creator IDE for this as I have used it in the past for non-Qt applications.

    I am using Qt 6.2 on Linux Mint 20.1, and everything works fine.
    I downloaded GLFW and built it with the same GCC compiler that Qt uses. I now have a libglfw3.a file.

    I have copied the 2 header files to the include directory and they are found by the IDE.
    What do I do with the compiled libglfw3.a file? I have put it in /usr/lib but the linker does not find it.
    I am using Cmake for building, so how do I tell it where to find the library?

    I have read the Cmake documentation but it isn't much help. The same for the Qt documentation.
    I am sure that this is a simple question but I just cannot find an answer anywhere. I have seen the question asked numerous times but no-one has answered the actual problem.

    The minimal 'hello world' application from the GLFW website compiles but won't link.

    Thanks

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MrShawn
      wrote on last edited by
      #2

      Hi @Colins2

      Here is some minimum CMake to add to your project which will link to the lib.

      target_link_libraries(yourprojectname PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) //this should already exist in the auto generated cmake file
      target_link_libraries(yourprojectname  PUBLIC libglfwbinary)  //specify binary location here
      
      target_include_directories(mailman-server PUBLIC
                                "${PROJECT_BINARY_DIR}"
                                "${PROJECT_SOURCE_DIR}/../pathtolibglfwheaders"  //specify header location
                                )
      

      from that you should be able to include your headers and cmake should know where the binary is when you compile.

      Also consider making your library dynamic instead of static (.so extension instead of .a). If you don't know how look that up, but really not that critical for now.

      C 2 Replies Last reply
      0
      • M MrShawn

        Hi @Colins2

        Here is some minimum CMake to add to your project which will link to the lib.

        target_link_libraries(yourprojectname PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) //this should already exist in the auto generated cmake file
        target_link_libraries(yourprojectname  PUBLIC libglfwbinary)  //specify binary location here
        
        target_include_directories(mailman-server PUBLIC
                                  "${PROJECT_BINARY_DIR}"
                                  "${PROJECT_SOURCE_DIR}/../pathtolibglfwheaders"  //specify header location
                                  )
        

        from that you should be able to include your headers and cmake should know where the binary is when you compile.

        Also consider making your library dynamic instead of static (.so extension instead of .a). If you don't know how look that up, but really not that critical for now.

        C Offline
        C Offline
        Colins2
        wrote on last edited by
        #3

        @MrShawn
        Thanks for your reply, I will try your suggestions.
        To enable me to get on with the course, I have installed the Windows libraries and am using VS to compile and run examples.
        However, I really want to use Qt on Linux or Windows.

        1 Reply Last reply
        0
        • M MrShawn

          Hi @Colins2

          Here is some minimum CMake to add to your project which will link to the lib.

          target_link_libraries(yourprojectname PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) //this should already exist in the auto generated cmake file
          target_link_libraries(yourprojectname  PUBLIC libglfwbinary)  //specify binary location here
          
          target_include_directories(mailman-server PUBLIC
                                    "${PROJECT_BINARY_DIR}"
                                    "${PROJECT_SOURCE_DIR}/../pathtolibglfwheaders"  //specify header location
                                    )
          

          from that you should be able to include your headers and cmake should know where the binary is when you compile.

          Also consider making your library dynamic instead of static (.so extension instead of .a). If you don't know how look that up, but really not that critical for now.

          C Offline
          C Offline
          Colins2
          wrote on last edited by
          #4

          @MrShawn
          It's all working fine now, thanks for your help.
          I do search online before posting questions but sometimes the little nugget that makes the penny drop is difficult to find.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved