[英]C++ LInker error (Visual Studio C++ 2010)
I tried to create empty project for Visual Studio. 我试图为Visual Studio创建一个空项目。
// OpenGL1.cpp : main project file.
// #include "stdafx.h"
#include "windows.h"
#include <GL/gl.h>
#include <iostream>
using namespace System;
int main()
{
std::cout << "Hello World" << "\n";
return 0;
}
Having configured these dependencies: 配置了以下依赖项:
opengl32.lib;glu32.lib;olepro32.lib;%(AdditionalDependencies);C:\\Program Files\\Microsoft SDKs\\Windows\\v7.0A\\Include\\gl; opengl32.lib; glu32.lib; olepro32.lib;%(AdditionalDependencies); C:\\ Program Files \\ Microsoft SDKs \\ Windows \\ v7.0A \\ Include \\ gl;
And I got this error: 我得到了这个错误:
.NETFramework,Version=v4.0.AssemblyAttributes.cpp LINK : fatal error LNK1104: cannot open file 'C:\\Program Files\\Microsoft SDKs\\Windows\\v7.0A\\Include\\gl.obj' .NETFramework,Version = v4.0.AssemblyAttributes.cpp链接:致命错误LNK1104:无法打开文件'C:\\ Program Files \\ Microsoft SDKs \\ Windows \\ v7.0A \\ Include \\ gl.obj'
Can you explain why this happens and how to remove the error? 您能解释一下为什么会发生这种情况以及如何消除错误吗?
The "dependencies" refer to the filenames of libraries which the linker should use, not to include paths. “依赖项”是指链接器应使用的库文件名 ,而不包括路径。 Include paths are for the compiler, not for the linker. 包含路径适用于编译器,而不适用于链接器。
You must first tell the linker where to find the OpenGL library file: 您必须首先告诉链接器在哪里可以找到OpenGL库文件:
http://msdn.microsoft.com/en-us/library/1xhzskbe%28v=vs.100%29.aspx http://msdn.microsoft.com/en-us/library/1xhzskbe%28v=vs.100%29.aspx
And then, as a dependency, you specify only its name, not a full path. 然后,作为依赖项,您仅指定其名称,而不指定完整路径。 In this case, opengl32.lib
. 在这种情况下,请使用opengl32.lib
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.