Linking with MinGW and Code::blocks

Official forum for the Chipmunk2D Physics Library.
Post Reply
nirwin
Posts: 2
Joined: Fri Aug 29, 2008 11:00 am
Contact:

Linking with MinGW and Code::blocks

Post by nirwin »

Hello,

I recently decided to use a physics library instead of writing my own basic implementation. Chipmunks looks to be just the job, so I downloaded it and tried to get it integrated. The project I am trying to integrate with is a c++ project, being built with MinGW (g++) and Code::Blocks IDE, I have chosen these two tools because I want the application to be cross-platform as these tools are.

So I made a project for building chipmunks, I set the 'type' to static library, and also had to add the "-std=c99" flag to get the compiler to like it. So this then manages to build the project and produce:
chipmunk.o
cpArbiter.o
... (the rest)
cpVect.o

and
libChipmunk.a

So this seems to be fine for chipmunks, so the next step is to integrate it into my existing project.
So I open the "Project Build Settings" and under the "Search Directories->Linker" tab I add the directories that the *.o (obj), and *.a (lib) files live in. I also added these two directories to the "Search Directories->Resource Compiler" tab in case this was necessary (doubt it).
Also in the "External Dependencies" window of the project settings, I add each of the .o files and the .a file.

Now onto the file where I try to invoke cpInitChipmunk(). I use the #include "chipmunk.h" command to include the file and in a function I call cpInitChipmunk();, when I compile this file, I get one warning: "warning: INFINITY_HACK defined but not used" and no errors.
However when I build, I get:
Compiling: types\CVector2D.cpp
Linking executable: C:\programming\jimmy2d\Debug\jimmy2d.exe
Debug\engine\CGameController.o: In function `ZSt38__copy_backward_output_normal_iteratorIPP22CGameCharacterAbstractN9__gnu_cxx17__normal_iteratorIS2_St6vectorIS1_SaIS1_EEEEET0_T_SA_S9_11__true_type':
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_algobase.h:(.text+0xbe): undefined reference to `cpInitChipmunk'
Debug\engine\CGameController.o: In function `ZN15CGameControllerC1EP13output_driver':
C:/programming/jimmy2d/engine/CGameController.cpp:21: undefined reference to `cpInitChipmunk'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 11 seconds)
2 errors, 14 warnings
which looks to me like the Linker can't find the Chipmunk library, but given all the dependencies and linker directories I have set up, I can't see why. Anyone have any ideas?

Sorry, if this seems dumb/not relevant to chipmunks, but I am not too practiced at including external libraries and am new to Code::blocks as well, and I would really love to get chipmunks working.

---UPDATE---
Since nobody seemed to know the solution to this one, I thought I'd post it in the hope that it saves someone else a headache.

It was just my lack of knowledge with Code::blocks in the end. I had to go to the "Linker settings" tab in the Project->"Build Options" dialog and add the term "chipmunks" to the "Link libraries" list.
That made the linker use the chipmunks library and all was well.

Now to get stuck into chipmunks.
Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests