简体   繁体   English

C ++ LInker错误(Visual Studio C ++ 2010)

[英]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.

相关问题 Visual Studio 2010 C ++项目的Poco和openssl链接器错误 - Poco and openssl linker error with visual studio 2010 c++ project 适用于大型项目的Visual Studio 2010 C ++链接器性能 - Visual Studio 2010 C++ linker performance for large projects Visual Studio 2010 C++ 尴尬 linker 行为不稳定 - Visual Studio 2010 C++ awkward linker erratic behaviour Visual Studio 2010 C ++运行时错误 - Visual Studio 2010 C++ runtime error 我试图在Visual Studio 2010编译c ++代码,我收到链接器错误 - I am trying to compile a c++ code at visual studio 2010 and i am getting a linker error 声明我从头文件创建的类时,Visual Studio 2010链接器错误C ++ - Visual Studio 2010 Linker Error C++ when declaring a class I created from a header file 使用Visual Studio 2010 C ++编译器和链接器,但未安装Visual Studio 2010 - Using Visual Studio 2010 C++ compiler and linker without Visual Studio 2010 having been installed 使用 Visual Studio C++ 进行单元测试时出现链接器错误 - Linker error while unit testing with Visual Studio C++ Visual Studio上的AWS C ++ SDK链接器错误 - AWS C++ SDK linker error on visual studio LINKER 错误 2005/2001 c++,视觉工作室 - LINKER ERROR 2005/2001 c++, visual studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM