Visual c++ “如何修复OpenGL编译错误”;未解析的外部符号“;

Visual c++ “如何修复OpenGL编译错误”;未解析的外部符号“;,visual-c++,linker-errors,Visual C++,Linker Errors,我正试图编写一个OpenGL程序来操作相机。但是,代码没有编译 错误是: 1>------ Rebuild All started: Project: Lab4, Configuration: Debug Win32 ------ 1>Build started 2/14/2011 7:17:54 PM. 1>_PrepareForClean: 1> Deleting file "Debug\Lab4.lastbuildstate". 1>InitializeB

我正试图编写一个OpenGL程序来操作相机。但是,代码没有编译

错误是:

1>------ Rebuild All started: Project: Lab4, Configuration: Debug Win32 ------
1>Build started 2/14/2011 7:17:54 PM.
1>_PrepareForClean:
1>  Deleting file "Debug\Lab4.lastbuildstate".
1>InitializeBuildStatus:
1>  Touching "Debug\Lab4.unsuccessfulbuild".
1>ClCompile:
1>  camera.cpp
1>camera.obj : error LNK2019: unresolved external symbol "public: void __thiscalllVector3::normalize(void)" (?normalize@Vector3@@QAEXXZ) referenced in function "public: void __thiscall Camera::set(class Point3,class Point3,class Vector3)" (?set@Camera@@QAEXVPoint3@@0VVector3@@@Z)
1>camera.obj : error LNK2019: unresolved external symbol "public: class Vector3 __thiscall Vector3::cross(class Vector3)" (?cross@Vector3@@QAE?AV1@V1@@Z) referenced in function "public: void __thiscall Camera::set(class Point3,class Point3,class Vector3)" (?set@Camera@@QAEXVPoint3@@0VVector3@@@Z)
1>camera.obj : error LNK2019: unresolved external symbol "public: float __thiscall Vector3::dot(class Vector3)" (?dot@Vector3@@QAEMV1@@Z) referenced in function "private: void __thiscall Camera::setModelviewMatrix(void)" (?setModelviewMatrix@Camera@@AAEXXZ)
1>C:\Users\Andrew Davis\Documents\Visual Studio 2010\Projects\Lab4\Debug\Lab4.exe : fatal error LNK1120: 3 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.08
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
我的链接器中已经有此项:

opengl32.lib glu32.lib glut32.lib freeglut.lib


有什么建议吗?提前谢谢

这不是OpenGL或其库的问题。看起来camera.cpp使用了一些不同的类,但它的实现不是生成的就是未链接的

编辑:只需查看您的代码


如何实现
Vector3::normalize()
Vector3::cross()
Vector3::dot()
?粘贴库中的第86、107和108行。

这不是OpenGL或其库的问题。看起来camera.cpp使用了一些不同的类,但它的实现不是生成的就是未链接的

编辑:只需查看您的代码


如何实现
Vector3::normalize()
Vector3::cross()
Vector3::dot()
?粘贴箱中的第86、107和108行。

您必须为以下功能提供一个主体,即使它是空的。
Vector3::normalize()、Vector3::cross()、Vector3::dot()
。比如说

void normalize(){ //do something}

您正在调用它们,因此会出现未解决的链接器错误,因为没有实现。

您必须为以下函数提供一个主体,即使它是空的。
Vector3::normalize()、Vector3::cross()、Vector3::dot()
。比如说

void normalize(){ //do something}

您正在调用它们,因此会出现未解决的链接器错误,因为没有实现。

我从我的计算机图形学书籍中获取了大部分现有代码。你能说得更具体一点吗,我对OpenGL非常陌生!我真的很感谢你的回复!好的,我让它为normalize工作,但是cross&dot仍然有问题。我从我的计算机图形学书籍中获取了大部分现有代码。你能说得更具体一点吗,我对OpenGL非常陌生!我真的很感谢你的回复!好的,我让它为normalize工作,但是cross&dot仍然有问题。如果可以,请阅读我对另一个答案的评论。我对此仍有困难。谢谢如果可以,请阅读我对另一个答案的评论。我对此仍有困难。谢谢