GP2X Can't Compile .c File (uses Sdl) To .o (using Devkitgp2x)


paul_nicholls

Still Fresh
Joined
Nov 23, 2006
Messages
42
Hi all,
I can make SDL programs using the SDL_Mixer for the gp2x using the devkitGP2X ok, but when I do the same thing using freepascal I get a crash.

So to try and get around this issue I am experimenting with trying to make a library? file (*.o) that I can link into the freepascal to see if this fixed the problem.

I have test c and h files I want to compile.

gp2x_sdl_mixer.h
CODE
#ifndef GP2X_SDL_MIXER
#define GP2X_SDL_MIXER
#include "SDL.h"
#include "SDL_mixer.h"
int Mix_gp2x_OpenAudio(int frequency, Uint16 format, int channels, int chunksize);
void Mix_gp2x_CloseAudio();
#endif


gp2x_sdl_mixer.c
CODE
#include "gp2x_sdl_mixer.h"
int Mix_gp2x_OpenAudio(int frequency, Uint16 format, int channels, int chunksize)
{
return Mix_OpenAudio(frequency,format,channels,chunksize);
};
void Mix_gp2x_CloseAudio()
{
Mix_CloseAudio();
};


I tried compiling it using
CODE
arm-linux-gcc.exe -c gp2x_sdl_mixer.c


but of course it complains that it can't find SDL.h for starters - fair enough.

So I have had a look at the sdltest makefile by (Guyfawks), but the problem is that I don't know much about Makefiles and I don't know how I could modify the makefile to compile my gp2x_sdl_mixer.c file to .o format.

Makefile
CODE
CROSS_COMPILE = C:/devkitGP2X/bin/arm-linux-
SDL_BASE = C:/devkitGP2X/bin/arm-linux-
LDFLAGS = -static

CXX = $(CROSS_COMPILE)g++
STRIP = $(CROSS_COMPILE)strip

CXXFLAGS = -I"C:/devkitGP2X/include" -I"C:/devkitGP2X/include/SDL" -DTARGET_GP2X -O2 -Wall
LIBS = -L"C:/devkitGP2X/lib" -lSDL -lSDL_gfx --start-group -lSDL_ttf -lfreetype -lSDL --end-group -lSDL_image -ljpeg -lpng12 -lz --start-group -lSDL_mixer -lvorbisidec -lmikmod -lsmpeg -lSDL --end-group -lgcc -lm -lc -lexpat -lpthread -ldl

TARGET = sdltest.gpe
OBJS = sdltest.o

ALL_TARGETS = $(TARGET)

all: $(ALL_TARGETS)

$(TARGET): $(OBJS)
$(CXX) $(LDFLAGS) -o $(TARGET) $(OBJS) $(LIBS)
$(STRIP) $(TARGET)

clean:
rm *.o
rm $(TARGET)



Any ideas or help would be great! :)

PS If it helps, I am compiling under windows and using the Make.exe found here (c:\devkitGP2X\minsys\bin)

cheers,
Paul
 

Yos-T

Still Fresh
Joined
Aug 3, 2007
Messages
16
You don't really need a makefile for compiling one source file. You can compile with arm-linux-gcc.exe -c gp2x_sdl_mixer.c -I<path to SDL.h>. -I tells the preprocessor where to look for include files.

If you want to use the makefile copy it to your source dir. Change "TARGET = sdltest.gpe" to "TARGET = gp2x_sdl_mixer.gpe" and "OBJS = sdltest.o" to "OBJS = gp2x_sdl_mixer.o" and "ALL_TARGETS = $(TARGET)" to "ALL_TARGETS = $("OBJS)" and check if the paths on CXXFLAGS are the right ones for you.
Then you should be able to compile with 'make'.
 

paul_nicholls

Still Fresh
Joined
Nov 23, 2006
Messages
42
Yos-T said:
You don't really need a makefile for compiling one source file. You can compile with arm-linux-gcc.exe -c gp2x_sdl_mixer.c -I<path to SDL.h>. -I tells the preprocessor where to look for include files.

If you want to use the makefile copy it to your source dir. Change "TARGET = sdltest.gpe" to "TARGET = gp2x_sdl_mixer.gpe" and "OBJS = sdltest.o" to "OBJS = gp2x_sdl_mixer.o" and "ALL_TARGETS = $(TARGET)" to "ALL_TARGETS = $("OBJS)" and check if the paths on CXXFLAGS are the right ones for you.
Then you should be able to compile with 'make'.
Thanks Yos-T, I will try your suggestions :)

I am usually a pascal programmer, and not a c/c++ programmer so I am not used to this part of things :)

EDIT: I did the first option and it worked just fine :)

thanks again,
cheers,
Paul.
 
Last edited by a moderator:

paul_nicholls

Still Fresh
Joined
Nov 23, 2006
Messages
42
rabidcow said:
Your makefile is set up to build C++ source, not C. You need to set CC and CFLAGS instead of or as well as CXX and CXXFLAGS. (if you still want to use the makefile)

One of the conveniences I don't like so much with make... There's implicit rules that hide what's going on:

http://www.gnu.org/software/make/manual/ma...alogue-of-Rules



Thanks for the info rabidcow :)

cheers,
Paul
 
Last edited by a moderator:

paul_nicholls

Still Fresh
Joined
Nov 23, 2006
Messages
42
Hi guys :)
I have compiled the 'library' sucessfully, but when I try and use it in a pascal program I get linking errors:

CODE
Linking sdlibltest
sdlibltest.o: In function `P$SDLTEST_SHUTDOWN':
sdlibltest.dpr:(.text.n_p$sdltest_shutdown+0x24): undefined reference to `gp2x_Mix_FreeMusic'
sdlibltest.dpr:(.text.n_p$sdltest_shutdown+0x28): undefined reference to `gp2x_Mix_CloseAudio'
sdlibltest.o: In function `P$SDLTEST_OPENAUDIO$$BOOLEAN':
sdlibltest.dpr:(.text.n_p$sdltest_openaudio$$boolean+0x50): undefined reference to `gp2x_Mix_OpenAudio'
sdlibltest.o: In function `P$SDLTEST_LOADMUSIC$ANSISTRING$$POINTER':
sdlibltest.dpr:(.text.n_p$sdltest_loadmusic$ansistring$$pointer+0x28): undefined reference to `gp2x_Mix_LoadMUS'
sdlibltest.o: In function `P$SDLTEST_PLAYMUSIC$POINTER$LONGINT$$LONGINT':
sdlibltest.dpr:(.text.n_p$sdltest_playmusic$pointer$longint$$longint+0x20): undefined reference to `gp2x_Mix_PlayMusic'
sdlibltest.o: In function `P$SDLTEST_PLAYINGMUSIC$$BOOLEAN':
sdlibltest.dpr:(.text.n_p$sdltest_playingmusic$$boolean+0x10): undefined reference to `gp2x_Mix_PlayingMusic'


my current .c and .h files + my pascal unit linking in the library:

The gp2x_sdl_mixer.h file
CODE
#ifndef GP2X_SDL_MIXER
#define GP2X_SDL_MIXER

#include "SDL_mixer.h"

int gp2x_Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize);
void gp2x_Mix_CloseAudio(void);
Mix_Music *gp2x_Mix_LoadMUS(const char *file);
int gp2x_Mix_PlayMusic(Mix_Music *music, int loops);
int gp2x_Mix_PlayingMusic(void);
void gp2x_Mix_FreeMusic (Mix_Music *music);

#endif


The gp2x_sdl_mixer.c file
CODE
#include "gp2x_sdl_mixer.h"

int gp2x_Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize)
{
return Mix_OpenAudio(frequency,format,channels,chunksize);
};
void gp2x_Mix_CloseAudio(void)
{
Mix_CloseAudio();
};
Mix_Music *gp2x_Mix_LoadMUS(const char *file)
{
return Mix_LoadMUS(file);
};
int gp2x_Mix_PlayMusic(Mix_Music *music, int loops)
{
return Mix_PlayMusic(music,loops);
};
int gp2x_Mix_PlayingMusic(void)
{
return Mix_PlayingMusic();
};
void gp2x_Mix_FreeMusic (Mix_Music *music)
{
Mix_FreeMusic(music);
};


The pascal unit
CODE
Unit gp2x_sdl_mixer;
{$IFDEF fpc
{$MODE Delphi}
{$ENDIF}

{$link gp2x_sdl_mixer.o}
{$linklib c}

Interface

Uses
CTypes;

Type
PMix_Music = Pointer;

Function gp2x_Mix_OpenAudio(frequency : ctypes.cint32; format : ctypes.cuint16; channels,chunksize : ctypes.cint32) : ctypes.cint32; cdecl; external;
Procedure gp2x_Mix_CloseAudio; CDecl; external;
Function gp2x_Mix_LoadMUS(Const filename : PChar) : PMix_Music; CDecl; external;
Function gp2x_Mix_PlayMusic(music : PMix_Music; loops : ctypes.cint32) : ctypes.cint32; CDecl; external;
Function gp2x_Mix_PlayingMusic : ctypes.cint32; CDecl; external;
Procedure gp2x_Mix_FreeMusic(music : PMix_Music); CDecl; external;

Implementation

End.


When I try to use any of the above routines in my sdltest pascal file I get the linker errors at the top of the post.

Any ideas?

cheers,
Paul.
 

gmiller1018

Member
Joined
Sep 21, 2006
Messages
336
Location
USA Florida
Website
Visit site
Have not done any pascal for a long time but from the error messages it appears that the object file with your C functions in it is not being found by the link stage. You appear to have the pascal compiler putting the correct external references in the main object file but the other object file might not be found. Did you get the 'gp2x_sdl_mixer.o' object file created with your C compile?

Paul Nicholls said:
Hi guys :)
I have compiled the 'library' sucessfully, but when I try and use it in a pascal program I get linking errors:

CODE
Linking sdlibltest
sdlibltest.o: In function `P$SDLTEST_SHUTDOWN':
sdlibltest.dpr:(.text.n_p$sdltest_shutdown+0x24): undefined reference to `gp2x_Mix_FreeMusic'
sdlibltest.dpr:(.text.n_p$sdltest_shutdown+0x28): undefined reference to `gp2x_Mix_CloseAudio'
sdlibltest.o: In function `P$SDLTEST_OPENAUDIO$$BOOLEAN':
sdlibltest.dpr:(.text.n_p$sdltest_openaudio$$boolean+0x50): undefined reference to `gp2x_Mix_OpenAudio'
sdlibltest.o: In function `P$SDLTEST_LOADMUSIC$ANSISTRING$$POINTER':
sdlibltest.dpr:(.text.n_p$sdltest_loadmusic$ansistring$$pointer+0x28): undefined reference to `gp2x_Mix_LoadMUS'
sdlibltest.o: In function `P$SDLTEST_PLAYMUSIC$POINTER$LONGINT$$LONGINT':
sdlibltest.dpr:(.text.n_p$sdltest_playmusic$pointer$longint$$longint+0x20): undefined reference to `gp2x_Mix_PlayMusic'
sdlibltest.o: In function `P$SDLTEST_PLAYINGMUSIC$$BOOLEAN':
sdlibltest.dpr:(.text.n_p$sdltest_playingmusic$$boolean+0x10): undefined reference to `gp2x_Mix_PlayingMusic'
my current .c and .h files + my pascal unit linking in the library:

The gp2x_sdl_mixer.h file
CODE
#ifndef GP2X_SDL_MIXER
#define GP2X_SDL_MIXER

#include "SDL_mixer.h"

int gp2x_Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize);
void gp2x_Mix_CloseAudio(void);
Mix_Music *gp2x_Mix_LoadMUS(const char *file);
int gp2x_Mix_PlayMusic(Mix_Music *music, int loops);
int gp2x_Mix_PlayingMusic(void);
void gp2x_Mix_FreeMusic (Mix_Music *music);

#endif


The gp2x_sdl_mixer.c file
CODE
#include "gp2x_sdl_mixer.h"

int gp2x_Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize)
{
return Mix_OpenAudio(frequency,format,channels,chunksize);
};
void gp2x_Mix_CloseAudio(void)
{
Mix_CloseAudio();
};
Mix_Music *gp2x_Mix_LoadMUS(const char *file)
{
return Mix_LoadMUS(file);
};
int gp2x_Mix_PlayMusic(Mix_Music *music, int loops)
{
return Mix_PlayMusic(music,loops);
};
int gp2x_Mix_PlayingMusic(void)
{
return Mix_PlayingMusic();
};
void gp2x_Mix_FreeMusic (Mix_Music *music)
{
Mix_FreeMusic(music);
};


The pascal unit
CODE
Unit gp2x_sdl_mixer;
{$IFDEF fpc
{$MODE Delphi}
{$ENDIF}

{$link gp2x_sdl_mixer.o}
{$linklib c}

Interface

Uses
CTypes;

Type
PMix_Music = Pointer;

Function gp2x_Mix_OpenAudio(frequency : ctypes.cint32; format : ctypes.cuint16; channels,chunksize : ctypes.cint32) : ctypes.cint32; cdecl; external;
Procedure gp2x_Mix_CloseAudio; CDecl; external;
Function gp2x_Mix_LoadMUS(Const filename : PChar) : PMix_Music; CDecl; external;
Function gp2x_Mix_PlayMusic(music : PMix_Music; loops : ctypes.cint32) : ctypes.cint32; CDecl; external;
Function gp2x_Mix_PlayingMusic : ctypes.cint32; CDecl; external;
Procedure gp2x_Mix_FreeMusic(music : PMix_Music); CDecl; external;

Implementation

End.


When I try to use any of the above routines in my sdltest pascal file I get the linker errors at the top of the post.

Any ideas?

cheers,
Paul.
 
Last edited by a moderator:

paul_nicholls

Still Fresh
Joined
Nov 23, 2006
Messages
42
Gary Miller said:
Have not done any pascal for a long time but from the error messages it appears that the object file with your C functions in it is not being found by the link stage. You appear to have the pascal compiler putting the correct external references in the main object file but the other object file might not be found. Did you get the 'gp2x_sdl_mixer.o' object file created with your C compile?
Hi Gary,
I do have the 'gp2x_sdl_mixer.o' file appearing in the same folder as the source code I am trying to compile...so I don't know what is going on :(

cheers,
Paul
 
Last edited by a moderator:

gmiller1018

Member
Joined
Sep 21, 2006
Messages
336
Location
USA Florida
Website
Visit site
I guess I was trying to suggest that the linker is not actually using that file or the file is referenced prior to the object file that calls the routines. Some linkers are positional where routines that are called by other object files must be listed after all of the others. Not being familar with the input specification for pascal here I am not sure how this works. Using the gcc link setup would be something like this:

gcc -o sdlibtest sdlibtest.o gp2x_sdl_mixer.o (then all of the libraries, in the correct order)

No linker that I know of will figure out what object files are needed by looking ANYWHERE they must be explicitly specified. Some will pick up libraries as long as they know where to look but in general you need to specify them as well. I am sorry I am not much more help. I stopped commercial pascal many years ago (at least 20 years) so I little knowledge of the linking rules for this version.
 

paul_nicholls

Still Fresh
Joined
Nov 23, 2006
Messages
42
Gary Miller said:
I guess I was trying to suggest that the linker is not actually using that file or the file is referenced prior to the object file that calls the routines. Some linkers are positional where routines that are called by other object files must be listed after all of the others. Not being familar with the input specification for pascal here I am not sure how this works. Using the gcc link setup would be something like this:

gcc -o sdlibtest sdlibtest.o gp2x_sdl_mixer.o (then all of the libraries, in the correct order)

No linker that I know of will figure out what object files are needed by looking ANYWHERE they must be explicitly specified. Some will pick up libraries as long as they know where to look but in general you need to specify them as well. I am sorry I am not much more help. I stopped commercial pascal many years ago (at least 20 years) so I little knowledge of the linking rules for this version.
Ah, ok I see what you mean now :)

If it helps, this is my batch file which compiles my main program file (sdllibtest.dpr)

It uses the ppcrossarm.exe (freepascal cross-compiler) to compile the program, then it uses the arm-linux-as.exe to assemble and arm-linux-ld.exe to link the libraries.

CompileMain.bat
CODE
echo Compiling %1.dpr
ppcrossarm -s -dGP2X %1.dpr
echo Assembling %1
arm-linux-as.exe -mcpu=arm920 -o %1.o %1.s
if errorlevel 1 goto asmend
echo Linking %1
arm-linux-ld.exe -static --no-warn-mismatch --reduce-memory-overheads --gc-sections -s -L. -o%1.gpe link.res -lpng -lm -lstdc++ -lgcc_eh -lpthread -lvorbisidec -lmikmod -lpng12 -lz -lSDL -ljpeg -lfreetype -lc -lgcc -lmad
if errorlevel 1 goto linkend
goto end
:asmend
echo An error occured while assembling %1
goto end
:linkend
echo An error occured while linking %1
:end
 
Last edited by a moderator:

paul_nicholls

Still Fresh
Joined
Nov 23, 2006
Messages
42
Gary Miller said:
Is the link.res your linker response file (or similar name) and have you posted that already?
Hi Gary, I assume the link.res file is what you are talking about and no I have not posted it yet. It is below, if it helps.

CODE

SEARCH_DIR(C:\devkitGP2X\sysroot\usr\lib\gconv)
SEARCH_DIR(C:\devkitGP2X\sysroot\usr\lib)
SEARCH_DIR(C:\devkitGP2X\sysroot\lib)
SEARCH_DIR(C:\devkitGP2X\lib\pkgconfig)
SEARCH_DIR(C:\devkitGP2X\lib\gcc\arm-linux\4.0.2)
SEARCH_DIR(C:\devkitGP2X\sysroot)
SEARCH_DIR(C:\devkitGP2X\share)
SEARCH_DIR(C:\devkitGP2X\minsys)
SEARCH_DIR(C:\devkitGP2X\man)
SEARCH_DIR(C:\devkitGP2X\libexec)
SEARCH_DIR(C:\devkitGP2X\lib)
SEARCH_DIR(C:\devkitGP2X\info)
SEARCH_DIR(C:\devkitGP2X\include)
SEARCH_DIR(C:\devkitGP2X\etc)
SEARCH_DIR(C:\devkitGP2X\bin)
SEARCH_DIR(C:\devkitGP2X\arm-linux)
SEARCH_DIR(C:\devkitGP2X\.)
SEARCH_DIR(C:\devkitGP2X\arm-linux\lib\ldscripts)
SEARCH_DIR(C:\devkitGP2X\arm-linux\lib)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\zvt)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\zlib)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\x11)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\uuid)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\utmp)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\unzip)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\unixutil)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\tcl)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\syslog)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\svgalib)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\sqlite)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\rtl)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\regexpr)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\pthreads)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\postgres)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\pcap)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\paszlib)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\pasjpeg)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\oracle)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\openssl)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\opengl)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\openal)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\oggvorbis)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\odbc)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\newt)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\netdb)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\ncurses)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\mysql)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\modplug)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\mad)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\libpng)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\libgd)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\libcurl)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\libasync)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\lexyacc)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\ldap)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\imlib)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\ibase)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\httpd-2.2)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\httpd-2.0)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\httpd-1.3)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\hash)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\gtk2)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\gtk)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\graph)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\gnome)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\ggi)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\gdbm)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\gdbint)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\gconf)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\fv)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\fppkg)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\fpmkunit)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\fpgtk)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\forms)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\fftw)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\fcl-xml)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\fcl-web)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\fcl-registry)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\fcl-passrc)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\fcl-net)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\fcl-image)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\fcl-fpcunit)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\fcl-db)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\fcl-base)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\dts)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\dbus)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\cdrom)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\cairo)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\bfd)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\a52)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\..)
SEARCH_DIR(C:\FPC_win32_arm-linux\units\arm-linux\.)
SEARCH_DIR(C:\FPC_win32_arm-linux\bin\arm-linux)
INPUT(
C:\FPC_win32_arm-linux\units\arm-linux\rtl\cprt0.o
C:\devkitGP2X\lib\gcc\arm-linux\4.0.2\crtbegin.o
C:\devkitGP2X\sysroot\usr\lib\crti.o
sdlibltest.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\system.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\objpas.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\sysutils.o
SDL.o
gp2x_sdl_mixer.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\unix.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\errors.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\sysconst.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\unixtype.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\baseunix.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\unixutil.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\strings.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\syscall.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\types.o
C:\FPC_win32_arm-linux\units\arm-linux\pthreads\pthreads.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\ctypes.o
)
INPUT(
-lSDL
-lpthread
-lc
)
INPUT(
C:\devkitGP2X\lib\gcc\arm-linux\4.0.2\crtend.o
C:\devkitGP2X\sysroot\usr\lib\crtn.o
)
ENTRY(_start)
SECTIONS
{
PROVIDE (__executable_start = 0x010000); . = 0x010000 +0x100;
.interp : { *(.interp) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.dyn :
{
*(.rel.init)
*(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
*(.rel.fini)
*(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
*(.rel.data.rel.ro*)
*(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
*(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
*(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
*(.rel.got)
*(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
}
.rela.dyn :
{
*(.rela.init)
*(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
*(.rela.fini)
*(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
*(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
*(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
*(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
*(.rela.got)
*(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
}
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.init :
{
KEEP (*(.init))
} =0x90909090
.plt : { *(.plt) }
.text :
{
*(.text .stub .text.* .gnu.linkonce.t.*)
KEEP (*(.text.*personality*))
*(.gnu.warning)
} =0x90909090
.fini :
{
KEEP (*(.fini))
} =0x90909090
PROVIDE (_etext = .);
.rodata :
{
*(.rodata .rodata.* .gnu.linkonce.r.*)
}
. = ALIGN (0x1000) - ((0x1000 - .) & (0x1000 - 1));
.dynamic : { *(.dynamic) }
.got : { *(.got) }
.got.plt : { *(.got.plt) }
.data :
{
*(.data .data.* .gnu.linkonce.d.*)
KEEP (*(.fpc .fpc.n_version .fpc.n_links))
KEEP (*(.gnu.linkonce.d.*personality*))
}
PROVIDE (_edata = .);
PROVIDE (edata = .);
.threadvar : { *(.threadvar .threadvar.* .gnu.linkonce.tv.*) }
__bss_start = .;
.bss :
{
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(32 / 8);
}
. = ALIGN(32 / 8);
PROVIDE (_end = .);
PROVIDE (end = .);
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
}



cheers,
Paul
 
Last edited by a moderator:

gmiller1018

Member
Joined
Sep 21, 2006
Messages
336
Location
USA Florida
Website
Visit site
What I would try is a modification of the "link.res" file where currently you have
CODE

INPUT(
C:\FPC_win32_arm-linux\units\arm-linux\rtl\cprt0.o
C:\devkitGP2X\lib\gcc\arm-linux\4.0.2\crtbegin.o
C:\devkitGP2X\sysroot\usr\lib\crti.o
sdlibltest.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\system.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\objpas.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\sysutils.o
SDL.o
gp2x_sdl_mixer.o



and change it to:
CODE

INPUT(
sdlibltest.o
gp2x_sdl_mixer.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\cprt0.o
C:\devkitGP2X\lib\gcc\arm-linux\4.0.2\crtbegin.o
C:\devkitGP2X\sysroot\usr\lib\crti.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\system.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\objpas.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\sysutils.o
SDL.o
...



The logic behind this is that sdlibtest.o calls code in gp2x_sdl_mixer.o which needs other things (like the C runtime library. So you list the code in the correct order to get the linker happy. Since I am sure of what I am doing this is a SWAG (scientific wild ass guess). I am applying the logic that all of the utilities use the same linker (part of binutils) and that is the behavior it works by. This may not help but it will give us some more information.
 

paul_nicholls

Still Fresh
Joined
Nov 23, 2006
Messages
42
Gary Miller said:
What I would try is a modification of the "link.res" file where currently you have
CODE

INPUT(
C:\FPC_win32_arm-linux\units\arm-linux\rtl\cprt0.o
C:\devkitGP2X\lib\gcc\arm-linux\4.0.2\crtbegin.o
C:\devkitGP2X\sysroot\usr\lib\crti.o
sdlibltest.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\system.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\objpas.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\sysutils.o
SDL.o
gp2x_sdl_mixer.o
and change it to:
CODE

INPUT(
sdlibltest.o
gp2x_sdl_mixer.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\cprt0.o
C:\devkitGP2X\lib\gcc\arm-linux\4.0.2\crtbegin.o
C:\devkitGP2X\sysroot\usr\lib\crti.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\system.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\objpas.o
C:\FPC_win32_arm-linux\units\arm-linux\rtl\sysutils.o
SDL.o
...



The logic behind this is that sdlibtest.o calls code in gp2x_sdl_mixer.o which needs other things (like the C runtime library. So you list the code in the correct order to get the linker happy. Since I am sure of what I am doing this is a SWAG (scientific wild ass guess). I am applying the logic that all of the utilities use the same linker (part of binutils) and that is the behavior it works by. This may not help but it will give us some more information.


Hi Gary,
I tried doing that and only running the linker section of the batch file, but I got the same errors :(

cheers,
Paul
 
Last edited by a moderator:

gmiller1018

Member
Joined
Sep 21, 2006
Messages
336
Location
USA Florida
Website
Visit site
Ok .. so we have to assume that some how the linker is not finding the gp2x_sdl_mixer.o file or for some reason it can not figure out how to find the names that the C/C++ compiler's name mangling code produced.

To prove that is really using your gp2x_sdl_mixer.o file try deleting it and then try the linking part only. If it complains that the object file is missing I would assume that the name managling that the Pascal compiler uses is not compatible with the C/C++ compiler.

You could use the "-save-temps" switch with the C compile to see what the assembly looks like for the gp2x_sdl_mixer.c code and compare the names with those in the assembly file produced by the pascal compiler. Looking at the names "might" give us some clues what to do.

This might be a topic to take up on the pascal site for the pascal compiler you are using asking how to call C code from a pascal routine. I am not sure I am really helping here since I know next to nothing about this pascal development environment.
 

paul_nicholls

Still Fresh
Joined
Nov 23, 2006
Messages
42
Gary Miller said:
Ok .. so we have to assume that some how the linker is not finding the gp2x_sdl_mixer.o file or for some reason it can not figure out how to find the names that the C/C++ compiler's name mangling code produced.

To prove that is really using your gp2x_sdl_mixer.o file try deleting it and then try the linking part only. If it complains that the object file is missing I would assume that the name managling that the Pascal compiler uses is not compatible with the C/C++ compiler.

You could use the "-save-temps" switch with the C compile to see what the assembly looks like for the gp2x_sdl_mixer.c code and compare the names with those in the assembly file produced by the pascal compiler. Looking at the names "might" give us some clues what to do.

This might be a topic to take up on the pascal site for the pascal compiler you are using asking how to call C code from a pascal routine. I am not sure I am really helping here since I know next to nothing about this pascal development environment.
Ok, thanks so much for you help so far Gary :)
I will try this idea and see how I get on...

cheers,
Paul
 
Last edited by a moderator:

paul_nicholls

Still Fresh
Joined
Nov 23, 2006
Messages
42
Paul Nicholls said:
Gary Miller said:
Ok .. so we have to assume that some how the linker is not finding the gp2x_sdl_mixer.o file or for some reason it can not figure out how to find the names that the C/C++ compiler's name mangling code produced.

To prove that is really using your gp2x_sdl_mixer.o file try deleting it and then try the linking part only. If it complains that the object file is missing I would assume that the name managling that the Pascal compiler uses is not compatible with the C/C++ compiler.

You could use the "-save-temps" switch with the C compile to see what the assembly looks like for the gp2x_sdl_mixer.c code and compare the names with those in the assembly file produced by the pascal compiler. Looking at the names "might" give us some clues what to do.

This might be a topic to take up on the pascal site for the pascal compiler you are using asking how to call C code from a pascal routine. I am not sure I am really helping here since I know next to nothing about this pascal development environment.
Ok, thanks so much for you help so far Gary :)
I will try this idea and see how I get on...

cheers,
Paul


I renamed the gp2x_sdl_mixer.o file and it complained that it couldn't find it, which is fair enough.

I tried the "-save-temps" option with the C compiler and it produced a .I file that I looked through; I really didn't know what I was looking at but I didn't see anything that seemed amiss.

cheers,
Paul
 
Last edited by a moderator:

gmiller1018

Member
Joined
Sep 21, 2006
Messages
336
Location
USA Florida
Website
Visit site
You should have gotten a ".s" or ".S" file which would have been the assembly output for the C files. It is good that it complained about the gp2x_sdl_mixer.o file missing because this means that it is linking in but the name mangling is not working for the linker is not finding the routine names to match up.

I would think that there must be someone on the compiler forum for your pascal compiler that could answer this. I am not sure how the names should be constructed in C or how the pascal compiler can be made to use the C standard name mangling rules.
 

paul_nicholls

Still Fresh
Joined
Nov 23, 2006
Messages
42
Gary Miller said:
You should have gotten a ".s" or ".S" file which would have been the assembly output for the C files. It is good that it complained about the gp2x_sdl_mixer.o file missing because this means that it is linking in but the name mangling is not working for the linker is not finding the routine names to match up.

I would think that there must be someone on the compiler forum for your pascal compiler that could answer this. I am not sure how the names should be constructed in C or how the pascal compiler can be made to use the C standard name mangling rules.
Hi Garry,
Life has kept me from following up this issue for a while :(

if it helps I ran the nm.exe file on the gp2x_sdl_mixer.o file and got this output:

CODE
00000000 D THREADVARLIST_GP2X_SDL_MIXER


I don't know if this helps the detective work at all...

cheers,
Paul
 
Last edited by a moderator:

gmiller1018

Member
Joined
Sep 21, 2006
Messages
336
Location
USA Florida
Website
Visit site
If you used the "-save-temps " switch on the compile command then you should have produced an assembly output file along with the object file (.o) so we can look at that file and see what the C compiler did with the output file. The pascal web site might have people that already know how to fix this but we can continue to look at what is going on.

The output of "nm.rxe" is interesting but I have not used it to do anything other than generate assembly listings. Using the "-g" switch with nm.exe with and without the "-C" switch might be interesting.

Why don't you PM me with the "gp2x_sdl_mixer.o" file and I can look at it myself. If you can't get it in a PM then send me a PM and I will reply with my email address you could use to send it to me as a zip or the ".o".
 
Top