cannot find -lSDL2

General FreeBASIC programming questions.
BasicCoder2
Posts: 2819
Joined: Jan 01, 2009 7:03

cannot find -lSDL2

Postby BasicCoder2 » Aug 21, 2017 0:43

So I downloaded SDL2 via,
viewtopic.php?t=21725

================================================================================================
Command executed:
"C:\FreeBasic\fbc.exe" "C:\FreeBasic\SDL_PROGRAMS\FB-SDL-2.0.1.b\FB-SDL-2.0.1\examples\graphics\SDL2\showimage.bas"

Compiler output:
C:\FreeBasic\bin\win32\ld.exe: cannot find -lSDL2
C:\FreeBasic\bin\win32\ld.exe: cannot find -lSDL2_image

Results:
Compilation failed

System:
FBIde: 0.4.6
fbc: FreeBASIC Compiler - Version 1.05.0 (01-31-2016), built for win32 (32bit)
OS: Windows NT 6.2 (build 9200)
===============================================================================================

I did a file search for -lSDL2 and -lDSL2_image without success.

I recognize them from a failed attempt to set up SDL2 with code::blocks

Google search result,
Your search - -lSDL2 - did not match any documents.

Can anyone tell me what are they and where are they?

.
MrSwiss
Posts: 1928
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: cannot find -lSDL2

Postby MrSwiss » Aug 21, 2017 0:51

BasicCoder2 wrote:C:\FreeBasic\bin\win32\ld.exe: cannot find -lSDL2
SDL2.dll
BasicCoder2 wrote:C:\FreeBasic\bin\win32\ld.exe: cannot find -lSDL2_image
SDL2_image.dll

-l --> Linker message (FB's Linker: ld.exe)
You'll have to download them from: SDL website.

You might also need: SDL2.dll.a (export-/import-library), as well as:
SDL2_image.dll.a
(export: from dll's point of view / import: from FB's point of view)

Applies to all other dll's too, irrespective of what the dll is for.
BasicCoder2
Posts: 2819
Joined: Jan 01, 2009 7:03

Re: cannot find -lSDL2

Postby BasicCoder2 » Aug 21, 2017 19:11

MrSwiss wrote:You'll have to download them from: SDL website.


Like I say it is a chore finding and figuring stuff out.
On the SDL2 site there are two files.
I assume it is the MinGW required? One is a .zip and the other .tar.gz?
I assume the .tar.gz covers more than just the Visual C++ compiler.

Development Libraries:
Windows
SDL2_image-devel-2.0.1-VC.zip (Visual C++ 32/64-bit)
SDL2_image-devel-2.0.1-mingw.tar.gz (MinGW 32/64-bit)


I downloaded the tar.gz version and a WinOpener window appeared.
I selected the folder to download to and then up pops an advertisement,
with, Recommended App driver update.
next I find myself on a website offering Opener Plus for $7.39
So I deleted the stupid WinOpener with it stupid GUI.
A lot of sites offering the dll downloads play the same tricks. No dll just their special programs to "fix dll problems".

I couldn't find any .dll's when I downloaded the .zip version in the Development Libraries section.

Eventually found web pages with the .dlls taking a risk of getting a virus with a download.
The programs now compile.

Thanks for the input I wouldn't have realized that the -lsld2 meant it couldn't find the .dll as the compiler fails to give solutions to errors. Do X without saying what X is. Or in this case problem X without saying what X is or how to fix it.

Now I will have to do some SDL2 tutorials to see how hard it is to use.
.
badidea
Posts: 544
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: cannot find -lSDL2

Postby badidea » Aug 21, 2017 20:12

BasicCoder2 wrote:Like I say it is a chore finding and figuring stuff out.

Sometimes, linux is a lot easier:
Image
sancho2
Posts: 547
Joined: May 17, 2015 6:41

Re: cannot find -lSDL2

Postby sancho2 » Aug 21, 2017 21:54

This is an example of how to write a tutorial.
I followed along to the first hello world program and it was step for step, and left no mysteries.
It is for C++ however so take it for what its worth.
If the first couple of lessons are any indication, then I think it still might help you in using SDL here in FB.
BasicCoder2
Posts: 2819
Joined: Jan 01, 2009 7:03

Re: cannot find -lSDL2

Postby BasicCoder2 » Aug 21, 2017 22:15

sancho2 wrote:This is an example of how to write a tutorial.

That was the tutorial I used in my failed attempt to set up SDL2 with code::blocks
Often experts are not always that good at explaining things to a non-expert or beginner.
Perhaps I will give C++ with SDL another try. If I can write C++ programs using SDL2 I should be able to translate them to FreeBASIC.
.
sancho2
Posts: 547
Joined: May 17, 2015 6:41

Re: cannot find -lSDL2

Postby sancho2 » Aug 21, 2017 23:26

I've never tried Code::Blocks. I used Visual Studio and the tutorial was spot on.
BasicCoder2
Posts: 2819
Joined: Jan 01, 2009 7:03

Re: cannot find -lSDL2

Postby BasicCoder2 » Aug 22, 2017 0:03

sancho2 wrote:I've never tried Code::Blocks. I used Visual Studio and the tutorial was spot on.


Ok. Well maybe I will have to try Visual Studio. That is a microsoft product?

In the meantime I tried to follow the tutorial carefully but ended up with,

||=== Build: Debug in SDL2 (compiler: GNU GCC Compiler) ===|
C:\mingw_dev_lib\01_hello_SDL.cpp|5|fatal error: SDL.h: No such file or directory|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|


After saving everything to come back to it later I get a window,
Layout changed
? The perspective 'Code::Blocks default' has changed. Do you want to save it?

Problem is I have no idea what they are talking about. Something the tutorial failed do cover.

So it looks like it is going to be a long hard road to follow. No easy tutorial for a beginner. Perhaps it was for you because you are already familiar with your IDE and how it works?
.
sancho2
Posts: 547
Joined: May 17, 2015 6:41

Re: cannot find -lSDL2

Postby sancho2 » Aug 22, 2017 1:16

It seems that code blocks can't find the header file.
It is step 4 in the tutorial.
Under project settings, click on project build options
In the Search Directories, we need to add a new compiler directory. Click add, Select the SDL2 folder inside of the include directory from the folder we extracted. Say no when it asks you whether you want it to be a relative path. Now Code::Blocks knows where to find the SDL 2 header files.

If you get an error where the compiler says it can't find SDL.h, it means you messed up this step.

On this page:
http://lazyfoo.net/tutorials/SDL/01_hello_SDL/windows/codeblocks/index.php
BasicCoder2
Posts: 2819
Joined: Jan 01, 2009 7:03

Re: cannot find -lSDL2

Postby BasicCoder2 » Aug 22, 2017 3:36

Found the SDL.h file in the uszipped SDL2_image-devel-2.0.1-VC.zip but couldn't figure out where to put it.
The SDL2_image-devel-2.0.1-mingw.tar.gz (MinGW 32/64-bit) didn't seem to unzip. I can't figure out why. I used the 7Zip utility.
Anyway I have erased everything and will start afresh again some other time.
They seem to want AU$3,674 for Visual Studio Enterprise.
.
sancho2
Posts: 547
Joined: May 17, 2015 6:41

Re: cannot find -lSDL2

Postby sancho2 » Aug 22, 2017 4:08

Visual Studio Express is what you are looking for. Its free.
But I thik that you are close with code::blocks anyway.
The last time I mess with tar files it seemed to me to be an unnecessary extra hassle. I'm sure they serve a purpose, but in this case there is a zip file that windows can handle natively.
You unzip all the contents into any folder. I made one simply c:\SDL and dumped everything in there. From there the tutorial tells you what files you have to copy and where to paste them.
If I were you I would backtrack all the way to the download and get the zip file instead of the tar file. I see the tutorial is telling you to opt for the tar.gz file but they give no reason for that.
Unzip everything into an easy to find spot. From there you can follow the instruction:
Inside of i686-w64-mingw32 are the include, lib, and bin folders which contain everything we need compile and run SDL applications. Copy the contents of i686-w64-mingw32 to any directory you want. I recommend putting it in a folder that you dedicate to holding all your development libraries for MinGW. For these tutorials I'm putting it in a directory I created C:\mingw_dev_lib


I can tell you that the Visual Studio C++ version of the tutorial is almost identical. So for sure the problem you are seeing are simply getting the three files in the right places. The Dll, the Header .h, and the library file. And then making sure code::blocks can find them.

If I can find the time I am going to try to get this to work with FB. Since there is an SDL2.bi include file, it should just be a matter of making sure the compiler can find the library and the dll.
BasicCoder2
Posts: 2819
Joined: Jan 01, 2009 7:03

Re: cannot find -lSDL2

Postby BasicCoder2 » Aug 22, 2017 6:00

Success!! 01_hello_SDL compiled and ran.
Thank you for hanging in there otherwise I probably would have given up.
With lesson 2 I found I had to do all the setting again!! And the image could not be found.
I have posted the problems to the C++ forum as this forum is really only for FB projects.

I managed to unzip the .tar.gz file somehow with 7ZFM. I think it might involve two stages.

Last time I was on the C++ forum (just playing with console programs) I was told that SFML is the best choice.
https://www.sfml-dev.org/

viewtopic.php?f=14&t=15325&hilit=SFML
.
MrSwiss
Posts: 1928
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: cannot find -lSDL2

Postby MrSwiss » Aug 22, 2017 13:40

BasicCoder2 wrote:
MrSwiss wrote:You'll have to download them from: SDL website.

Like I say it is a chore finding and figuring stuff out ...
A lot of sites offering the dll downloads play the same tricks. No dll just their special programs to "fix dll problems".
Eventually found web pages with the .dlls taking a risk of getting a virus with a download.
The programs now compile.
If you would read FB's Manual, there would NOT be such hassles!
On the page: External Libraries Index --> SDL it clearly states:
http://www.libsdl.org, but I'd use (secure): https://www.libsdl.org,
which is the official SDL homepage. (Not some dubious re-distributor ...)

Now, I'd suggest, to stop moaning and start reading, instead!

Return to “General”

Who is online

Users browsing this forum: No registered users and 5 guests