C++未定义对`_imp__glewInit @ 0`的引用

imk*_*dal 2 c++ glew makefile

注意:我看过有关C语言中出现此问题的人的帖子,因为glew.c脚本没有为他加载,我不认为这是我的问题.从GLEW文档网站上的确切步骤尽可能接近(并且我没有提到添加名为glew.c的文件的要求)我已经使用MinGW设置了glew并将dll和libs提取到适当的位置文件夹尚未在编译时得到此消息:

undefined reference to `_imp__glewInit@0`
Run Code Online (Sandbox Code Playgroud)

这是我的主文件main.cpp:

#include <stdlib.h>
#include <iostream>
#include <windows.h>
#include <GL/glew.h>
#include <GL/glut.h>

using namespace std;

 int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutCreateWindow("Glew Test");
    GLenum err = glewInit();

    if (GLEW_OK != err)
    {
        cout << "Something effed up";
    }

    cout << "Awwwwwwwwhhhhh Yeeeeeeeaaaaah!!!";

return 0;
}
Run Code Online (Sandbox Code Playgroud)

这是我的MakeFile:

MY_LIBS = -lglut32 -lglew32 -lopengl32 
glewex:
    g++ -g main.cpp -o glewex $(MY_LIBS)
Run Code Online (Sandbox Code Playgroud)

有关为何我收到此错误的任何想法?

The*_*Saw 9

为什么要坚持从外部链接到这个库?它造成的麻烦比它值得多.

添加glew.c到您的项目.只需将其与其他源文件一起编译即可.只要你#define GLEW_STATIC它会工作正常.问题解决了.

即使您成功将其链接到库,您也可以绑定到一个特定的体系结构/构建/版本.如果您只是包含,glew.c您可以随意在任何地方构建项目.