The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Code Blocks problem with SDL
GoldSpark


Joined: 01 Jul 2015
Posts: 4
Ok so I have set up code blocks for SDL in my flash drive and it is working perfectly. Now i've created new project in destkop folder and set it up the same way. When I click build it says G:\Luka\SDL2-2.0.3\lib\x86\SDL2main.lib(.\Release\SDL_windows_main.obj)(.text[_ShowError]+0x12)||undefined reference to `_imp____iob_func'|


Or sometimes ID.exe has crashed. :/
MrTAToad


Joined: 13 Feb 2014
Posts: 205
Location: Chichester, England
Are you trying to use the Visual Studio libraries with CodeBlocks ? If you are, and you aren't using the Visual Studio compiler then you have to use the GCC libraries.
Lemonhead


Joined: 27 Jun 2015
Posts: 7
Unfortunately I don't know how to solve your exact problem, but I know how to avoid it, perhaps. Just use a makefile and tell Code::Blocks the location. Using this method, it still shows all the files, runs, debugs, and does everything an IDE is supposed to do, so I don't really see any downside.
GoldSpark


Joined: 01 Jul 2015
Posts: 4
No i am not using visual studio files... How do I do that Lemonhead?
Lemonhead


Joined: 27 Jun 2015
Posts: 7
This is just one way to do it, but it has been working for me so far on linux. (I still can't get Android working, but it uses a whole separate build system.) I have this makefile in the project folder with flak.cpb. My source files are in "src" and binaries get sent to "bin". My game is named "flak" but you can overwrite that.

Code:

# Makefile for Linux target

SRC = $(wildcard src/*.cpp)

CC = clang++

COMPILER_FLAGS = -Wall -std=c++11 -Wwrite-strings -lm -Wdeprecated-writable-strings -Isrc

RELEASE_FLAGS = -O3 $(COMPILER_FLAGS)

DEBUG_FLAGS = -O1 -g $(COMPILER_FLAGS)

LINKER_FLAGS = -lSDL2 -lSDL2_mixer

RELEASE_OBJ_NAME = bin/flak

DEBUG_OBJ_NAME = bin/flak-debug

Release : $(SRC)
   $(CC) $(SRC) $(RELEASE_FLAGS) $(LINKER_FLAGS) -o $(RELEASE_OBJ_NAME)

Debug : $(SRC)
   $(CC) $(SRC) $(DEBUG_FLAGS) $(LINKER_FLAGS) -o $(DEBUG_OBJ_NAME)


I'm using clang++, but you can change it to some other, like gcc or g++ if you want.

Then in Code::Blocks, under Projects->Properties, set:

- Makefile: "makefile"
- This is a custom makefile: Check
- Execution directory: "bin"

Under the Build Targets tab, I also set my debug target to "bin/flak-d" and release to "bin/flak".
Lemonhead


Joined: 27 Jun 2015
Posts: 7
Correction: "bin/flak-debug" not "bin/flak-d"
GoldSpark


Joined: 01 Jul 2015
Posts: 4
Problem is fixed. I have been using wrong directory in linker options... :/
GoldSpark


Joined: 01 Jul 2015
Posts: 4
Thank you all for your assistance!
MrTAToad


Joined: 13 Feb 2014
Posts: 205
Location: Chichester, England
No problem!