I Need Help Again With Code::blocks And Sdl Setup

Started by
4 comments, last by Kylotan 7 years, 8 months ago
I'm setting up Code::Blocks and SDL on another computer at a family member's house. I'm following the Lazy Foo tutorial and I'm being careful not to make the mistakes that I made earlier in the year. For a start, I'm using SDL 2 not SDL 1.2, and I've got the version that comes as a tarball (even though this is for Windows 10 - this is what Lazy Foo recommends). I've tinkered around some more, hoping to fix the problem but I still get the same error. I will be very clear: I used the i686* (32 bit) version and I am linking the .a files to the linker settings, and the include directory gets linked to the compiler.

*I searched this online to confirm that i686 is definitely 32 bit.

I still get the most basic error:

||=== Build: Debug in testempty (compiler: GNU GCC Compiler) ===|
ld.exe||cannot find -lSDL2main|
ld.exe||cannot find -lSDL2|
||error: ld returned 1 exit status|
||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
.
I've checked everything and supposedly the error (according to lazy foo) is that the linker or compiler can't find the files and folders. I'm linking right into those folders - the linker points to the .a files, and the compiler settings point straight to include/SDL2 where all the .h files are. What could possibly be wrong? I even made sure that the files and folders were not "read only" just in case.
Logging in from unsecured wireless, I hope no-one steals my password (October 22, 2016)
Advertisement
I've checked everything

If there is an error, then you haven't checked everything. Happens to me all the time, don't worry.

You need 4 things to get it working. Check what you've missed from the stuff below.

1.Tell the compiler where the headers are.

2.Tell the compiler where the libs are.

3.Link against the libs.

4.Copy all .dll files into your project folder.

5.Done.

I get different errors depending on what exactly I point to. If I point to ./include/SDL the error "cannot find project_name/.objs/input.o". Alternatively, if I just point the compiler to ./include without its subfolder, it says I'm missing SDL.h. Either way I'm stuck. I think I'll wait 2 weeks until I move house and then I'll install Fedora. It's so easy to get SDL working under Linux. Just search the repository and install everything with "sdl" and "dev" in its name, and then it works!

Installing Linux to solve this problem is akin to killing a fly with a nuclear bomb... but at least it works. It's also possible that my download was corrupted. I had better check that possibility first.

Logging in from unsecured wireless, I hope no-one steals my password (October 22, 2016)

I think I have solved the problem. The trick is to find "search directories". Under that there is settings for linker and compiler. This "search directories" is the only thing you need to fill in, besides "other compiler options" which is -lmingw32 -lSDL2 -lSDL2main. I suspect the issue is that I pointed the linker straight to the .a files and the compiler to the INCLUDE directory. That didn't work; The good settings on my main system point to the root SDL folder, which has INCLUDE and LIB as sub folders. If I point to that root directory in the "search directories" tab that should make it work. I'll confirm it, and if correct I will email Lazy Foo because his suggestion didn't work in my scenario. Once I move house I'll make my own SDL 2 tutorial on my website, and add my own tips.

Logging in from unsecured wireless, I hope no-one steals my password (October 22, 2016)

aha!

I went to the Code::Blocks forum and searched SDL and found heaps of people with the same problem. The best way to get SDL configured, is to use the wizard... but it usually has a problem finding the right directory. The stupid script is always out of date - it can be edited though. When creating a new project you can right-click SDL Project and select "edit script". I have an account on the Code Blocks forum now, so I'll ask all my questions there!

Here's the screenshot:

editscript.png

Update: I'm able to edit the SDL script and make it find SDL2.dll instead of SDL.dll there's a lot wrong with the default script. The other problem is when it searches for SDLmain.lib and SDLmain.a when again, it should be SDL2 not SDL!

and also sorry but...

thread_necromancy.jpg

Logging in from unsecured wireless, I hope no-one steals my password (October 22, 2016)

Never apologise for necro-ing a thread if you've come back to post the answer. :)

This topic is closed to new replies.

Advertisement