SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2015-04-18 15:27:43

Renatinho
New Member
Registered: 2015-04-18
Posts: 2

Troubles with SDL.

Hey guys, when I try to compile a c/c++ code whit SDL geany returns to me that canot find the SDL archive.

SDL/SDL.h : File or directory not found ( maybe not exactly like this, I'm brasilian, my geany is in portuguese, I only translate the error.)

It happens in VI too, it's not a IDE problem.

The sdl is instaled in usr/SDL2/SDL.h. I tried to switch SDL ( in #include SDL/SDL.h) to SDL2, but still doesnt work.

Last edited by Renatinho (2015-04-18 15:28:39)

Offline

Help fund CrunchBang, donate to the project!

#2 2015-04-18 16:24:23

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Troubles with SDL.

[code]
your terminal output here.
see the Code command just below the smilies faces.

sua saída do terminal aqui.
consulte o comando Código logo abaixo dos rostos sorridentes.
[/code]

Offline

#3 2015-04-18 17:08:10

twoion
Emerald Caffeine
From: 星界
Registered: 2012-05-11
Posts: 1,648

Re: Troubles with SDL.

If you use your own makefile or a build script, the best way is to query the necessary CPPFLAGS and LDFLAGS like this (simplified example for make):

CPPFLAGS = $(shell pkg-config --cflags sdl)
CFLAGS = -O3 $(CPPFLAGS) 
LDFLAGS = $(shell pkg-config --libs sdl)

myprogram : myprogram.c myprogram2.c
	gcc $(CFLAGS) -o $@ $^ $(LDFLAGS)

If you use the GNU autotools, but something like is in your configure.ac:

PKG_CHECK_MODULES([LIBSDL], [sdl])

and add something like this to your Makefile.am:

myprogram_CFLAGS = $(LIBSDL_CFLAGS)
myprogram_LDFLAGS = $(LIBSDL_LIBS)

and do

autoreconf -if

If you still are facing problems, post your build scripts/build system configuration because without that nobody here could possibly know what is going wrong.

Last edited by twoion (2015-04-18 17:09:52)

Offline

#4 2015-04-18 17:09:31

Renatinho
New Member
Registered: 2015-04-18
Posts: 2

Re: Troubles with SDL.

renatinho@crunchbang:~$ g++ ~/jogo/01_hello_SDL/01_hello_SDL.cpp -w lSDL2 -o 01_hello_sdl
g++: error: lSDL2: Arquivo ou diretório não encontrado

Sorry by taking your time, i've found my mistake the right code is #include "SDL2/SDL.h".

Last edited by Renatinho (2015-04-18 17:35:52)

Offline

#5 2015-04-18 17:14:44

twoion
Emerald Caffeine
From: 星界
Registered: 2012-05-11
Posts: 1,648

Re: Troubles with SDL.

^ or put sdl2 instead of sdl with you want to compile against libsdl2.

In your command line, you probably meant to write

-lSDL2

Also, put flags that are passed through to the linker -L/-l always at the very end of the gcc/g++ invocation. So, your example should probably read like this:

g++ -w -o 01_hello_SDL $(pkg-config --cflags sdl2) ~/jogo/01_hello_SDL/01_hello_SDL.cpp $(pkg-config --libs sdl2)

Offline

#6 2015-04-18 17:16:02

Head_on_a_Stick
CatMod
From: A world of pure imagination
Registered: 2014-01-21
Posts: 4,797

Re: Troubles with SDL.

renatinho@crunchbang:~$ g++ ~/jogo/01_hello_SDL/01_hello_SDL.cpp -w lSDL2 -o 01_hello_sdl
g++: error: lSDL2: Arquivo ou diretório não encontrado

Last edited by Head_on_a_Stick (2015-04-18 17:16:46)

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat

Debian Logo