Hello again,
I'm in a bit of a quandary: having gone through a whole bunch of SDL tutorials I've finally made a game of Sobokan that not just compiles but works (!!!) so which I'm very proud of, so I want to share it. Trouble is it only runs from Codeblocks: the output file just throws up a blank screen (of the correct dimensions, but a blank screen none-the-less).
This problem seems to infect all the executables (if that's what you call them under Linux) created from projects that use the SDL_image library: they compile and run perfectly from the IDE but the executable (?) does nothing if run independently. Meanwhile the projects that don't use this library (the first tutorials before SDL_image was introduced) run fine from the executables found in Debug/Release.
William
PS - I'm officially terrified of posting on this board lest my self-confidence take another beating from the moderators ("obviously you are too stupid to use our software") :shock: Please God let this be on-topic...
Post the build log and someone on the site or the site that supports the library might be able to help.
http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F
The standard stuff needed for all questions:
Compiler name and version
Code::Blocks version or svn
OS Name and version
If this was on windows I would say you were missing a needed DLL in the exe folder;
but, Linux uses a different method IIRC.
Edit: I found this Googling may or may not apply
http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
Tim S.
Oops - sorry about that :? Coincidently the example was made using Codeblocks under Windows, so the executable (which I can run under wine) came with the required .dll s - I tried adding them to the same folder just to see what would happen but (unsurprisingly) there was no change...
Ubuntu 9.04
Codeblocks 8.02
GNU GCC Compiler 4:3.4.3-1ubuntu1
And here is the build log:
-------------- Build: Debug in Mario2 ---------------
gcc -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -Wall -g -c /home/william/Desktop/Documents/Programming/SDL/Mario2/files.c -o obj/Debug/files.o
gcc -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -Wall -g -c /home/william/Desktop/Documents/Programming/SDL/Mario2/main.c -o obj/Debug/main.o
gcc -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -Wall -g -c /home/william/Desktop/Documents/Programming/SDL/Mario2/make.c -o obj/Debug/make.o
/home/william/Desktop/Documents/Programming/SDL/Mario2/make.c: In function 'make':
/home/william/Desktop/Documents/Programming/SDL/Mario2/make.c:34: warning: missing curly brackets around initialiser
/home/william/Desktop/Documents/Programming/SDL/Mario2/make.c:34: warning: (near initialisation for 'map[0]')
gcc -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -Wall -g -c /home/william/Desktop/Documents/Programming/SDL/Mario2/play.c -o obj/Debug/play.o
/home/william/Desktop/Documents/Programming/SDL/Mario2/play.c: In function 'play':
/home/william/Desktop/Documents/Programming/SDL/Mario2/play.c:33: warning: missing curly brackets around initialiser
/home/william/Desktop/Documents/Programming/SDL/Mario2/play.c:33: warning: (near initialisation for 'map[0]')
g++ -o bin/Debug/Mario2 obj/Debug/files.o obj/Debug/main.o obj/Debug/make.o obj/Debug/play.o -L/usr/lib -lSDL -lSDL_image
Output size is 36.23 KB
Process terminated with status 0 (0 minutes, 2 seconds)
0 errors, 4 warnings
I haven't checked the "shared libraries" page yet, I'll do that now - just wanted to get the information out there as soon as possible
Thanks for the help :)
William
If you just use system-libraries (or libs from package installed correctly) they should be found.
If you have self-compiled libs you want to use, see the link Tim posted.
The compiled programs on linux are of course executables, because you can execute them (even if they have no file ending, linux works in a different way).
In your case I guess it's a problem with the paths to your images.
If you start your program from inside C::B look in your build-log how C::B does it.
It should look like:
Checking for existence: /tmp/test/bin/Release/test
Executing: /tmp/test/bin/Release/test (in /tmp/test/.)
Now open a console and switch to /tmp/test and type /tmp/test/bin/Release/test to see if it works now.
You have to use your paths of course and not mine.
Gotcha
Checking for existence: /home/william/Desktop/Documents/Programming/SDL/Mario2/bin/Debug/Mario2
Executing: xterm -T Mario2 -e /usr/bin/cb_console_runner /home/william/Desktop/Documents/Programming/SDL/Mario2/bin/Debug/Mario2 (in /home/william/Desktop/Documents/Programming/SDL/Mario2/.)
So go here:
/home/william/Desktop/Documents/Programming/SDL/Mario2/
and execute:
xterm -T Mario2 -e /usr/bin/cb_console_runner /home/william/Desktop/Documents/Programming/SDL/Mario2/bin/Debug/Mario2
That seems to have worked perfectly, and I can always make a bash script to run it. Is there any way of simplifying the process though?
William
You can move the executables and dynamic libs (.so) to the root of you project:
project -> properties -> build targets
Quote from: oBFusCATed on October 06, 2009, 07:48:57 PM
You can move the executables and dynamic libs (.so) to the root of you project:
project -> properties -> build targets
Hang on, so the image files aren't actually part of the executable, they need to be in the same folder as it to run? I probably should have tried that first... Sorry guys :shock:
Put them all together and it works like magic - hurrah!
Thanks for the help, even if it was a really dumb question as it turns out :)