使用 MinGW 在 eclipse 中构建 box2d 测试台应用程序

发布于 2024-12-26 05:11:29 字数 7194 浏览 1 评论 0原文

这篇文章: 我如何构建 Box2D 以在代码中工作::Blocks/Mingw32(Windows) 和此站点:http://www.transmissionzero.co.uk/computing/using-glut -with-mingw/ 对我尝试使用 MinGW GCC 工具链和 Gnu Make 构建器从 eclipse 中的源代码构建 Box2D 测试台有很大帮助,但我仍然遇到链接中未定义的引用错误阶段:

make all 
Building target: PhysInvent.exe
Invoking: MinGW C++ Linker
g++ -L../../PhysInvent/libs -o "PhysInvent.exe"  ./include/glui/algebra3.o ./include 
/glui/arcball.o ./include/glui/glui.o ./include/glui/glui_add_controls.o ./include
/glui/glui_bitmap_img_data.o ./include/glui/glui_bitmaps.o ./include 
/glui/glui_button.o 
./include/glui/glui_checkbox.o ./include/glui/glui_column.o ./include
/glui/glui_commandline.o ./include/glui/glui_control.o ./include/glui/glui_edittext.o 
./include/glui/glui_filebrowser.o ./include/glui/glui_list.o ./include
/glui/glui_listbox.o ./include/glui/glui_mouse_iaction.o ./include/glui/glui_node.o 
./include/glui/glui_panel.o ./include/glui/glui_radio.o ./include/glui/glui_rollout.o 
./include/glui/glui_rotation.o ./include/glui/glui_scrollbar.o ./include
/glui/glui_separator.o ./include/glui/glui_spinner.o ./include/glui/glui_statictext.o 
./include/glui/glui_string.o ./include/glui/glui_textbox.o ./include
/glui/glui_translation.o ./include/glui/glui_tree.o ./include/glui/glui_treepanel.o 
./include/glui/glui_window.o ./include/glui/quaternion.o  ./include/freeglut
/freeglut_callbacks.o ./include/freeglut/freeglut_cursor.o ./include/freeglut
/freeglut_display.o ./include/freeglut/freeglut_ext.o ./include/freeglut
/freeglut_font.o ./include/freeglut/freeglut_font_data.o ./include/freeglut
/freeglut_gamemode.o ./include/freeglut/freeglut_geometry.o ./include/freeglut
/freeglut_glutfont_definitions.o ./include/freeglut/freeglut_init.o ./include/freeglut
/freeglut_input_devices.o ./include/freeglut/freeglut_joystick.o ./include/freeglut
/freeglut_main.o ./include/freeglut/freeglut_menu.o ./include/freeglut/freeglut_misc.o 
./include/freeglut/freeglut_overlay.o ./include/freeglut/freeglut_spaceball.o ./include
/freeglut/freeglut_state.o ./include/freeglut/freeglut_stroke_mono_roman.o ./include
/freeglut/freeglut_stroke_roman.o ./include/freeglut/freeglut_structure.o ./include
/freeglut/freeglut_teapot.o ./include/freeglut/freeglut_videoresize.o ./include
/freeglut/freeglut_window.o  ./include/Box2D/Rope/b2Rope.o  ./include/Box2D/Dynamics
/Joints/b2DistanceJoint.o ./include/Box2D/Dynamics/Joints/b2FrictionJoint.o ./include
/Box2D/Dynamics/Joints/b2GearJoint.o ./include/Box2D/Dynamics/Joints/b2Joint.o 
./include/Box2D/Dynamics/Joints/b2MouseJoint.o ./include/Box2D/Dynamics/Joints
/b2PrismaticJoint.o ./include/Box2D/Dynamics/Joints/b2PulleyJoint.o ./include/Box2D
/Dynamics/Joints/b2RevoluteJoint.o ./include/Box2D/Dynamics/Joints/b2RopeJoint.o 
./include/Box2D/Dynamics/Joints/b2WeldJoint.o ./include/Box2D/Dynamics/Joints
/b2WheelJoint.o  ./include/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.o ./include
/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.o ./include/Box2D/Dynamics/Contacts
/b2CircleContact.o ./include/Box2D/Dynamics/Contacts/b2Contact.o ./include/Box2D
/Dynamics/Contacts/b2ContactSolver.o ./include/Box2D/Dynamics/Contacts
/b2EdgeAndCircleContact.o ./include/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.o 
./include/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.o ./include/Box2D/Dynamics
/Contacts/b2PolygonContact.o  ./include/Box2D/Dynamics/b2Body.o ./include/Box2D
/Dynamics/b2ContactManager.o ./include/Box2D/Dynamics/b2Fixture.o ./include/Box2D
/Dynamics/b2Island.o ./include/Box2D/Dynamics/b2World.o ./include/Box2D/Dynamics
/b2WorldCallbacks.o  ./include/Box2D/Common/b2BlockAllocator.o ./include/Box2D/Common
/b2Draw.o ./include/Box2D/Common/b2Math.o ./include/Box2D/Common/b2Settings.o ./include
/Box2D/Common/b2StackAllocator.o ./include/Box2D/Common/b2Timer.o  ./include/Box2D
/Collision/Shapes/b2ChainShape.o ./include/Box2D/Collision/Shapes/b2CircleShape.o 
./include/Box2D/Collision/Shapes/b2EdgeShape.o ./include/Box2D/Collision/Shapes
/b2PolygonShape.o  ./include/Box2D/Collision/b2BroadPhase.o ./include/Box2D/Collision
/b2CollideCircle.o ./include/Box2D/Collision/b2CollideEdge.o ./include/Box2D/Collision
/b2CollidePolygon.o ./include/Box2D/Collision/b2Collision.o ./include/Box2D/Collision
/b2Distance.o ./include/Box2D/Collision/b2DynamicTree.o ./include/Box2D/Collision
/b2TimeOfImpact.o  ./Tests/TestEntries.o  ./Framework/Main.o ./Framework/Render.o 
./Framework/Test.o  ./Box2dInventMain.o   -lBox2D -lfreeglut -lglui -lglu32 -lopengl32
./include/freeglut/freeglut_display.o:freeglut_display.c:(.text+0xa3): undefined 
reference to `SwapBuffers@4'
./include/freeglut/freeglut_init.o:freeglut_init.c:(.text+0x212): undefined reference 
to `timeEndPeriod@4'
./include/freeglut/freeglut_init.o:freeglut_init.c:(.text+0x437): undefined reference 
to `GetDeviceCaps@8'
./include/freeglut/freeglut_init.o:freeglut_init.c:(.text+0x44f): undefined reference 
to `GetDeviceCaps@8'
./include/freeglut/freeglut_init.o:freeglut_init.c:(.text+0x472): undefined reference 
to `timeBeginPeriod@4'
 ./include/freeglut/freeglut_joystick.o:freeglut_joystick.c:(.text+0x222): undefined 
reference to `joyGetDevCapsA@12'
./include/freeglut/freeglut_joystick.o:freeglut_joystick.c:(.text+0x78a): undefined 
reference to `joyGetPosEx@8'
./include/freeglut/freeglut_main.o:freeglut_main.c:(.text+0xcf): undefined reference 
to `timeGetTime@0'
./include/freeglut/freeglut_main.o:freeglut_main.c:(.text+0x127): undefined reference 
to `timeGetTime@0'
./include/freeglut/freeglut_main.o:freeglut_main.c:(.text+0x2d7): undefined reference 
to `timeGetTime@0'
./include/freeglut/freeglut_main.o:freeglut_main.c:(.text+0x4ec): undefined reference 
to `timeGetTime@0'
./include/freeglut/freeglut_main.o:freeglut_main.c:(.text+0x11c): undefined reference 
to `timeGetTime@0'
./include/freeglut/freeglut_state.o:freeglut_state.c:(.text+0x690): undefined 
reference to `GetPixelFormat@4'
./include/freeglut/freeglut_window.o:freeglut_window.c:(.text+0x303): undefined 
reference to `GetDeviceCaps@8'
./include/freeglut/freeglut_window.o:freeglut_window.c:(.text+0x31b): undefined 
reference to `ChoosePixelFormat@8'
./include/freeglut/freeglut_window.o:freeglut_window.c:(.text+0x432): undefined 
reference to `SetPixelFormat@12'
./include/freeglut/freeglut_window.o:freeglut_window.c:(.text+0x6b6): undefined 
reference to `SetPixelFormat@12'
collect2: ld returned 1 exit status
make: *** [PhysInvent.exe] Error 1

**** Build Finished ****

无论如何,我的库路径是相对的(../PhysInvent/libs),并且我引用的库列表按以下顺序排列:

Box2D (from libBox2D.a)
freeglut (from freeglut.dll which uses import library libfreeglut.a)
glui (from libglui.a)
glu32 (from the Windows system libs)
opengl32 (from the Windows system libs)

在我上面链接的另一个问题中,Pwngulator 指出“据我所知,无法使用MinGW(我相信你必须使用 Visual Studio)”这让我觉得很奇怪,因为源代码都存在;如果你有源代码,你不应该能够在任何地方用任何东西构建它吗?

有人使用 MinGW 在 eclipse 中成功构建了 Box2D 测试床吗?有人可以深入了解上面的链接器错误吗?

谢谢, CCJ

This post: How would I build Box2D to work in Code::Blocks/Mingw32(Windows) and this site: http://www.transmissionzero.co.uk/computing/using-glut-with-mingw/ have helped a lot in my attempts to build the Box2D testbed from source in eclipse using the MinGW GCC toolchain and the Gnu Make builder, but I'm still stuck with undefined reference errors in the link phase:

make all 
Building target: PhysInvent.exe
Invoking: MinGW C++ Linker
g++ -L../../PhysInvent/libs -o "PhysInvent.exe"  ./include/glui/algebra3.o ./include 
/glui/arcball.o ./include/glui/glui.o ./include/glui/glui_add_controls.o ./include
/glui/glui_bitmap_img_data.o ./include/glui/glui_bitmaps.o ./include 
/glui/glui_button.o 
./include/glui/glui_checkbox.o ./include/glui/glui_column.o ./include
/glui/glui_commandline.o ./include/glui/glui_control.o ./include/glui/glui_edittext.o 
./include/glui/glui_filebrowser.o ./include/glui/glui_list.o ./include
/glui/glui_listbox.o ./include/glui/glui_mouse_iaction.o ./include/glui/glui_node.o 
./include/glui/glui_panel.o ./include/glui/glui_radio.o ./include/glui/glui_rollout.o 
./include/glui/glui_rotation.o ./include/glui/glui_scrollbar.o ./include
/glui/glui_separator.o ./include/glui/glui_spinner.o ./include/glui/glui_statictext.o 
./include/glui/glui_string.o ./include/glui/glui_textbox.o ./include
/glui/glui_translation.o ./include/glui/glui_tree.o ./include/glui/glui_treepanel.o 
./include/glui/glui_window.o ./include/glui/quaternion.o  ./include/freeglut
/freeglut_callbacks.o ./include/freeglut/freeglut_cursor.o ./include/freeglut
/freeglut_display.o ./include/freeglut/freeglut_ext.o ./include/freeglut
/freeglut_font.o ./include/freeglut/freeglut_font_data.o ./include/freeglut
/freeglut_gamemode.o ./include/freeglut/freeglut_geometry.o ./include/freeglut
/freeglut_glutfont_definitions.o ./include/freeglut/freeglut_init.o ./include/freeglut
/freeglut_input_devices.o ./include/freeglut/freeglut_joystick.o ./include/freeglut
/freeglut_main.o ./include/freeglut/freeglut_menu.o ./include/freeglut/freeglut_misc.o 
./include/freeglut/freeglut_overlay.o ./include/freeglut/freeglut_spaceball.o ./include
/freeglut/freeglut_state.o ./include/freeglut/freeglut_stroke_mono_roman.o ./include
/freeglut/freeglut_stroke_roman.o ./include/freeglut/freeglut_structure.o ./include
/freeglut/freeglut_teapot.o ./include/freeglut/freeglut_videoresize.o ./include
/freeglut/freeglut_window.o  ./include/Box2D/Rope/b2Rope.o  ./include/Box2D/Dynamics
/Joints/b2DistanceJoint.o ./include/Box2D/Dynamics/Joints/b2FrictionJoint.o ./include
/Box2D/Dynamics/Joints/b2GearJoint.o ./include/Box2D/Dynamics/Joints/b2Joint.o 
./include/Box2D/Dynamics/Joints/b2MouseJoint.o ./include/Box2D/Dynamics/Joints
/b2PrismaticJoint.o ./include/Box2D/Dynamics/Joints/b2PulleyJoint.o ./include/Box2D
/Dynamics/Joints/b2RevoluteJoint.o ./include/Box2D/Dynamics/Joints/b2RopeJoint.o 
./include/Box2D/Dynamics/Joints/b2WeldJoint.o ./include/Box2D/Dynamics/Joints
/b2WheelJoint.o  ./include/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.o ./include
/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.o ./include/Box2D/Dynamics/Contacts
/b2CircleContact.o ./include/Box2D/Dynamics/Contacts/b2Contact.o ./include/Box2D
/Dynamics/Contacts/b2ContactSolver.o ./include/Box2D/Dynamics/Contacts
/b2EdgeAndCircleContact.o ./include/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.o 
./include/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.o ./include/Box2D/Dynamics
/Contacts/b2PolygonContact.o  ./include/Box2D/Dynamics/b2Body.o ./include/Box2D
/Dynamics/b2ContactManager.o ./include/Box2D/Dynamics/b2Fixture.o ./include/Box2D
/Dynamics/b2Island.o ./include/Box2D/Dynamics/b2World.o ./include/Box2D/Dynamics
/b2WorldCallbacks.o  ./include/Box2D/Common/b2BlockAllocator.o ./include/Box2D/Common
/b2Draw.o ./include/Box2D/Common/b2Math.o ./include/Box2D/Common/b2Settings.o ./include
/Box2D/Common/b2StackAllocator.o ./include/Box2D/Common/b2Timer.o  ./include/Box2D
/Collision/Shapes/b2ChainShape.o ./include/Box2D/Collision/Shapes/b2CircleShape.o 
./include/Box2D/Collision/Shapes/b2EdgeShape.o ./include/Box2D/Collision/Shapes
/b2PolygonShape.o  ./include/Box2D/Collision/b2BroadPhase.o ./include/Box2D/Collision
/b2CollideCircle.o ./include/Box2D/Collision/b2CollideEdge.o ./include/Box2D/Collision
/b2CollidePolygon.o ./include/Box2D/Collision/b2Collision.o ./include/Box2D/Collision
/b2Distance.o ./include/Box2D/Collision/b2DynamicTree.o ./include/Box2D/Collision
/b2TimeOfImpact.o  ./Tests/TestEntries.o  ./Framework/Main.o ./Framework/Render.o 
./Framework/Test.o  ./Box2dInventMain.o   -lBox2D -lfreeglut -lglui -lglu32 -lopengl32
./include/freeglut/freeglut_display.o:freeglut_display.c:(.text+0xa3): undefined 
reference to `SwapBuffers@4'
./include/freeglut/freeglut_init.o:freeglut_init.c:(.text+0x212): undefined reference 
to `timeEndPeriod@4'
./include/freeglut/freeglut_init.o:freeglut_init.c:(.text+0x437): undefined reference 
to `GetDeviceCaps@8'
./include/freeglut/freeglut_init.o:freeglut_init.c:(.text+0x44f): undefined reference 
to `GetDeviceCaps@8'
./include/freeglut/freeglut_init.o:freeglut_init.c:(.text+0x472): undefined reference 
to `timeBeginPeriod@4'
 ./include/freeglut/freeglut_joystick.o:freeglut_joystick.c:(.text+0x222): undefined 
reference to `joyGetDevCapsA@12'
./include/freeglut/freeglut_joystick.o:freeglut_joystick.c:(.text+0x78a): undefined 
reference to `joyGetPosEx@8'
./include/freeglut/freeglut_main.o:freeglut_main.c:(.text+0xcf): undefined reference 
to `timeGetTime@0'
./include/freeglut/freeglut_main.o:freeglut_main.c:(.text+0x127): undefined reference 
to `timeGetTime@0'
./include/freeglut/freeglut_main.o:freeglut_main.c:(.text+0x2d7): undefined reference 
to `timeGetTime@0'
./include/freeglut/freeglut_main.o:freeglut_main.c:(.text+0x4ec): undefined reference 
to `timeGetTime@0'
./include/freeglut/freeglut_main.o:freeglut_main.c:(.text+0x11c): undefined reference 
to `timeGetTime@0'
./include/freeglut/freeglut_state.o:freeglut_state.c:(.text+0x690): undefined 
reference to `GetPixelFormat@4'
./include/freeglut/freeglut_window.o:freeglut_window.c:(.text+0x303): undefined 
reference to `GetDeviceCaps@8'
./include/freeglut/freeglut_window.o:freeglut_window.c:(.text+0x31b): undefined 
reference to `ChoosePixelFormat@8'
./include/freeglut/freeglut_window.o:freeglut_window.c:(.text+0x432): undefined 
reference to `SetPixelFormat@12'
./include/freeglut/freeglut_window.o:freeglut_window.c:(.text+0x6b6): undefined 
reference to `SetPixelFormat@12'
collect2: ld returned 1 exit status
make: *** [PhysInvent.exe] Error 1

**** Build Finished ****

anyway, my library path is relative (../PhysInvent/libs) and my referenced library list is in the following order:

Box2D (from libBox2D.a)
freeglut (from freeglut.dll which uses import library libfreeglut.a)
glui (from libglui.a)
glu32 (from the Windows system libs)
opengl32 (from the Windows system libs)

In the other question I linked above, Pwngulator states "AFAIK, there is no way to compile the Testbed using MinGW (you have to use Visual Studio, I believe)" which strikes me as odd, since the source is all present; shouldn't you be able to build it anywhere with anything provided you have the source code?

Has anyone successfully built the Box2D testbed in eclipse using MinGW? Can someone please offer insight into the linker errors above?

thanks,
CCJ

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文