首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >编译GLUI库时,VS2010给了我一个奇怪的名称空间错误

编译GLUI库时,VS2010给了我一个奇怪的名称空间错误
EN

Stack Overflow用户
提问于 2010-10-12 06:01:38
回答 3查看 5.4K关注 0票数 3

我为我所在的一个类做了一个OpenGL项目,它是基于GLUI的。提供的GLUI库不能工作,这就是我尝试自己编译它的原因。因此,我从SourceForge下载了源代码,并尝试编译_glui库。它给了我这个,但我找不到任何关于它的信息:

代码语言:javascript
复制
1>ClCompile:
1>  algebra3.cpp
1>  arcball.cpp
1>  glui.cpp
1>c:\users\jake\downloads\glui-2.36\glui-2.36\src\include\gl\glui.h(1718): error C2252: an explicit instantiation of a template can only occur at namespace scope
1>c:\users\jake\downloads\glui-2.36\glui-2.36\src\include\gl\glui.h(1719): error C2252: an explicit instantiation of a template can only occur at namespace scope
1>  glui_add_controls.cpp
1>c:\users\jake\downloads\glui-2.36\glui-2.36\src\include\gl\glui.h(1718): error C2252: an explicit instantiation of a template can only occur at namespace scope
1>c:\users\jake\downloads\glui-2.36\glui-2.36\src\include\gl\glui.h(1719): error C2252: an explicit instantiation of a template can only occur at namespace scope
1>  glui_bitmap_img_data.cpp
1>  glui_bitmaps.cpp
1>c:\users\jake\downloads\glui-2.36\glui-2.36\src\include\gl\glui.h(1718): error C2252: an explicit instantiation of a template can only occur at namespace scope
1>c:\users\jake\downloads\glui-2.36\glui-2.36\src\include\gl\glui.h(1719): error C2252: an explicit instantiation of a template can only occur at namespace scope
1>  glui_button.cpp
1>c:\users\jake\downloads\glui-2.36\glui-2.36\src\include\gl\glui.h(1718): error C2252: an explicit instantiation of a template can only occur at namespace scope
1>c:\users\jake\downloads\glui-2.36\glui-2.36\src\include\gl\glui.h(1719): error C2252: an explicit instantiation of a template can only occur at namespace scope
1>  glui_checkbox.cpp
1>c:\users\jake\downloads\glui-2.36\glui-2.36\src\include\gl\glui.h(1718): error C2252: an explicit instantiation of a template can only occur at namespace scope
1>c:\users\jake\downloads\glui-2.36\glui-2.36\src\include\gl\glui.h(1719): error C2252: an explicit instantiation of a template can only occur at namespace scope
1>  glui_column.cpp

等等等等

我查看了glui.h源文件,1718和1719行包含以下内容:

代码语言:javascript
复制
#ifdef _MSC_VER
// Explicit template instantiation needed for dll
template class GLUIAPI std::allocator<GLUI_String>;
template class GLUIAPI std::vector<GLUI_String, std::allocator<GLUI_String> >;
#endif

有人见过这个吗?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2010-10-12 06:03:37

如果有人有更多的信息,我很高兴听到,但我发现注释掉glui.h中的部分可以编译它。现在我们来看看编译后的库是否能正常工作……

票数 1
EN

Stack Overflow用户

发布于 2013-08-20 22:23:29

我刚刚遇到了这个问题。然后我跟着做,你可以试一试。

(1)从gib下载最新版本。

(2)使用vs2010构建。

(3)你会遇到这个问题

代码语言:javascript
复制
#ifdef _MSC_VER
// Explicit template instantiation needed for dll
template class GLUIAPI std::allocator<GLUI_String>;
template class GLUIAPI std::vector<GLUI_String, std::allocator<GLUI_String> >;
#endif

只需将代码从类中取出,重新构建即可。

(4)生成glui.lib。

(5)使用glui.lib和glui.h

票数 3
EN

Stack Overflow用户

发布于 2012-12-06 10:15:23

不能在函数或类中显式实例化模板。尝试将它移到函数或类之外。或者它是一个图书馆?

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3910262

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档