开发者

Compiling GLUI library, VS2010 gives me a weird namespace error

I've got an OpenGL project for a class I'm in, and it's based on GLUI. The provided GLUI library won't work which is why I'm trying to compile it myself. So, I downloaded the source code from SourceForge and try to compile the _glui library. It gives me this, and I can't find any information on it:

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

etc, etc etc

I look at the glui.h source file, and lines 1718 and 1719 have this:

#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

Anyone seen this before?


I just come across this problem. then I do following,you can try.

(1) download the lastest vision from gib.
(2) use vs2010 build it.
(3) you will come across the problem

#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

just get the code out of class, rebuild again.
(4) you will generate glui.lib.
(5) use the glui.lib,and the glui.h


You cannot explicitly instantiate a template inside a function or a class. try moving it outside the function or class. Or is it a library?


If anyone has more info, I'd be glad to hear it, but I found that commenting out the section in glui.h allows it to compile. Now we'll find out if the compiled library actually works....

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