gpt4 book ai didi

visual-studio-2010 - 编译 GLUI 库,VS2010 给我一个奇怪的命名空间错误

转载 作者:行者123 更新时间:2023-12-01 11:07:25 25 4
gpt4 key购买 nike

我有一个我所在类(class)的 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

有人以前见过这个吗?

最佳答案

我刚遇到这个问题。那我就跟着做,你可以试试。

(1) 从gib下载最新vision。
(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

关于visual-studio-2010 - 编译 GLUI 库,VS2010 给我一个奇怪的命名空间错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3910262/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com