User forums > Using Code::Blocks

Code::Blocks don't finds my SDL2 libs

(1/2) > >>

moevenbaer:
Hello to the CB-World,
after some days searching and learning and searching and ... my brain is a little bit confused about that all.  ;)

System: Win 11 - get error linking SDL2-libs:
 ld.exe   can't find -llibSDL2
 ld.exe   can't find -llibSDL2main

I didn't find out what is wrong here in my steps:

* C:\CODEBLOCKS\ is my folder for all stuff
* C:\CODEBLOCKS\Codeblocks is installation folder of codeblocks with MinGW in there.
* Copied content of zip file "codeblocks-20.03mingw-nosetup.zip" to this CodeBlocks installation folder
* Copied folder SDL2 from SDL2-devel-2.30.3-mingw.zip folder SDL2 found under  SDL2-2.30.3\include to C:\CODEBLOCKS\Codeblocks\MinGW\include\
* Copied content from lib folder found in SDL2-devel-2.30.3-mingw.zip under  SDL2-2.30.3\lib to C:\CODEBLOCKS\Codeblocks\MinGW\lib\
* Created a console project for c++ in workspace folder C:\CODEBLOCKS\CB_WSp\
* Build and went ok (Returncode zero)
* Added compiler path C:\CODEBLOCKS\Codeblocks\MinGW\include\
* Added linker path C:\CODEBLOCKS\Codeblocks\MinGW\lib\
* Added the test code from the SDL2.0 project template with the #include <SDL2/SDL.h>
* In allmost tutorials there is spoken about linker options -lSDL2 -lSDL2main to added to the lib, but there isn't any.
So I decided using -llibSDL2 and -libSDL2main for the other linker options.What I'm thinking wrong? What did I forgot or not know?
Greetings from Germany
Ekkehard

stahta01:
Important FAQ https://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

Most GCC Mingw compilers add the lib before library names; therefore adding the lib before the library name sometimes can cause issues.

moevenbaer:
Thanks. Looks not to be the reason.
To fullfill the "How to post ..." I will answer later again. I'm tried to test SDLs i686 subfolders as told in different posts and videos setting up sdl2 with codeblocks around the internet. In the build logs I found that there are x86_64 folder is userd by MinGW. So I will test the subfolders for x86_64. So long until later.
Ekkehard
P.S. But this (prepending lib to libname) happens in codeblocks/MinGW-Compilers too.

moevenbaer:
So here is my promised reply:
I am running Code::Blocks release 20.03 - rev 11983 (2020-03-12 18:24:30) - gcc 8.1.0 Windows/unicode - 64 bit on Windows 11 Home(version 23H2 build 22631.3593). The compiler I use is build in MinGW.

When I ...
In my first problem I tried to buil this from scratch. With no success. But now I build the normal SDL2.0 project.
When it ask for the includ/lib folder with shown $(#sdl2) in the input line, I replaced it with the full paath to MinGW inside codeblocks installation folder.
The lib and the include folder fom the SDL2 devel file I copied earlier to there. The include directive for SDL.h I updated to SDL2/SDL.h.
... the following happens ...
The building tells the following build messages.

--- Code: ---||=== Build: Debug in SDL2TestA (compiler: GNU GCC Compiler) ===|
ld.exe||cannot find -lSDL2main|
ld.exe||cannot find -lSDL2.dll|
||error: ld returned 1 exit status|
||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|

--- End code ---
and the later following build log.
Messing around with the files I found the project xml file and in there at the end the overwritten $(#sdl2). Setting this to the ame folder as inputted, the things went well.
All though the from the scratch version I'm not able to build.

So my question changes a little bit:
How and where shell I set the macro variable for $(#sdl2) in the project (or better codeblocks?) settings?

Build log:

--- Code: ----------------- Build: Debug in SDL2TestA (compiler: GNU GCC Compiler)---------------
g++.exe -Wall -g -IC:\CODEBLOCKS\CodeBlocks\MinGW\include -c C:\CODEBLOCKS\CB_WSp\SDL2TestA\main.cpp -o obj\Debug\main.o
g++.exe -LC:\CODEBLOCKS\CodeBlocks\MinGW\lib -o bin\Debug\SDL2TestA.exe obj\Debug\main.o   -lmingw32 -lSDL2main -lSDL2.dll -luser32 -lgdi32 -lwinmm -ldxguid
C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\CODEBLOCKS\CodeBlocks\MinGW\lib/libSDL2main.a when searching for -lSDL2main
C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\CODEBLOCKS\CodeBlocks\MinGW\lib\libSDL2main.a when searching for -lSDL2main
C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../lib/libSDL2main.a when searching for -lSDL2main
C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../lib\libSDL2main.a when searching for -lSDL2main
C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../libSDL2main.a when searching for -lSDL2main
C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../..\libSDL2main.a when searching for -lSDL2main
C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\CODEBLOCKS\CodeBlocks\MinGW\lib/libSDL2main.a when searching for -lSDL2main
C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../lib/libSDL2main.a when searching for -lSDL2main
C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../libSDL2main.a when searching for -lSDL2main
C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL2main
C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\CODEBLOCKS\CodeBlocks\MinGW\lib/libSDL2.dll.a when searching for -lSDL2.dll
C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\CODEBLOCKS\CodeBlocks\MinGW\lib\libSDL2.dll.a when searching for -lSDL2.dll
C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../lib/libSDL2.dll.a when searching for -lSDL2.dll
C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../lib\libSDL2.dll.a when searching for -lSDL2.dll
C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../libSDL2.dll.a when searching for -lSDL2.dll
C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../..\libSDL2.dll.a when searching for -lSDL2.dll
C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\CODEBLOCKS\CodeBlocks\MinGW\lib/libSDL2.dll.a when searching for -lSDL2.dll
C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../lib/libSDL2.dll.a when searching for -lSDL2.dll
C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../libSDL2.dll.a when searching for -lSDL2.dll
C:/CODEBLOCKS/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL2.dll
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 1 second(s))
3 error(s), 0 warning(s) (0 minute(s), 1 second(s))

--- End code ---

stahta01:
You need to stop doing the things you have done! MIXING 32 and 64 bit DOES NOT WORK!

You need to decide what you wish to do!

1. Do you wish to build using 64 bit or 32 bit?
2. Find an compiler or library that matches the bit size you wish to use?
3. Now find either a compiler or library to match the choice in 2?
Note: You can just choose a compiler in step 2 and the build the SDL2 library using that compiler.

Me, assuming windows 10 [or 11] 64 bit, I would install MSys2 MINGW64 GCC and SDL2 and use that for questions 1 to 3.
It [Msys2 SDL2] will take work; but, I can likely help you figure out how to get a simple example to build.

Tim S.

Navigation

[0] Message Index

[#] Next page

Go to full version