[svn] SDL.h not found, broken compile

Where bugs go to lie down and rest

Moderator: Moderator

Post Reply
Message
Author
greycat
Sher'Tul
Posts: 1396
Joined: Tue May 11, 2010 11:51 pm

[svn] SDL.h not found, broken compile

#1 Post by greycat »

Code: Select all

==== Building physfs ====
Creating ../obj/Debug/physfs
physfs_byteorder.c
physfs.c
physfsrwops.c
In file included from ../src/physfs/physfsrwops.c:24:
../src/physfs/physfsrwops.h:30:17: error: SDL.h: No such file or directory

Code: Select all

#include "physfs.h"
#ifdef __APPLE__
#include <SDL/SDL.h>
#else
#include "SDL.h"
#endif
I am on Debian 6.0. Presumably __APPLE__ is not set. My SDL.h is in /usr/include/SDL/ so the __APPLE__ version is what should be used here. I'm not familiar with premake4, but shouldn't that be figuring out where the libraries and headers are, so we don't hard-code OS symbols in the code?

Ah, and if I fix that one by hand, then:

Code: Select all

==== Building TEngine ====
Creating ../obj/Debug/TEngine
main.c
In file included from ../src/display_sdl.h:24,
                 from ../src/display.h:23,
                 from ../src/main.c:21:
../src/tSDL.h:7:17: warning: SDL.h: No such file or directory
../src/tSDL.h:8:21: warning: SDL_ttf.h: No such file or directory
../src/tSDL.h:10:23: warning: SDL_image.h: No such file or directory
In file included from ../src/display.h:23,
                 from ../src/main.c:21:
../src/display_sdl.h:40: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
../src/display_sdl.h:41: error: expected ‘)’ before ‘*’ token
../src/display_sdl.h:42: error: expected ‘)’ before ‘*’ token
../src/display_sdl.h:46: error: expected ‘)’ before ‘*’ token
etc.
And:

Code: Select all

==== Building TEngine ====
main.c
In file included from ../src/main.c:40:
../src/music.h:38:17: error: SDL.h: No such file or directory
../src/music.h:39:24: error: SDL_thread.h: No such file or directory
../src/main.c:53: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
../src/main.c:54: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘maincontext’
And if I fix all of those, then:

Code: Select all

==== Building TEngine ====
Creating ../obj/Debug/TEngine
main.c
../src/main.c:53: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
../src/main.c:54: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘maincontext’
src/main.c doesn't have any SDL #includes at all!

Canderel
Sher'Tul
Posts: 1252
Joined: Mon Nov 24, 2003 2:31 pm
Location: South Africa

Re: [svn] SDL.h not found, broken compile

#2 Post by Canderel »

All I know is that latest svn requires sdl 1.2.

greycat
Sher'Tul
Posts: 1396
Joined: Tue May 11, 2010 11:51 pm

Re: [svn] SDL.h not found, broken compile

#3 Post by greycat »

According to IRC, it requires 1.3. And if you go to the SDL home page you won't find it easily; it's hidden in the HG link. Also, it doesn't compile cleanly on Linux, or at least not the version I got moments ago....

greycat
Sher'Tul
Posts: 1396
Joined: Tue May 11, 2010 11:51 pm

Re: [svn] SDL.h not found, broken compile

#4 Post by greycat »

Wow, this is ... huge. I got it working, with many steps involved, guided by the folks in the IRC channel. Let me attempt to write this all down while I can still remember some of it:
  • You need libsdl 1.3 which is NOT obtained by following the SDL 1.3 link on the SDL home page, but rather, is obtained from http://www.libsdl.org/hg.php using a Mercurial checkout. (sudo apt-get install mercurial to get the hg command.)
  • libsdl 1.3 from Hg would not build for me, on Linux. It blew up with fatal errors. I traced down the definitions and took a guess at a workaround: ./configure --disable-input-events -- this worked for me. You may not need this, if the bug is fixed in your own Hg checkout. Or you may not need it on non-Linux systems. (--enable-input-events is "use Linux 2.4 unified input interface" and toggles the bit of code that was blowing up.)
  • You do not need separate Hg versions of libsdl-ttf or libsdl-image. You do, however, need to tell premake4 where everything is. If you are building libsdl 1.3 in the default place, it installs into /usr/local/lib. The Lua files in t-engine expect it elsewhere, so they need to be edited:

    Code: Select all

    Index: premake4.lua
    ===================================================================
    --- premake4.lua	(revision 4114)
    +++ premake4.lua	(working copy)
    @@ -17,7 +17,8 @@
     		"src/utf8proc",
     		"src/physfs",
     		"src/physfs/zlib123",
    -		"/opt/SDL-1.3/include/SDL/",
    +		"/usr/local/include/SDL/",
    +		"/usr/include/SDL/",
     		"/usr/include/GL",
     	}
     	if _OPTIONS.lua == "default" then includedirs{"src/lua"}
    Index: build/te4core.lua
    ===================================================================
    --- build/te4core.lua	(revision 4114)
    +++ build/te4core.lua	(working copy)
    @@ -57,8 +57,8 @@
     
     
     	configuration "linux"
    -		libdirs {"/opt/SDL-1.3/lib/"}
    -		links { "dl", "SDL-1.3", "SDL_ttf", "SDL_image", "openal", "vorbisfile", "GL", "GLU", "m", "pthread" }
    +		libdirs {"/usr/local/lib/"}
    +		links { "dl", "SDL", "SDL_ttf", "SDL_image", "openal", "vorbisfile", "GL", "GLU", "m", "pthread", "png" }
     		defines { [[TENGINE_HOME_PATH='".t-engine"']], 'SELFEXE_LINUX' }
     
     	configuration {"Debug"}
    
    Note that the /usr/include/SDL/ path is where the Debian versions of libsdl-ttf and libsdl-image are; while /usr/local/include/SDL/ is where the Hg (1.3) version of libsdl itself is. Also note I had to tell it to link against png. This is apparently not needed on some other systems, but it was needed on mine.
  • After linking, it needs to be able to find libSDL-1.3.so.whatever, which in my case was accomplished by running ldconfig -v (as root). Alternatives include editing /etc/ld.so.conf first, or setting LD_LIBRARY_PATH at runtime, etc.

marvalis
Uruivellas
Posts: 683
Joined: Sun Sep 05, 2010 5:11 am

Re: [svn] SDL.h not found, broken compile

#5 Post by marvalis »

/edit: I realized I edited the wrong file xD. Still trying to get it to work.

I am trying to install SDL 1.3 and compile on ubuntu.
I installed SDL.
I tried to edit premake but some parts where missing from the premake file (no configuration linux)
I got the following errors:

Code: Select all

==== Building TEngine (debug) ====
particles.c
../src/particles.c: In function ‘create_particles_thread’:
../src/particles.c:893:3: warning: passing argument 2 of ‘SDL_CreateThread’ from incompatible pointer type
/usr/local/include/SDL/SDL_thread.h:145:1: note: expected ‘const char *’ but argument is of type ‘struct particle_thread *’
../src/particles.c:893:3: error: too few arguments to function ‘SDL_CreateThread’
/usr/local/include/SDL/SDL_thread.h:145:1: note: declared here
make[1]: *** [../obj/Debug/TEngine/particles.o] Error 1
make: *** [TEngine] Error 2
To be honest I have no clue what I am doing.

This is what I did to my premake4 file:

Code: Select all

===================================================================
--- t-engine4/premake4.lua	(revision 4551)
+++ t-engine4/premake4.lua	(working copy)
@@ -18,7 +18,8 @@
 		"src/physfs",
 		"src/physfs/zlib123",
 		"src/bzip2",
-		"/opt/SDL-1.3/include/SDL/",
+		"/usr/local/include/SDL/",
+		"/usr/include/SDL/",
 		"/usr/include/GL",
 	}
 	if _OPTIONS.lua == "default" then includedirs{"src/lua"}
@@ -49,6 +50,12 @@
 configuration "macosx"
 	buildoptions { "-pagezero_size 10000", "-image_base 100000000" }
 
+   configuration "linux"
+	libdirs {"/usr/local/lib/"}
+	links { "dl", "SDL", "SDL_ttf", "SDL_image", "openal", "vorbisfile", "GL", "GLU", "m", "pthread", "png" }
+	defines { [[TENGINE_HOME_PATH='".t-engine"']], 'SELFEXE_LINUX' }
+
+   configuration {"Debug"}
 configuration "Debug"
 	defines { }
 	flags { "Symbols" }
BTW, that is my first diff output ever, so congratulations to me!

greycat
Sher'Tul
Posts: 1396
Joined: Tue May 11, 2010 11:51 pm

Re: [svn] SDL.h not found, broken compile

#6 Post by greycat »

The configuration "linux" part is in build/te4core.lua. You don't add it to ./premake4.lua.

theotherhiveking
Posts: 2
Joined: Sat Oct 15, 2011 3:53 pm

Re: [svn] SDL.h not found, broken compile

#7 Post by theotherhiveking »

marvalis wrote:

Code: Select all

==== Building TEngine (debug) ====
particles.c
../src/particles.c: In function ‘create_particles_thread’:
../src/particles.c:893:3: warning: passing argument 2 of ‘SDL_CreateThread’ from incompatible pointer type
/usr/local/include/SDL/SDL_thread.h:145:1: note: expected ‘const char *’ but argument is of type ‘struct particle_thread *’
../src/particles.c:893:3: error: too few arguments to function ‘SDL_CreateThread’
/usr/local/include/SDL/SDL_thread.h:145:1: note: declared here
make[1]: *** [../obj/Debug/TEngine/particles.o] Error 1
make: *** [TEngine] Error 2
I got this error too, using archlinux.

yufra
Perspiring Physicist
Posts: 1332
Joined: Tue Jul 13, 2010 2:53 pm

Re: [svn] SDL.h not found, broken compile

#8 Post by yufra »

marvalis wrote: I got the following errors:

Code: Select all

==== Building TEngine (debug) ====
particles.c
../src/particles.c: In function ‘create_particles_thread’:
../src/particles.c:893:3: warning: passing argument 2 of ‘SDL_CreateThread’ from incompatible pointer type
/usr/local/include/SDL/SDL_thread.h:145:1: note: expected ‘const char *’ but argument is of type ‘struct particle_thread *’
../src/particles.c:893:3: error: too few arguments to function ‘SDL_CreateThread’
/usr/local/include/SDL/SDL_thread.h:145:1: note: declared here
make[1]: *** [../obj/Debug/TEngine/particles.o] Error 1
make: *** [TEngine] Error 2
The problem is that we are using a different SDL version than DarkGod is. If you look at the source code for SDL_threads you can see that the SDL_CreateThread function has changed:

Code: Select all

DECLSPEC SDL_Thread *SDLCALL
SDL_CreateThread(int (SDLCALL * fn) (void *),
                 const char *name, void *data)
The important change is that the "name" argument has been inserted before the "data" one. This is fairly straight-forward to fix by finding all of the SDL_CreateThread calls in T-Engine4 and adding a dummy string name for the second argument. Here is my complete diff:

Code: Select all

diff --git a/build/te4core.lua b/build/te4core.lua
index 6cb12f8..1979eca 100644
--- a/build/te4core.lua
+++ b/build/te4core.lua
@@ -57,8 +57,8 @@ project "TEngine"
 
 
        configuration "linux"
-               libdirs {"/opt/SDL-1.3/lib/"}
-               links { "dl", "SDL-1.3", "SDL_ttf", "SDL_image", "openal", "vorbisfile", "GL", "GLU", "m", "pthread" }
+               libdirs {"/usr/local/lib/"}
+               links { "dl", "SDL", "SDL_ttf", "SDL_image", "openal", "vorbisfile", "GL", "GLU", "m", "pthread", "png" }
                defines { [[TENGINE_HOME_PATH='".t-engine"']], 'SELFEXE_LINUX' }
 
        configuration {"Debug"}
diff --git a/premake4.lua b/premake4.lua
index f516dfe..aaf6307 100644
--- a/premake4.lua
+++ b/premake4.lua
@@ -18,7 +18,8 @@ solution "TEngine"
                "src/physfs",
                "src/physfs/zlib123",
                "src/bzip2",
-               "/opt/SDL-1.3/include/SDL/",
+               "/usr/local/include/SDL",
+               "/usr/include/SDL",
                "/usr/include/GL",
        }
        if _OPTIONS.lua == "default" then includedirs{"src/lua"}
diff --git a/src/music.c b/src/music.c
index b438039..4ef9d47 100644
--- a/src/music.c
+++ b/src/music.c
@@ -275,7 +275,8 @@ static int loadsoundLua(lua_State *L) {
                if (sound->mutex == NULL) luaL_error(L, "out of memory");
                sound->cond = SDL_CreateCond();
                if (sound->cond == NULL) luaL_error(L, "out of memory");
-               sound->loaderThread = SDL_CreateThread(streamingLoader, sound);
+               const char *name = "Sound";
+               sound->loaderThread = SDL_CreateThread(streamingLoader, name, sound);
        }
        else {
                sound->static_source = 0;
diff --git a/src/particles.c b/src/particles.c
index c44fcf1..e443d55 100644
--- a/src/particles.c
+++ b/src/particles.c
@@ -890,7 +890,8 @@ void create_particles_thread()
                pt->keyframes = SDL_CreateSemaphore(0);
                pt->running = TRUE;
 
-               thread = SDL_CreateThread(thread_particles, pt);
+               const char *name = "Particles";
+               thread = SDL_CreateThread(thread_particles, name, pt);
                if (thread == NULL) {
                        printf("Unable to create particle thread: %s\n", SDL_GetError());
                        continue;
diff --git a/src/profile.c b/src/profile.c
index 7afd243..ecc8b65 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -207,7 +207,8 @@ int create_profile_thread(lua_State *L)
        profile->lock_oqueue = SDL_CreateMutex();
        profile->wait_oqueue = SDL_CreateSemaphore(0);
 
-       thread = SDL_CreateThread(thread_profile, profile);
+       const char *name = "Profile";
+       thread = SDL_CreateThread(thread_profile, name, profile);
        if (thread == NULL) {
                printf("Unable to create profile thread: %s\n", SDL_GetError());
                return -1;
<DarkGod> lets say it's intended

greycat
Sher'Tul
Posts: 1396
Joined: Tue May 11, 2010 11:51 pm

Re: [svn] SDL.h not found, broken compile

#9 Post by greycat »

Which version of C lets you define a new variable in the middle of a function without starting a new block? Is that a C99 feature? I stopped using C professionally in between 89 and 99 so I don't know all the 99 stuff....

tiger_eye
Perspiring Physicist
Posts: 889
Joined: Thu Feb 17, 2011 5:20 am

Re: [svn] SDL.h not found, broken compile

#10 Post by tiger_eye »

yufra wrote:The problem is that we are using a different SDL version than DarkGod is.
As of b34, DarkGod uses revision hg5580 from the SDL-1.3 mercurial repository. For the linux binary anyway.

Post Reply