The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL Linkage problems
Almamu


Joined: 16 Jan 2015
Posts: 1
I'm working on a medium-sized game that targets platforms like Windows, Linux, MacOSx, Nintendo DS and PlayStationPortable, I'm actually working on the Linux build system for the game code and I'm stuck with the linkage of SDL.

The game is developed under the Nintendo DS (as is the one that has less power) and is re-compiled for better platforms. The build system (based in Makefiles) works like a charm for DS and without any problem, I can also compile for Windows (under Visual Studio) and run exactly the same code as Linux (so It's not really a problem with the way I include things or link libs, at least that's what I think).

The Makefiles I'm using for the Linux are a modified version of the DS' Makefiles, so most of the build system should be working correctly (of course I've modified them to include needed libraries so It can link to SDL and custom libraries [some ported libraries from the DS that allow to port the game to different platforms as fast as possible]).

In my testing environment I'm using Ubuntu 14.04 with the needed development packages for SDL 1.2 (I've checked that libSDL.so exists on my system and SDL_* do, too). These are the lines generated by the Makefile to build the project and link them.

First port library *.c compilation
Code:

gcc -MMD -MP -MF /home/almamu/Escritorio/smash_tmp/smash/nflib/build/video.d -g -Wall -O2 -fomit-frame-pointer -ffast-math  -I/home/almamu/Escritorio/smash_tmp/smash/nflib/include -I/home/almamu/Escritorio/smash_tmp/smash/nflib/win/include  -I/home/almamu/Escritorio/smash_tmp/smash/nflib/build -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -D__UNIXBUILD -Wno-unused-result  -c /home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c -o video.o


First static library ".a" generation
Code:

ar -rc /home/almamu/Escritorio/smash_tmp/smash/nflib/lib/libnflib.a nf_2d.o nf_3d.o nf_affinebg.o nf_basic.o nf_bitmapbg.o nf_colision.o nf_media.o nf_mixedbg.o nf_sound.o nf_sprite256.o nf_sprite3d.o nf_text16.o nf_text.o nf_tiledbg.o dswifi9.o nitrofs.o debugprint.o console.o keys.o video.o


Second port library *.cpp compilation
Code:

g++ -MMD -MP -MF /home/almamu/Escritorio/smash_tmp/smash/render/build/graphics.d -g -Wall -O2 -fomit-frame-pointer -ffast-math  -I/home/almamu/Escritorio/smash_tmp/smash/render/include -I/home/almamu/Escritorio/smash_tmp/smash/render/win/include -I/home/almamu/Escritorio/smash_tmp/smash/core/include -I/home/almamu/Escritorio/smash_tmp/smash/nflib/include -I/home/almamu/Escritorio/smash_tmp/smash/nflib/win/include -I/home/almamu/Escritorio/smash_tmp/smash/render/build -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -D__UNIXBUILD -Wno-unused-result  -fno-rtti -fno-exceptions -std=c++11 -c /home/almamu/Escritorio/smash_tmp/smash/render/win/source/graphics.cpp -o graphics.o


Second static library ".a" generation
Code:

ar -rc /home/almamu/Escritorio/smash_tmp/smash/render/lib/librender.a graphics.o


Game's code *.cpp compilation
Code:

g++ -MMD -MP -MF /home/almamu/Escritorio/smash_tmp/smash/core/build/strings.d -g -Wall -O2 -fomit-frame-pointer -ffast-math -Wformat=0 -I/home/almamu/Escritorio/smash_tmp/smash/core/include -I/home/almamu/Escritorio/smash_tmp/smash/nflib/include -I/home/almamu/Escritorio/smash_tmp/smash/render/include -I/home/almamu/Escritorio/smash_tmp/smash/render/include -I/home/almamu/Escritorio/smash_tmp/smash/render/win/include -I/home/almamu/Escritorio/smash_tmp/smash/nflib/include -I/home/almamu/Escritorio/smash_tmp/smash/nflib/win/include -I/home/almamu/Escritorio/smash_tmp/smash/core/build -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -D__UNIXBUILD -fno-rtti -fno-exceptions -fpermissive -std=c++11 -c /home/almamu/Escritorio/smash_tmp/smash/core/source/strings.cpp -o strings.o


Whole project linkage
Code:

g++  -g  -Wl,-Map,core.map -L/usr/lib/x86_64-linux-gnu -lSDL   assets.o battle.o client.o cmap.o common.o events.o filesystem.o input.o main.o memory.o messages.o mvars.o network.o server.o strings.o   -L/home/almamu/Escritorio/smash_tmp/smash/nflib/lib -L/home/almamu/Escritorio/smash_tmp/smash/render/lib -lrender -lnflib -o /home/almamu/Escritorio/smash_tmp/smash/core/core.elf


