简体   繁体   English

GLM声明后定义vec3

[英]GLM Define a vec3 after declaration

I am trying to write a program using OpenGL. 我正在尝试使用OpenGL编写程序。 I am using the GLM header-only library for its vector and matrix functions, and I have run into something really weird. 我正在将GLM仅标头库用于其向量和矩阵函数,但遇到了一些非常奇怪的问题。

I have a glm::vec3 that I want to use as the position for an object, so I declare it in my header file ( glm::vec3 position; ) and then I want to actually set it in the object constructor ( position = glm::vec3(0.0f, 0.0f, 0.0f) ). 我有一个glm::vec3我想用作对象的位置,所以我在头文件中声明了它( glm::vec3 position; ),然后实际上要在对象构造函数中设置它( position = glm::vec3(0.0f, 0.0f, 0.0f) )。 When I try to compile this, I get a LNK2019 error. 当我尝试对此进行编译时,出现LNK2019错误。

To make diagnosing this easier, I have tested the following two pieces of code: 为了简化诊断,我测试了以下两段代码:

glm::vec3 position = glm::vec3(0.0f, 0.0f, 0.0f);

and

glm::vec3 position;
position = glm::vec3(0.0f, 0.0f, 0.0f);

The first one compiles and runs absolutely fine. 第一个编译并运行完全正常。

The second one gets the LNK2019 error: 第二个出现LNK2019错误:

main.obj : error LNK2019: unresolved external symbol "public: struct
glm::tvec3<float,0> & __thiscall glm::tvec3<float,0>::operator=(struct 
glm::tvec3<float,0> const &)" (??4?$tvec3@M$0A@@glm@@QAEAAU01@ABU01@@Z) 
referenced in function _main

I am probably missing something really obvious, but I cannot figure it out. 我可能缺少真正明显的东西,但我无法弄清楚。 I am using VS2010, if that makes any difference. 我正在使用VS2010,如果有什么区别。

I have been playing around with this myself. 我自己一直在玩这个游戏。 It appears that the issue is with the new version of GLM; 看来问题出在新版本的GLM上。 0.9.7.0. 0.9.7.0。 I downloaded each of the previous versions back to 0.9.5.4 and did not experience this issue. 我将每个以前的版本下载回0.9.5.4,但没有遇到此问题。

Since the new version was uploaded less than a month ago I think I can assume there is some kind of bug with it. 由于新版本的上传时间不到一个月,我想我可以假设它存在某种错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM