c++ - 在 Windows 上为 glut 3.7 构建静态库

标签 c++ c static glut

我一直在尝试将 glut 编译为静态库,而不必在运行时与 glut32.dll 链接。我下载了 glut windows 源代码,但是当我尝试编译(默认)时,我不断得到:

Making in glut subdirectory...
        link  /INCREMENTAL:NO /NOLOGO -entry:_DllMainCRTStartup@12 -dll  -out:glut32.dll -def:glut.def glut_8x13.obj glut_9x15.obj glut_bitmap.obj glut_bwidth.obj glut_cindex.obj glut_cmap.obj glut_cu
rsor.obj glut_dials.obj glut_dstr.obj glut_event.obj glut_ext.obj glut_fullscrn.obj glut_gamemode.obj glut_get.obj glut_hel10.obj glut_hel12.obj glut_hel18.obj glut_init.obj glut_input.obj glut_joy.ob
j glut_key.obj glut_keyctrl.obj glut_keyup.obj glut_mesa.obj glut_modifier.obj glut_mroman.obj glut_overlay.obj glut_roman.obj glut_shapes.obj glut_space.obj glut_stroke.obj glut_swap.obj glut_swidth.
obj glut_tablet.obj glut_teapot.obj glut_tr10.obj glut_tr24.obj glut_util.obj glut_vidresize.obj glut_warp.obj glut_win.obj glut_winmisc.obj win32_glx.obj win32_menu.obj win32_util.obj win32_winproc.o
bj win32_x11.obj opengl32.lib glu32.lib winmm.lib kernel32.lib  ws2_32.lib mswsock.lib advapi32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib
LINK : fatal error LNK1104: cannot open file 'glut32.lib'
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\link.EXE"' : return code '0x450'
Stop.
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\nmake.EXE"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\nmake.EXE"' : return code '0x2'
Stop.

据我了解,glut32.lib 应该在 {source}\lib\glut\中编译和创建,但它不在那里。

任何为过剩编译静态库的帮助将不胜感激。

编辑:

Makefile.win

更改:
$(链接) $(LFLAGS) -out:$(GLUTDLL) -def:glut.def $(OBJS) $(LIBS)

库 $(OBJS) $(LIBS)

它生成了\lib\glut\glut_8x13.lib,我不确定 8x13 是什么,但是当我尝试链接它时,我得到了一些 Unresolved external 问题:

GPURenderer_test.obj : error LNK2019: unresolved external symbol __imp__glutCreateWindow@4 referenced in function "protected: __thiscall GlobalDecl::OpenGLConte
xt::OpenGLContext(unsigned int,unsigned int)" (??0OpenGLContext@GlobalDecl@@IAE@II@Z)
GPURenderer_test.obj : error LNK2019: unresolved external symbol __imp__glutInitWindowSize@8 referenced in function "protected: __thiscall GlobalDecl::OpenGLCon
text::OpenGLContext(unsigned int,unsigned int)" (??0OpenGLContext@GlobalDecl@@IAE@II@Z)
GPURenderer_test.obj : error LNK2019: unresolved external symbol __imp__glutInitWindowPosition@8 referenced in function "protected: __thiscall GlobalDecl::OpenG
LContext::OpenGLContext(unsigned int,unsigned int)" (??0OpenGLContext@GlobalDecl@@IAE@II@Z)
GPURenderer_test.obj : error LNK2019: unresolved external symbol __imp__glutInitDisplayMode@4 referenced in function "protected: __thiscall GlobalDecl::OpenGLCo
ntext::OpenGLContext(unsigned int,unsigned int)" (??0OpenGLContext@GlobalDecl@@IAE@II@Z)
GPURenderer_test.obj : error LNK2019: unresolved external symbol __imp__glutInit@8 referenced in function "protected: __thiscall GlobalDecl::OpenGLContext::Open
GLContext(unsigned int,unsigned int)" (??0OpenGLContext@GlobalDecl@@IAE@II@Z)
GPURenderer_test.obj : error LNK2019: unresolved external symbol __imp__glutSwapBuffers@0 referenced in function "protected: void __thiscall GlobalDecl::OpenGLC
ontext::_executeTest(class GlobalDecl::UnitTest &)" (?_executeTest@OpenGLContext@GlobalDecl@@IAEXAAVUnitTest@2@@Z)

谢谢, 瑞安

最佳答案

在我看来,您的build设置中有些东西被严重破坏了(或者您完全使用了错误的build设置,例如在构建它们使用的库之前尝试构建一些示例)。

要构建静态库,您根本不应该运行 link。对于静态库,您编译目标文件,然后使用 lib 将它们放在一个库中。您将使用 link 构建动态库 (DLL) 或可执行文件,而不是静态库。

关于c++ - 在 Windows 上为 glut 3.7 构建静态库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10856832/

相关文章:

php - 静态关键字在 PHP 生成器函数中不起作用

c++ - 为什么没有从指针到引用的隐式转换?

c++ - 使用 GCC 6.1 检测概念 TS

c++ - 在 Visual Studio 中使用子项目

c++ - MinGW + GVim 编译 C/C++ 失败(没有那个文件或目录)

c# - 如何将函数扩展到 Random 类

c++ - CodeSynthesis XSD 动态树序列化

c - 检索在 root 下运行的进程中登录的用户名或 ID

C语言编程 "Access violation writing location 0x00000000."

flash - xulrunner的插件容器已停止工作