C++ 对InitGL的未定义引用

C++ 对InitGL的未定义引用,c++,c,opengl,undefined-reference,glew,C++,C,Opengl,Undefined Reference,Glew,问题是,我正在尝试编译简单的C++/OpenGL代码,不管我从编译器中得到什么: /tmp/ccU7u7eO.o: In function `main': main.cpp:(.text+0x55): undefined reference to `initGL()' main.cpp:(.text+0x72): undefined reference to `loadMedia()' main.cpp:(.text+0x8f): undefined reference to `handleKe

问题是,我正在尝试编译简单的C++/OpenGL代码,不管我从编译器中得到什么:

/tmp/ccU7u7eO.o: In function `main':
main.cpp:(.text+0x55): undefined reference to `initGL()'
main.cpp:(.text+0x72): undefined reference to `loadMedia()'
main.cpp:(.text+0x8f): undefined reference to `handleKeys(unsigned char, int, int)'
main.cpp:(.text+0x99): undefined reference to `render()'
我用这些来编译它:
g++main.cpp-o test-lGLEW-lGLU-lGL-lglut

错误
未定义对“x”的引用
只是意味着编译器无法找到该名称的符号

常见原因包括:

  • 错过图书馆
  • 如果项目中有多个源文件,则忘记在编译器/链接器命令中包含文件
  • 函数名的键入/拼写错误,例如,当您真正的意思是
    initGL
    时,您键入了
    initGL

这是我能做的最好的事情,无需您发布其余代码。

您是否尝试过为GLEW启用实验模式?我不认为initGL和handleKeys是GL函数,如果它们是您的函数,您可能需要检查是否首先定义了它们。