gpt4 book ai didi

opengl - Ubuntu 上对 OpenGL 的 undefined reference

转载 作者:行者123 更新时间:2023-12-05 04:17:29 24 4
gpt4 key购买 nike

我得到了所有这些 undefined reference :

Linking CXX executable SimpleGavam
../../lib/local/Gavam/libGavam.a(MeshUtils.cpp.o): In function `Gavam::DrawMesh(cv::Mat_<float>&, cv::Mat_<float> const&, cv::Mat_<int> const&, cv::Vec<double, 6> const&, double, double, double, double, cv::Size_<int> const&, double, double)':
/home/samuel/Clm-Z/lib/local/Gavam/src/MeshUtils.cpp:189: undefined reference to `glutSwapBuffers'
../../lib/local/Gavam/libGavam.a(MeshUtils.cpp.o): In function `Gavam::InitialiseOpenGLDrawingWindow(int, int, double, double, double)':
/home/samuel/Clm-Z/lib/local/Gavam/src/MeshUtils.cpp:578: undefined reference to `glutInit'
/home/samuel/Clm-Z/lib/local/Gavam/src/MeshUtils.cpp:580: undefined reference to `glutInitDisplayMode'
/home/samuel/Clm-Z/lib/local/Gavam/src/MeshUtils.cpp:582: undefined reference to `glutInitWindowSize'
/home/samuel/Clm-Z/lib/local/Gavam/src/MeshUtils.cpp:584: undefined reference to `glutCreateWindow'
/home/samuel/Clm-Z/lib/local/Gavam/src/MeshUtils.cpp:585: undefined reference to `glutHideWindow'
collect2: error: ld returned 1 exit status
make[2]: *** [exe/SimpleGavam/SimpleGavam] Error 1
make[1]: *** [exe/SimpleGavam/CMakeFiles/SimpleGavam.dir/all] Error 2

我正在使用 cmake 编译我的项目,我在 CMakeLists 中添加了 glut 标志

SET( CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -g -std=c++11 -lGL -lglut -lGLU")
SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -g -std=c++11 -lGL -lglut -lGLU")

我在文件中包含这些内容:

#include <Gavam.h>

#include <math.h>
#include <fstream>

// OPEN GL
#include <GL/gl.h>
#include <GL/freeglut.h>

我做错了什么?

最佳答案

使用 CMake 标准模块而不是链接器标志 FindOpenGL

关于opengl - Ubuntu 上对 OpenGL 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22985882/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com