As you can see I've included the needed args to link the project with SDL (generated by sdl-config --libs) without any luck, this is the output of the linkage command:
Code:

/home/almamu/Escritorio/smash_tmp/smash/render/lib/librender.a(graphics.o): In function  `R_PrecacheBackground(assetHeader_t*, unsigned char, unsigned char, bool)':
/home/almamu/Escritorio/smash_tmp/smash/render/win/source/graphics.cpp:492: reference to `SDL_CreateRGBSurface' not defined
/home/almamu/Escritorio/smash_tmp/smash/render/win/source/graphics.cpp:514: reference to `SDL_CreateRGBSurfaceFrom' not defined
/home/almamu/Escritorio/smash_tmp/smash/render/win/source/graphics.cpp:515: reference to `SDL_UpperBlit' not defined
/home/almamu/Escritorio/smash_tmp/smash/render/lib/librender.a(graphics.o): In function `R_UpdateBackground(background_t*)':
/home/almamu/Escritorio/smash_tmp/smash/render/win/source/graphics.cpp:568: reference to `SDL_UpperBlit' not defined
/home/almamu/Escritorio/smash_tmp/smash/render/lib/librender.a(graphics.o): In function `R_SetBackgroundVisibility(unsigned char, unsigned char, bool)':
/home/almamu/Escritorio/smash_tmp/smash/render/win/source/graphics.cpp:599: reference to `SDL_FillRect' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/lib/libnflib.a(nf_2d.o): In function `NF_Set2D(unsigned char, unsigned char)':
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/nf_2d.cpp:31: reference to `SDL_MapRGB' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/nf_2d.cpp:31: reference to `SDL_FillRect' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/lib/libnflib.a(nf_tiledbg.o): In function `NF_ResetTiledBgBuffers()':
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/nf_tiledbg.cpp:98: reference to `SDL_FreeSurface' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/lib/libnflib.a(keys.o): In function `scanKeys':
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/keys.c:22: reference to `SDL_PollEvent' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/keys.c:153: reference to `SDL_Quit' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/keys.c:22: reference to `SDL_PollEvent' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/lib/libnflib.a(video.o): In function `defaultExceptionHandler':
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:75: reference to `SDL_Init' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:81: reference to `SDL_SetVideoMode' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:87: reference to `SDL_EnableUNICODE' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:88: reference to `SDL_WM_SetCaption' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:94: reference to `SDL_MapRGB' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:95: reference to `SDL_SetColorKey' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:102: reference to `SDL_CreateRGBSurface' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:103: reference to `SDL_SetColorKey' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:108: reference to `SDL_CreateRGBSurface' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:111: reference to `SDL_FillRect' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:112: reference to `SDL_SetColorKey' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/lib/libnflib.a(video.o): In function `swiWaitForVBlank':
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:150: reference to `SDL_UpperBlit' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:163: reference to `SDL_UpperBlit' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:167: reference to `SDL_Flip' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:175: reference to `SDL_FillRect' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:184: reference to `SDL_GetTicks' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:189: reference to `SDL_Delay' not defined
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:192: reference to `SDL_GetTicks' not defined


These are the Makefiles used in the project build system
Rules.linux
Code:

# --------------------------------------
# COMPILER DEFINITIONS
# --------------------------------------

export MKFILE_PATH = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
export BRANCH_NAME = $(notdir $(patsubst %/,%,$(dir $(MKFILE_PATH))))
export DST_PLATFORM = UNIX
export PLATFORM_DEF = __$(DST_PLATFORM)BUILD

# --------------------------------------
# BINARIES CONFIGURATION
# --------------------------------------

export LIB_EXTENSION = a
export EXE_EXTENSION = out
export OUT_EXTENSION = elf

# --------------------------------------
# SDL config
# --------------------------------------
export SDL_CFLAGS = $(shell sdl-config --cflags)
export SDL_DFLAGS = $(shell sdl-config --libs)

# --------------------------------------
# NFLIB config
# --------------------------------------

export NFLIB_NAME = nflib
export NFLIB_DIR = $(MKFILE_PATH)$(NFLIB_NAME)
export NFLIB_LIB = $(NFLIB_DIR)/lib
export NFLIB_INC = include win/include
export NFLIB_EXTENSION = $(LIB_EXTENSION)

# --------------------------------------
# RENDER config
# --------------------------------------

export RENDER_NAME = render
export RENDER_DIR = $(MKFILE_PATH)$(RENDER_NAME)
export RENDER_INC = include win/include
export RENDER_LIB = $(RENDER_DIR)/lib
export RENDER_EXTENSION = $(LIB_EXTENSION)

# --------------------------------------
# GAME config
# --------------------------------------

export GAME_INC = include
export GAME_NAME = core
export GAME_DIR = $(MKFILE_PATH)$(GAME_NAME)
export GAME_EXTENSION = $(EXE_EXTENSION)

# --------------------------------------
# MAKE util
# --------------------------------------

export MAKE = make -C
export MAKEFILE = Makefile.linux

# --------------------------------------
# BUILD utils
# --------------------------------------
export PREFIX   :=
export CC   :=   $(PREFIX)gcc
export CXX   :=   $(PREFIX)g++
export AS   :=   $(PREFIX)as
export AR   :=   $(PREFIX)ar
export OBJCOPY   :=   $(PREFIX)objcopy
export STRIP   :=   $(PREFIX)strip
export NM   :=   $(PREFIX)nm

ISVC=$(or $(VCBUILDHELPER_COMMAND),$(MSBUILDEXTENSIONSPATH32),$(MSBUILDEXTENSIONSPATH))

ifneq (,$(ISVC))
   ERROR_FILTER   :=   2>&1 | sed -e 's/\(.[a-zA-Z]\+\):\([0-9]\+\):/\1(\2):/g'
endif

# --------------------------------------
# DEBUG utils
# --------------------------------------

# --------------------------------------
# BUILD rules
# --------------------------------------
%.a:
   @echo $(notdir $@)
   @rm -f $@
   $(AR) -rc $@ $^

