Problem compiling with CodeBlocks

79 views
Skip to first unread message

Brian Tacker

unread,
Apr 3, 2014, 8:15:45 PM4/3/14
to freer...@googlegroups.com
I noticed other people have been able to get the project to compile with CodeBlocks but I just cant seem to get it working. I'm able to compile through terminal but I want to do some tinkering.
I am trying to compile under Linux and Windows with the same results. I just get a bunch of "undefined reference" messages:


Im using GCC compiler on both machines and still same results.

Any help would be appreciated.



Doctor J

unread,
Apr 3, 2014, 9:30:43 PM4/3/14
to freer...@googlegroups.com
If it compiles and runs ok via terminal commands then you must have all the proper libraries installed. Then its just a matter of setting up the project within CodeBlocks to access those libraries. It is common to set up two build targets: a "Debug" version as a console application and a "Release" version as a GUI application. For my system, I specified the libraries to link to under Project : Build Options : Linker Settings; add the entries: SDL2 and SDL2_tff. Under Project : Build Options : Search Directories : Compiler, point to where the SDL2 include files are on your system (in my case : /usr/include/SDL2.) Under Project : Build Options : Search Directories : Linker point to the library binaries (in my case : /usr/lib64.)

Brian Tacker

unread,
Apr 4, 2014, 12:25:19 AM4/4/14
to freer...@googlegroups.com
Originally I didn't have the files as part of a project, I was just building from freerct.cpp. I created a new project in CodeBlocks and added the src files and now Im just getting undefined reference to SDL functions (e.g. SDL_PollEvent(), SDL_GetTicks(), etc). 
I had already added /usr/include/SDL2 to the search directories. I tried adding the SDL2 and SDL2_ttf entries to the linker settings like you mentioned and wasn't really sure what to choose, so I chose libSDL2.a and SDL2_ttf.a. Is that correct? Because after doing that I get the same results. Also my machine doesn't have a /usr/lib64 directory, just /lib64 and /usr/lib. I added both to the Search Directories : Linker and still the same results. Any Clue?
Thanks for the help.

Doctor J

unread,
Apr 4, 2014, 12:50:52 AM4/4/14
to freer...@googlegroups.com
It is a good idea to inspect the directories with a file manager and make sure which directory has the binaries. Also, the SDL library and the compiler must be the same bit width (32 vs 64) or it will not understand the library, even though it is there and valid otherwise.

Lord Aro

unread,
Apr 4, 2014, 7:23:59 AM4/4/14
to freer...@googlegroups.com
You should be able to use cmake to generate Codeblocks project files: http://www.cmake.org/Wiki/CMake_Generator_Specific_Information#Code::Blocks_Generator

Brian Tacker

unread,
Apr 4, 2014, 11:41:56 AM4/4/14
to freer...@googlegroups.com
That worked perfectly, now I can build and run directly from CodeBlocks, Thanks!
Reply all
Reply to author
Forward
0 new messages