这篇文章:我如何构建 Box2D 以在 Code::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 声明“AFAIK,没有办法使用 MinGW 编译测试平台(我相信你必须使用 Visual Studio)”这让我觉得很奇怪,因为源都存在;只要你有源代码,你不应该可以在任何地方构建它吗?
有没有人使用 MinGW 在 Eclipse 中成功构建了 Box2D 测试平台?有人可以提供对上述链接器错误的见解吗?
谢谢,CCJ