OpenGL GLFW:对'glfwInit'的未定义引用 [英] OpenGL GLFW: undefined reference to 'glfwInit'

查看:1073
本文介绍了OpenGL GLFW:对'glfwInit'的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我意识到在StackOverflow和其他站点上已经多次问过这个问题了;在查看了这些资源后,我仍然很茫然.

I realize that this question has been asked many times on StackOverflow and on other sites; after reviewing these resources I am still at a loss.

我只是想让GLFW在我的机器(Windows 7 64位)上运行OpenGL.

I am simply trying to get OpenGL working on my machine (Windows 7 64-bit) with GLFW.

我遇到的问题与其他许多问题一样:我收到单个链接器错误:未定义对'glfwInit'的引用."我尝试编译的代码是最简单的(在文件Test.cpp中).

The issue I am having is the same as many others have: I am getting the singular linker error: "undefined reference to 'glfwInit'." The code I am trying to compile is the simplest possible (in a file Test.cpp).

#include <iostream>
#include <GLFW/glfw3.h>
int main()
{
    std::cout << "hello world" << std::endl;
    glfwInit();
    return 0;
}

我正在使用一个简单的Makefile尝试进行编译:

I am using a simple Makefile to attempt to compile:

Test: Test.o
    g++ -o Test  -L./lib -lglew32 -lglfw3 -lopengl32 -lglu32 -lgdi32 Test.o

Test.o: Test.cpp
    g++ -I./include -c Test.cpp

其他信息:
*使用g ++进行编译(MinGW32)
* lib文件夹包含glfw3.dll,libglfw3.a和libglfw3dll.a(从GLFW网站下载的Win32版本-Windows预编译的库)
* include文件夹包含一个名为GLFW的文件夹,其中包含glfw3.h和glfw3native.h(来自下载的GLFW-include文件夹)

Additional information:
* Using g++ to compile (MinGW32)
* The lib folder contains glfw3.dll, libglfw3.a, and libglfw3dll.a (Win32 version downloaded from GLFW website - Windows pre-compiled library)
* The include folder contains a folder named GLFW, which contains glfw3.h and glfw3native.h (from downloaded GLFW - include folder)

我尝试过:
*使用GLFW中的64位版本
*使用IDE(Eclipse,VS)
* GLFW未定义引用
中的建议 * 中的建议是一个未定义的引用/未解决的外部符号错误,如何解决?(交换链接参数顺序)
* 带有Eclipse CDT + MinGW + GLEW + GLFW的OpenGL中的建议:未定义的引用
*尝试使用CMake自己编译库,但看不到在此过程中创建的任何.a,.lib或.dll文件.

I have tried:
* Using the 64-bit version from GLFW
* Using IDEs (Eclipse, VS)
* The suggestion in GLFW Undefined References
* Suggestions in What is an undefined reference/unresolved external symbol error and how do I fix it? (swapping linking argument order)
* Suggestion in OpenGL with Eclipse CDT + MinGW + GLEW + GLFW: Undefined References
* Attempted to use CMake to compile the libraries myself, but do not see any .a, .lib, or .dll files created in the process.

请让我知道其他信息是否有帮助.

Please let me know if additional information would be helpful.

推荐答案

几个小时后终于弄清了我的问题.

Finally figured out my issue MANY hours later.

将libglfw3.a文件与glfw3.dll放在同一目录中(如果尝试动态链接)会使链接器混乱.如果动态链接,请将其删除-您只需要dll和/include文件夹即可.

Leaving the libglfw3.a file in the same directory as the glfw3.dll (if attempting dynamic linking) will confuse the linker. Delete it if linking dynamically - all you need is the dll and the /include folder.

还添加

#define GLFW_DLL

如果与DLL链接,则在include语句上方.

above the include statement if linking with a DLL.

这篇关于OpenGL GLFW:对'glfwInit'的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