%.o: %.cpp
   @echo $(notdir $<)
   $(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -c $< -o $@ $(ERROR_FILTER)
   
# --------------------------------------
%.o: %.c
   @echo $(notdir $<)
   $(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -c $< -o $@ $(ERROR_FILTER)

# --------------------------------------
%.o: %.m
   @echo $(notdir $<)
   $(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(OBJCFLAGS) -c $< -o $@ $(ERROR_FILTER)

# --------------------------------------
%.o: %.s
   @echo $(notdir $<)
   $(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ $(ERROR_FILTER)

# --------------------------------------
%.o: %.S
   @echo $(notdir $<)
   $(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ $(ERROR_FILTER)

# --------------------------------------
%.elf:
   @echo linking $(notdir $@)
   @$(LD)  $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@



General Makefile.linux
Code:

#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
# --------------------------------------
# SYSTEM DEFINITIONS
# --------------------------------------

include Rules.linux

# --------------------------------------
# NORMAL MAKE EXECUTION
# --------------------------------------

.PHONY: run debug nflib render clean game omitnflib omitrender cleanrender cleannflib cleangame

all: nflib render game
omitnflib: render game
omitrender: game

# --------------------------------------
# NFLIB COMPILATION
# --------------------------------------

nflib:
   @echo NFLIB
   @$(MAKE) $(NFLIB_DIR) -f $(MAKEFILE) clean
   @$(MAKE) $(NFLIB_DIR) -f $(MAKEFILE)
   
# --------------------------------------
# RENDER COMPILATION
# --------------------------------------

render:
   @echo RENDER
   @$(MAKE) $(RENDER_DIR) -f $(MAKEFILE) clean all
   
# --------------------------------------
# GAME COMPILATION
# --------------------------------------

game:
   @echo GAME
   @$(MAKE) $(GAME_DIR) -f $(MAKEFILE)

# --------------------------------------
# FULL PROJECT CLEAN
# --------------------------------------

clean: cleanrender cleannflib cleangame

cleanrender:
   @$(MAKE) $(RENDER_DIR) -f $(MAKEFILE) clean
   
cleannflib:
   @$(MAKE) $(NFLIB_DIR) -f $(MAKEFILE) clean
   
cleangame:
   @$(MAKE) $(GAME_DIR) -f $(MAKEFILE) clean


# --------------------------------------
# PROJECT TESTING PURPOSES
# --------------------------------------

run: debug

debug:
   @$(MAKE) $(GAME_DIR) -f $(MAKEFILE) run
   
# --------------------------------------
# PROJECT DEBUG UTILS LAUNCHING
# --------------------------------------

addr2line:
   @$(A2L) $(A2L_FLAGS)


First lib's Makefile.linux
Code:

#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
include $(MKFILE_PATH)Rules.linux

#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
#---------------------------------------------------------------------------------
TARGET      :=   $(NFLIB_NAME)
BUILD      :=   build
SOURCES      :=   win/source win/source/libnds win/source/libnds/nds win/source/libnds/nds/arm9
DATA      :=   data
INCLUDES   :=   $(NFLIB_INC)

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS   :=   -g -Wall -O2\
      -fomit-frame-pointer -ffast-math \

CFLAGS   +=   $(INCLUDE) -D$(PLATFORM_DEF) -Wno-unused-result
CXXFLAGS   := $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11

ASFLAGS   :=   -g $(ARCH)
LDFLAGS   =   -Wl,-Map,$(notdir $*.map)

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS   :=   $(LIBNDS)

#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------

export OUTPUT   :=   $(CURDIR)/lib/lib$(TARGET).a

export VPATH   :=   $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
         $(foreach dir,$(DATA),$(CURDIR)/$(dir))

export DEPSDIR   :=   $(CURDIR)/$(BUILD)

CFILES      :=   $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES   :=   $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES      :=   $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES   :=   $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))

#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
   export LD   :=   $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
   export LD   :=   $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------

export OFILES   :=   $(addsuffix .o,$(BINFILES)) \
         $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)

export INCLUDE   :=   $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
               $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
               -I$(CURDIR)/$(BUILD) $(SDL_CFLAGS)

.PHONY: $(BUILD) clean all

#---------------------------------------------------------------------------------
all: $(BUILD)

lib:
   @[ -d $@ ] || mkdir -p $@
   
$(BUILD): lib
   @[ -d $@ ] || mkdir -p $@
   @make --no-print-directory -C $(BUILD) -f $(CURDIR)/$(MAKEFILE)

#---------------------------------------------------------------------------------
clean:
   @echo clean ...
   @rm -fr $(BUILD) lib

#---------------------------------------------------------------------------------
else

DEPENDS   :=   $(OFILES:.o=.d)

#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT)   :   $(OFILES)

#---------------------------------------------------------------------------------
%.bin.o   :   %.bin
#---------------------------------------------------------------------------------
   @echo $(notdir $<)
   @$(bin2o)


-include $(DEPENDS)

#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------


Second lib's Makefile.linux
Code:

#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
include $(MKFILE_PATH)Rules.linux

#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
#---------------------------------------------------------------------------------
TARGET      :=   $(RENDER_NAME)
BUILD      :=   build
SOURCES      :=   win/source
DATA      :=   data
INCLUDES   :=   $(RENDER_INC)

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS   :=   -g -Wall -O2\
      -fomit-frame-pointer -ffast-math \

CFLAGS   +=   $(INCLUDE) -D$(PLATFORM_DEF) -Wno-unused-result
CXXFLAGS   := $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11

ASFLAGS   :=   -g $(ARCH)
LDFLAGS   =   -Wl,-Map,$(notdir $*.map)

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS   :=   $(LIBNDS) $(GAME_DIR)

#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------

export OUTPUT   :=   $(CURDIR)/lib/lib$(TARGET).a

export VPATH   :=   $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
         $(foreach dir,$(DATA),$(CURDIR)/$(dir))

export DEPSDIR   :=   $(CURDIR)/$(BUILD)

CFILES      :=   $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES   :=   $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES      :=   $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES   :=   $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))

#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
   export LD   :=   $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
   export LD   :=   $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------

export OFILES   :=   $(addsuffix .o,$(BINFILES)) \
         $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)

export INCLUDE   :=   $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
               $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
               $(foreach dir,$(NFLIB_INC),-I$(NFLIB_DIR)/$(dir)) \
               -I$(CURDIR)/$(BUILD) $(SDL_CFLAGS)

.PHONY: $(BUILD) clean all

#---------------------------------------------------------------------------------
all: $(BUILD)

lib:
   @[ -d $@ ] || mkdir -p $@
   
$(BUILD): lib
   @[ -d $@ ] || mkdir -p $@
   @make --no-print-directory -C $(BUILD) -f $(CURDIR)/$(MAKEFILE)

#---------------------------------------------------------------------------------
clean:
   @echo clean ...
   @rm -fr $(BUILD) lib

#---------------------------------------------------------------------------------
else

DEPENDS   :=   $(OFILES:.o=.d)

#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT)   :   $(OFILES)

#---------------------------------------------------------------------------------
%.bin.o   :   %.bin
#---------------------------------------------------------------------------------
   @echo $(notdir $<)
   @$(bin2o)


-include $(DEPENDS)

#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------


Game's Makefile.linux (the last Makefile used)
Code:

