Code::Blocks "SDL2.dll not found"

Started by
4 comments, last by Acharis 10 years, 2 months ago

I have a slight configuration problem with Code::Blocks. My old SDL1.2 is configured nicely, it uses dlls from the SDL bin folder. But for some reason I can't configure SDL 2.0 the same way and I need to manually copy dlls to the project folder (I don't want to drop these to the system folder, want to contain this within Code::Block and projects environment).

I can't find any difference between my SDL 1.2 and SDL 2.0 configuation, I must be missing something...

I attached a screenshot with all steps I took.

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

Advertisement

Are you sure you didn't have another copy of SDL 1.2's dll in your system folder which is in the system path variable?

If you do want to change your working directory though, it should be project->properties->build target->[name]->execution working directory. Execution working directory looks like it's on your last screenshot there.

I have a slight configuration problem with Code::Blocks. My old SDL1.2 is configured nicely, it uses dlls from the SDL bin folder. But for some reason I can't configure SDL 2.0 the same way and I need to manually copy dlls to the project folder (I don't want to drop these to the system folder, want to contain this within Code::Block and projects environment).

I can't find any difference between my SDL 1.2 and SDL 2.0 configuation, I must be missing something...

I attached a screenshot with all steps I took.

I've attached an SDL2 project wizard to this reply. Tested on Windows 8 Pro x64 with stock installs of Code::Blocks 13.12, MinGW32 and SDL2 2.0.1 - I suppose it works on Linux as well since sdl2-config is mentioned in the wizard, but I didn't test (look at the edit below).

How to install on Windows:
1) Make a backup copy of C:\Program Files (x86)\CodeBlocks\share\CodeBlocks\templates\wizard\config.script because it will be overwritten.
2) Unzip the attached file to C:\Program Files (x86)\CodeBlocks\share\CodeBlocks\templates
3) Done. Now when creating a new project, the "SDL2 project" template is available.

Details:
1) The template only assumes that stock SDL2 is installed, and only links against SDL2main and SDL2.dll - in other words, if you are using SDL2_image, SDL2_mixer, SDL2_net, or SDL2_ttf, you'll have to manually add those to the Linker settings/Link libraries under Build options.
2) The template includes a post-build step that copies the SDL2 DLLs to the output folder - in other words, you can run the project directly after building. There's no need to copy the DLLs to the output folder nor to any other folder in your PATH. I suppose this solves the problem you reported.

EDIT: Just tested it on Code::Blocks 12.11 on Debian Wheezy 32-bit with libsdl2-dev from wheezy-backports, and it worked.

How to install on Debian Wheezy 32-bit (I suppose it's not all that different on other distros):
1) Make a backup copy of /usr/share/codeblocks/templates/wizard/config.script because it will be overwritten.
2) Unzip the attached file to /usr/share/codeblocks/templates
2.5) If you're really picky, convert the line endings of /usr/share/codeblocks/templates/wizard/config.script using e.g. dos2unix
3) Done. Now when creating a new project, the "SDL2 project" template is available.


Are you sure you didn't have another copy of SDL 1.2's dll in your system folder which is in the system path variable?

If you do want to change your working directory though, it should be project->properties->build target->[name]->execution working directory. Execution working directory looks like it's on your last screenshot there.
No, It's not that I have SDL.dll installed (the same story is with SDL_TTF and SDL_Mixer I don't need to copy these when running a SDL1.2 project but have to copy them for SDL2 project.

The "execution working directory" in my SDL1.2 project is ".", it's the same for SDL2 project.


2) The template includes a post-build step that copies the SDL2 DLLs to the output folder
Well... you mean it will physically copy all dlls to the project folder after compiling? Not "link them without copying"? I wanted to make it like my SDL1.2 which requires no copying at all.

Well, it's not a big problem, but still I'm curious, why SDL1.2 and SDL2 setup behave so different...

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

Your SDL exe works without the .dll in either the system nor its directory?

It looks like you are using static linkage on SDL1 and shared on SDL2.

If you were not linking SDL 1 statically, I really don't understand how it could work without the dll in the folder, system or PATH.

You can use a loader application, one that handles the path for your dll, or one that actually calls your true executable from, say, a separated bin folder, that has your dll.


Your SDL exe works without the .dll in either the system nor its directory?
Yes. But only if run via Code::Blocks (it seems to be getting these from the directory specified by the global variables). The thing is, I have set the global variables the same way (at least it seems that way to me) for SDL2 and I can't get the same effect....


a separated bin folder, that has your dll
With the old SDL 1.2 it gets these from the bin folder of my libraries. With SDL2 I can't make it do it.

Again, I'm talking ONLY about Code::Blocks environment. It would be not posible for the final release version.

Or maybe Code::Blocks have set up PATH for the old SDL1.2? And when I tried to manually add SDL2.0 I missed that step somehow? (althrough I don't know how, even through I used the SDL template I needed to add TTF and mixer manually, so it should not work for that one...)

It's driving me crazy, the mystery why this setup of SDL 1.2 and 2.0 behaves so different :D

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

This topic is closed to new replies.

Advertisement