我为我所在的一个类做了一个OpenGL项目,它是基于GLUI的。提供的GLUI库不能工作,这就是我尝试自己编译它的原因。因此,我从SourceForge下载了源代码,并尝试编译_glui库。它给了我这个,但我找不到任何关于它的信息:
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行包含以下内容:
#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有人见过这个吗?
发布于 2010-10-12 06:03:37
如果有人有更多的信息,我很高兴听到,但我发现注释掉glui.h中的部分可以编译它。现在我们来看看编译后的库是否能正常工作……
发布于 2013-08-20 22:23:29
我刚刚遇到了这个问题。然后我跟着做,你可以试一试。
(1)从gib下载最新版本。
(2)使用vs2010构建。
(3)你会遇到这个问题
#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
发布于 2012-12-06 10:15:23
不能在函数或类中显式实例化模板。尝试将它移到函数或类之外。或者它是一个图书馆?
https://stackoverflow.com/questions/3910262
复制相似问题