[svn] SDL.h not found, broken compile

Where bugs go to lie down and rest

Moderator: Moderator

Post Reply
Message
Author
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