GLFW3 - Undefined reference to XRR

前端 未结 1 759
被撕碎了的回忆
被撕碎了的回忆 2021-01-17 23:54

I am trying to compile a very simple OpenGL program that uses GLFW3. Despite linking everything I deem necessary, I\'m getting a plethora of undefined references.

         


        
1条回答
  •  心在旅途
    2021-01-18 00:21

    I figured out the answer myself while writing the question.

    I was misled into believing that I was linking everything necessary because of the output of

    pkg-config --libs --cflags --print-requires glfw3 
    

    which was

    -I/usr/local/include  -L/usr/local/lib -lglfw3  
    

    The --print-requires flag was having no impact at all on the output, which seemed odd. I searched and printed the corresponding .pc file.

    sudo find / | grep "glfw3\.pc"
    cat /usr/local/lib/pkgconfig/glfw3.pc 
    

    There I found this.

    Requires.private:  x11 xrandr xi xxf86vm gl
    

    Which indicates which libraries are required for static linking. I added their correponding flags to CMake and it worked. My mistake was that I missed the --print-requires-private flag when executing pkg-config.

    I hope this helps someone save some time.

    0 讨论(0)
提交回复
热议问题