#---------------------------------------------------------------------------------
# Makefile for NightFox's Lib Projects
# Modified By Almamu
#
# Changelog:
#         Support for paths defined from superior Makefiles added
#         This should make the compilation more dynamic and easy to maintain
#---------------------------------------------------------------------------------

#---------------------------------------------------------------------------------
# Compilation Options
#---------------------------------------------------------------------------------



#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
include $(MKFILE_PATH)Rules.linux

#---------------------------------------------------------------------------------
%.nds: %.elf
   @ndstool -c $@ -9 $< -b $(GAME_ICON) "$(GAME_TITLE);$(GAME_SUBTITLE1);$(GAME_SUBTITLE2)" $(_ADDFILES)
   @echo built ... $(notdir $@)

#---------------------------------------------------------------------------------
%.elf:
   @echo linking $(notdir $@)
   $(LD)  $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@


#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
# DATA is a list of directories containing binary files embedded using bin2o
# GRAPHICS is a list of directories containing image files to be converted with grit
#---------------------------------------------------------------------------------
TARGET      :=   $(GAME_NAME)
BUILD      :=   build
SOURCES      :=   source
INCLUDES   :=   $(GAME_INC)
DATA      :=   data 
GRAPHICS   :=   gfx 
NITRODATA   :=   nitrofiles

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS   :=   -g -Wall -O2 -fomit-frame-pointer\
      -ffast-math -Wformat=0

CFLAGS   +=   $(INCLUDE) -D$(PLATFORM_DEF)
CXXFLAGS   := $(CFLAGS) -fno-rtti -fno-exceptions -fpermissive -std=c++11

ASFLAGS   :=   -g $(ARCH)
LDFLAGS   =   -g $(ARCH) -Wl,-Map,$(notdir $*.map) $(SDL_DFLAGS)

#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------

LIBS   := -l$(RENDER_NAME) -l$(NFLIB_NAME)
 
 
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS   :=   $(LIBNDS) $(NFLIB_DIR) $(RENDER_DIR)

 
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------

export OUTPUT   :=   $(CURDIR)/$(TARGET)

export VPATH   :=   $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
               $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \
               $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))

export DEPSDIR   :=   $(CURDIR)/$(BUILD)

ifneq ($(strip $(NITRODATA)),)
   export NITRO_FILES   :=   $(CURDIR)/$(NITRODATA)
endif

CFILES      :=   $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES   :=   $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
PNGFILES   :=   $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png)))
SFILES      :=   $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES   :=   $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
 
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
   export LD   :=   $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
   export LD   :=   $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------

export OFILES   :=   $(addsuffix .o,$(BINFILES)) \
               $(addsuffix .o,$(PNGFILES)) \
               $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
 
export INCLUDE   :=   $(foreach dir,$(INCLUDES),-I$(GAME_DIR)/$(dir)) \
               $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
               $(foreach dir,$(RENDER_INC),-I$(RENDER_DIR)/$(dir)) \
               $(foreach dir,$(NFLIB_INC),-I$(NFLIB_DIR)/$(dir)) \
               -I$(CURDIR)/$(BUILD) $(SDL_CFLAGS)
 
export LIBPATHS   :=   $(foreach dir,$(LIBDIRS),-L$(dir)/lib)

icons := $(wildcard *.bmp)

ifneq (,$(findstring $(TARGET).bmp,$(icons)))
   export GAME_ICON := $(CURDIR)/$(TARGET).bmp
else
   ifneq (,$(findstring icon.bmp,$(icons)))
      export GAME_ICON := $(CURDIR)/icon.bmp
   endif
endif
 
.PHONY: $(BUILD) clean
 
#---------------------------------------------------------------------------------
$(BUILD):
   @[ -d $@ ] || mkdir -p $@
   @make --no-print-directory -C $(BUILD) -f $(CURDIR)/$(MAKEFILE)
 
#---------------------------------------------------------------------------------
clean:
   @echo clean ...
   @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(TARGET).arm9
   
#---------------------------------------------------------------------------------
else
 
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).nds   :    $(OUTPUT).elf
$(OUTPUT).elf   :   $(OFILES)
 
#---------------------------------------------------------------------------------
%.bin.o   :   %.bin
#---------------------------------------------------------------------------------
   @echo $(notdir $<)
   $(bin2o)
 
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------


I'm completely out of ideas, the thing is that It should be linking correctly as the *.so files from libSDL are in the correct folder, and the packages are correctly installed, has anyone had the same problem or any idea of how I could fix it?

Thanks in advance for the help.