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.
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.
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.
No i am not using visual studio files… How do I do that Lemonhead?
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.
# 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”.
Correction: “bin/flak-debug” not “bin/flak-d”
Problem is fixed. I have been using wrong directory in linker options…
Thank you all for your assistance!