我有我的显卡的最新驱动程序。我正在为Windows(glfw-3.2.1.bin.WIN64)使用glfw 3.2.1,这是预编译的库。我还使用glew 2.1.0(glew-2.1.0),因为我认为也许我也需要它。我编写了一个Powershell脚本来为我完成所有编译工作,称为“ compile TEST.ps1”。
我相信自己链接正确,但是无论如何我可能都把它弄乱了。我已经将glew32.dll和glfw3.dll都放入了名为“ main.cpp”的.cpp文件中。这些dll也被复制粘贴到我的System32文件中。每当我运行脚本尝试编译程序时,它就会失败并显示给定错误:
g++ : C:\Users\USERNAMEHERE~1\AppData\Local\Temp\ccYYPyBE.o:main.cpp:(.text+0x11): undefined reference to `_imp__glfwInit'
At E:\c++\projected\compile TEST.ps1:1 char:1
+ g++ main.cpp -I"E:\c++\projected\glfw-3.2.1.bin.WIN64\include" -I"E:\ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (C:\Users\USERNAMEHERE..._imp__glfwInit':String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
TLDR: 我正在使用glfw和glew并尝试使用g ++进行编译,但我不断收到此错误,并且与glfw3中的所有方法类似。
我搞砸了什么? LWJGL好多了。
“编译TEST.ps1”
g++ main.cpp -I"E:\c++\projected\glfw-3.2.1.bin.WIN64\include" -I"E:\c++\projected\glew-2.1.0\include" -L"E:\c++\projected\glfw-3.2.1.bin.WIN64\lib-mingw-w64" -L"E:\c++\projected\glew-2.1.0\lib\Release\Win32" -lglfw3 -lglew32 -lopengl32 -lglu32 -lgdi32 -mwindows
./colorCorrection.exe
Pause
“ colorCorrection.exe”是我编写的程序,用于解决g ++确实使我的powershell实例变色的情况。
“ main.cpp”
#define GLEW_STATIC
#include <GL/glew.h>
#define GLFW_DLL
#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>
int main(){
glewInit();
if (!glfwInit()){
// Initialization failed
}else{
glfwTerminate();
}
return 0;
}
这不是我第一次尝试使其工作,但我总是被困在这里。