GLFW将无法正确链接 [英] GLFW Won't Link Correctly
问题描述
操作系统:Windows 8 64位
编译器:mingw64
p> IDE:eclipse
我的简单测试程序:
#include< stdio.h>
#include< stdlib.h>
#define GLEW_STATIC
#include< gl / glew.h>
#include< gl / glfw3.h>
int main(void){
glfwInit();
puts(Hello,World!);
return(EXIT_SUCCESS);
}
我如何设置链接: http://i.imgur.com/yyISNtZ.png
这些错误(注意这些只在引用任何GLFW函数时才会发生,它们不会通过简单包含头部而发生):
13 :33:00 ****为项目MementoLibrary增量构建配置发布****
信息:内部构建器用于构建
gcc -O3 -Wall -c -fmessage-length = 0 - osrc\\\MementoLibrary.o..\\src\\\MementoLibrary.c
gcc -o MementoLibrary.exesrc\\\MementoLibrary.o-lglfw3 - lglew32s -lopengl32
c:/ mingw64 / mingw64 / bin /../ lib / gcc / x86_64-w64-mingw32 / 4.8.1 /../../../../ x86_64-w64-mingw32 / lib / ../ lib / libglfw3.a(win32_monitor.c.obj):win32_monitor.c :( .text + 0x2a7):未定义引用__imp_CreateDCW'
c:/ mingw64 / mingw64 / bin /../ LIB / GCC / x86_64的-W64-的mingw32 / 4.8.1 /../../../../ x86_64的-W64-的mingw32 / LIB / .. /lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x2e9):未定义对`__imp_GetDeviceCaps'的引用
c:/ mingw64 / mingw64 / bin /../ lib / gcc / x86_64的-W64-的mingw32 / 4.8.1 /../../../../ x86_64的-W64-的mingw32 / lib中/../ LIB / libglfw3.a(win32_monitor.c.obj):win32_monitor.c: (.text + 0x2fb):未定义引用`__imp_GetDeviceCaps'
c:/ mingw64 / mingw64 / bin /../ lib / gcc / x86_64-w64-mingw32 / 4.8.1 /../../ .. /../x86_64-w64-mingw32/lib/../lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x31e):对`__imp_DeleteDC'的未定义引用
c: /mingw64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe:c: /mingw64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/lib/../lib/libglfw3 .a(win32_monitor.c.obj):`.pdata'节中的重定位地址0x0错误
collect2.exe:错误:ld返回1退出状态
您的静态GLFW库使用 _ GLFW_NO_DLOAD_WINMM
编译时宏启用。这个和其他这样的宏可以在GLFW配置头文件中找到。
定义这个会导致GLFW假定你将链接到winmm( winmm .lib
在Visual C ++上或 libwinmm.a
在MinGW上)。这不是库的静态版本的默认设置,所以我假设你自己编译了它。您可以将winmm添加到链接时依赖项,或者在编译GLFW时不定义 _GLFW_NO_DLOAD_WINMM
。
让你的程序链接。
So recently I've started a project involving GLFW (64-bit, with GLEW). However, I can't seem to get it to link correctly. Here's how I'm set up:
OS: Windows 8 64-bit
Compiler: mingw64
IDE: eclipse
My simple test program:
#include <stdio.h>
#include <stdlib.h>
#define GLEW_STATIC
#include <gl/glew.h>
#include <gl/glfw3.h>
int main(void) {
glfwInit();
puts("Hello, World!");
return (EXIT_SUCCESS);
}
How I've set up the linking: http://i.imgur.com/yyISNtZ.png
The errors (note these only occur when referencing any GLFW function. They don't occur by simply including the header):
13:33:00 **** Incremental Build of configuration Release for project MementoLibrary ****
Info: Internal Builder is used for build
gcc -O3 -Wall -c -fmessage-length=0 -o "src\\MementoLibrary.o" "..\\src\\MementoLibrary.c"
gcc -o MementoLibrary.exe "src\\MementoLibrary.o" -lglfw3 -lglew32s -lopengl32
c:/mingw64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/lib/../lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x2a7): undefined reference to `__imp_CreateDCW'
c:/mingw64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/lib/../lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x2e9): undefined reference to `__imp_GetDeviceCaps'
c:/mingw64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/lib/../lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x2fb): undefined reference to `__imp_GetDeviceCaps'
c:/mingw64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/lib/../lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x31e): undefined reference to `__imp_DeleteDC'
c:/mingw64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: c:/mingw64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/lib/../lib/libglfw3.a(win32_monitor.c.obj): bad reloc address 0x0 in section `.pdata'
collect2.exe: error: ld returned 1 exit status
Your static GLFW library is compiled with the _GLFW_NO_DLOAD_WINMM
compile-time macro enabled. This and other such macros may be found in the GLFW config header.
Defining this causes GLFW to assume that you will be linking against winmm (winmm.lib
on Visual C++ or libwinmm.a
on MinGW). This is not the default setting for the static version of the library, so I assume you have compiled it yourself. You can either add winmm to your link-time dependencies or not define _GLFW_NO_DLOAD_WINMM
when compiling GLFW.
Either solution should make your program link.
这篇关于GLFW将无法正确链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!