Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用GLFW3编译OpenGL程序_Opengl_Glfw - Fatal编程技术网

用GLFW3编译OpenGL程序

用GLFW3编译OpenGL程序,opengl,glfw,Opengl,Glfw,我安装了GLFW3,并试图用以下代码编译我的OpenGL程序: g++ -std=c++11 main.cpp -lGL -lGLEW -lglfw3 但这里是我得到的库错误: /usr/bin/ld: cannot find -lglfw3 collect2: error: ld returned 1 exit status 我还尝试了pkg config: g++ `pkg-config --cflags glfw3 glew` -o myprog main.cpp `pkg-conf

我安装了GLFW3,并试图用以下代码编译我的OpenGL程序:

g++ -std=c++11 main.cpp -lGL -lGLEW -lglfw3 
但这里是我得到的库错误:

/usr/bin/ld: cannot find -lglfw3
collect2: error: ld returned 1 exit status
我还尝试了pkg config:

g++ `pkg-config --cflags glfw3 glew` -o myprog main.cpp `pkg-config --static --libs glfw3 glew`
它可以编译,但当我运行myprog时,它说找不到libglfw.so.3

但它位于/usr/local/lib中

Ubuntu在/usr/local/lib中安装libglfw.so.3,因此您必须将这一行添加到/etc/ld.so.conf中,我也遇到了同样的问题。 在我的案例中,以下步骤是有用的:

  • 下载glfw源代码
  • 解开它
  • cd glfw_文件夹
  • 克马克。(带圆点)
  • 制造
  • sudo制作安装
  • 要检查,请在控制台中复制并粘贴以下命令“whereis libglfw3”。 您应该有如下输出:“libglfw3:/usr/local/lib/libglfw3.a”(或“:”之后的另一个路径)

    我的配置:VAIO Pro 13/Ubuntu 16.04 LTS/Intel HD4000


    附言:是的,我试过“sudo apt get install libglfw3”和所有依赖项

    IIRC Ubuntu默认查看
    /usr/local/lib
    ;我想我从来没有这样做过。虽然它安装为
    libglfw.so.3
    ,但不是
    libglfw3.so