Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: CSoldier on February 26, 2006, 04:22:13 pm

Title: C Langage: SDL Projetcs does not compile !
Post by: CSoldier on February 26, 2006, 04:22:13 pm
Hello,

I installed Code::Blocks under Windows XP SP2, I would like to know how I can create a SDL project in C Language AND which is compiled with a "C" compiler and not MingW-g++ but rather MingW-GCC for example !

I installed SDL myself because I have not found a installer of files of development and runtime.
The headers files is in the repertory "...\include\SDL\" and the libs in "...\lib\" of the repertory of C::B.

Here the error of compilation with the default SDL project (C++) - (just for testing but I want e C/SDL project):
Code
Project   : SDL Application
Compiler  : GNU GCC Compiler (called directly)
Directory : C:\Documents and Settings\Franck\Mes documents\sdlapp\
--------------------------------------------------------------------------------
Switching to target: default
Linking console executable: SDLapp.exe
..\..\..\..\Program Files\CodeBlocks\lib\SDLmain.lib(./Release/SDL_win32_main.obj):C:\SDL-1.2.9\Src\M:(.text[_main]+0x0): multiple definition of `main'
C:\Program Files\CodeBlocks\lib/libmingw32.a(main.o):main.c:(.text+0x0): first defined here
Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized
..\..\..\..\Program Files\CodeBlocks\lib\SDLmain.lib(./Release/SDL_win32_main.obj):C:\SDL-1.2.9\Src\M:(.text[_main]+0x55): undefined reference to `_alloca_probe'
..\..\..\..\Program Files\CodeBlocks\lib\SDLmain.lib(./Release/SDL_win32_main.obj):C:\SDL-1.2.9\Src\M:(.text[_main]+0xc8): undefined reference to `SDL_SetModuleHandle'
..\..\..\..\Program Files\CodeBlocks\lib\SDLmain.lib(./Release/SDL_win32_main.obj):C:\SDL-1.2.9\Src\M:(.text[_WinMain@16]+0x162): undefined reference to `_alloca_probe'
..\..\..\..\Program Files\CodeBlocks\lib\SDLmain.lib(./Release/SDL_win32_main.obj):C:\SDL-1.2.9\Src\M:(.text[_WinMain@16]+0x1a5): undefined reference to `_alloca_probe'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 1 warnings


Thanks for all !
Title: Re: C Langage: SDL Projetcs does not compile !
Post by: TDragon on February 26, 2006, 04:38:52 pm
Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized
Firstly, it seems some MSVC commands are getting mixed up in your GCC command line. To troubleshoot this, change Compiler logging to "Full command line" in the Other tab of your global compiler settings. This will show the full command line being used to compile. You may need to create an entirely new project and add your files to it to fix this issue.

Secondly, you appear to be using the MSVC version of the SDL devel library. While GCC has limited support for MSVC libraries and object files, there are enough important differences that you would be better off downloading the MinGW32 devel package (SDL-devel-1.2.9-mingw32.tar.gz (http://www.libsdl.org/release/SDL-devel-1.2.9-mingw32.tar.gz)).

Thirdly, if you aren't already using one of the C::B nightly builds, switch now (http://forums.codeblocks.org/index.php?topic=2469.0)! They are much more feature rich and lack most of RC2's annoying bugs. (You will need to install MinGW (http://www.mingw.org/) separately, preferably using the new 5.0.2 installer.)
Title: Re: C Langage: SDL Projetcs does not compile !
Post by: CSoldier on February 26, 2006, 05:36:35 pm
Ok, it's better  :D Thank you... !

Last question... By creating my personnal template for a SDL project in C Language, how I makes to specify that the compiler must be a C compiler and not C++ ?  Or that's done automatically compared to the extension of the files ?
Title: Re: C Langage: SDL Projetcs does not compile !
Post by: TDragon on February 26, 2006, 08:44:37 pm
Or that's done automatically compared to the extension of the files ?
Indeed. :)
Title: Re: C Langage: SDL Projetcs does not compile !
Post by: CSoldier on February 26, 2006, 11:54:49 pm
Ok  :P Thanks, that functions impeccably well   :P :P