Having A Bit Of Trouble Compiling


-pete-

Still Fresh
Joined
Oct 11, 2006
Messages
11
Hey guys,

I've recently tried installing the SDL libraries on my PC to start deving for the GP2X but I've hit a bit of a brick wall. I've managed to get a windows build up and running without too much trouble but when I try to do a GP2X build I get the following...

CODE

1>------ Build started: Project: SDL_GP2X, Configuration: Debug Win32 ------
1>Linking SDL_GP2X.gpe...
1>arm-linux-gcc.exe: Debug\*.o: Invalid argument
1>arm-linux-gcc.exe: no input files
1>main.cpp
1>arm-linux-gcc.exe: no input files
1>Embedding manifest...
1>mt.exe : general error c10100b1: Failed to load file "..\SDL_Basic\Debug\SDL_GP2X.gpe". The system cannot find the file specified.
1>Build log was saved at "file://c:\devkitPro\Source\SDL_Basic\SDL_GP2X\Debug\BuildLog.htm"
1>SDL_GP2X - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



I'm following the setup from here: http://wiki.gp2x.org/wiki/Using_Visual_C_2...Express_Edition
I've copied the SDL libs into my C:/devkitpro/devkitgp2x folders, arm-linux-gcc.exe is in my C:\devkitpro\devkitgp2x\bin folder and to my knowledge everything is where it should be. Any ideas what could be wrong?

I'm running windows vista business 2005 (x86) and microsoft visual studio 2008. All my PATHS are working correctly (i think)
 
Sorry for the probably useless response, as I know nothing about compiling under Visual C Express, but the "Configuration: Debug Win32" part of your log seems a bit odd if you're supposed to be compiling for the GP2X...

Personally, if I was using Windows, I'd ditch your current setup and use yaustar's pre-configured Code::Blocks:

http://archive.gp2x.de/cgi-bin/cfiles.cgi?0,0,0,0,14,2295
 
fishybawb said:
Sorry for the probably useless response, as I know nothing about compiling under Visual C Express, but the "Configuration: Debug Win32" part of your log seems a bit odd if you're supposed to be compiling for the GP2X...

Personally, if I was using Windows, I'd ditch your current setup and use yaustar's pre-configured Code::Blocks:

http://archive.gp2x.de/cgi-bin/cfiles.cgi?0,0,0,0,14,2295



Nice idea fishy but I need this for a uni project and they only allow visual studio (its 2008 pro btw, not express if that makes a difference) I might try to import it in on the uni machines after tho :unsure:
 
Last edited by a moderator:
You can setup Visual Studio project to compile via a makefile which would be your best bet if your University is restricting your tool usage.

This part looks wrong though:
CODE
1>Linking SDL_GP2X.gpe...
1>arm-linux-gcc.exe: Debug\*.o: Invalid argument

It is trying to link using the compiler executable rather then the linker executable.
 
yaustar said:
You can setup Visual Studio project to compile via a makefile which would be your best bet if your University is restricting your tool usage.
I'm looking into that now, is there a simple open makefile that I could edit and use?

yaustar said:
This part looks wrong though:
CODE
1>Linking SDL_GP2X.gpe...
1>arm-linux-gcc.exe: Debug\*.o: Invalid argument

It is trying to link using the compiler executable rather then the linker executable.
Errrr... wut? What would I need to change to get it using the right one? It never creates a .o file as far as I know.
 
Last edited by a moderator:
QUOTE
I'm looking into that now, is there a simple open makefile that I could edit and use?

I believe there is one with Guyfawkes SDL test program in the file archive.

QUOTE
Errrr... wut? What would I need to change to get it using the right one? It never creates a .o file as far as I know.

I assume you roughly know the pipeline in how a compiler creates a binary executable? If not, ask your lecturer to explain.

I don't know what you need to change as I use Code::Blocks for cross development.

Edit: I am looking at the custom build rules and this part looks wrong:
CODE
<CustomBuildRule
Name="arm-linux-link"
DisplayName="GCC Linker"
CommandLine="arm-linux-gcc.exe $(IntDir)\*.o -o &quot;$(TargetPath)&quot; [AllOptions] [AdditionalOptions] -static 2&gt;&amp;1 | sed -e s/(.[a-zA-Z]\+):([0-9]\+):/\1(\2):/"
Outputs="never-exists"
FileExtensions="*.link"
ExecutionDescription="Linking $(TargetFileName)..."
>

Someone correct me if I am wrong but shouldn't this be:
CODE
<CustomBuildRule
Name="arm-linux-link"
DisplayName="GCC Linker"
CommandLine="arm-linux-ld.exe $(IntDir)\*.o -o &quot;$(TargetPath)&quot; [AllOptions] [AdditionalOptions] -static 2&gt;&amp;1 | sed -e s/(.[a-zA-Z]\+):([0-9]\+):/\1(\2):/"
Outputs="never-exists"
FileExtensions="*.link"
ExecutionDescription="Linking $(TargetFileName)..."
>
 
Last edited by a moderator:
thanks yaustar, thats not the makefile I have, mine looks like this:

CODE
<CustomBuildRule
Name="arm-linux-gcc"
DisplayName="GCC Compiler"
CommandLine="arm-linux-gcc.exe -c [AllOptions] [AdditionalOptions] -o $(IntDir)\$(InputName).o [inputs] 2&gt;&amp;1 | sed -e s/(.[a-zA-Z]\+):([0-9]\+):/\1(\2):/"
Outputs="$(IntDir)\$(InputName).o"
FileExtensions="*.c;*.cpp"
ExecutionDescription="$(InputFileName)"
>


Is that wrong? I can't remember where I got the file from, I think it was the GP2X wiki :/
 
Last edited by a moderator:
-pete- said:
thanks yaustar, thats not the makefile I have, mine looks like this:

CODE
<CustomBuildRule
Name="arm-linux-gcc"
DisplayName="GCC Compiler"
CommandLine="arm-linux-gcc.exe -c [AllOptions] [AdditionalOptions] -o $(IntDir)\$(InputName).o [inputs] 2&gt;&amp;1 | sed -e s/(.[a-zA-Z]\+):([0-9]\+):/\1(\2):/"
Outputs="$(IntDir)\$(InputName).o"
FileExtensions="*.c;*.cpp"
ExecutionDescription="$(InputFileName)"
>


Is that wrong? I can't remember where I got the file from, I think it was the GP2X wiki :/

That is right as it is building the object files. The part that mine was referring to is the linker stage. Note the name tag.

To save any further confusion, this is what I think the rules file should look like given the errors:
CODE
<?xml version="1.0" encoding="utf-8"?>
<VisualStudioToolFile
Name="GCC Compiler"
Version="8.00"
>
<Rules>
<CustomBuildRule
Name="arm-linux-gcc"
DisplayName="GCC Compiler"
CommandLine="arm-linux-gcc.exe -c [AllOptions] [AdditionalOptions] -o $(IntDir)\$(InputName).o [inputs] 2&gt;&amp;1 | sed -e s/(.[a-zA-Z]\+):([0-9]\+):/\1(\2):/"
Outputs="$(IntDir)\$(InputName).o"
FileExtensions="*.c;*.cpp"
ExecutionDescription="$(InputFileName)"
>
<Properties>
<StringProperty
Name="IncludePaths"
DisplayName="Additional Include Paths"
Description="Specifies one or more directories to add to the include path; use semi-colon delimited list if more than one."
Switch="-I&quot;[value]&quot;"
Delimited="true"
Inheritable="true"
/>
<BooleanProperty
Name="WarningsAsErrors"
DisplayName="Warnings As Errors"
Description="Treat warnings as errors"
Switch="-Werror"
/>
<EnumProperty
Name="OptimizationLevel"
DisplayName="Optimization Level"
Description="Set the optimization level"
>
<Values>
<EnumValue
Value="0"
DisplayName="Default"
/>
<EnumValue
Value="1"
Switch="-O0"
DisplayName="No Optimization"
/>
<EnumValue
Value="2"
Switch="-O1"
DisplayName="Simple Optimization"
/>
<EnumValue
Value="3"
Switch="-O2"
DisplayName="Optimize for Speed"
/>
<EnumValue
Value="4"
Switch="-Os"
DisplayName="Optimize for Size"
/>
<EnumValue
Value="5"
Switch="-O3"
DisplayName="Maximum Optimization"
/>
</Values>
</EnumProperty>
<StringProperty
Name="PreprocessorDefines"
DisplayName="Preprocessor Defines"
Description="Specifies one or more preprocessor defines. Separate multiple defines with a semi-colon."
Switch="-D[value]"
Delimited="true"
Inheritable="true"
/>
<EnumProperty
Name="WarningLevel"
DisplayName="Warning Level"
Description="Set the level of warnings that are displayed."
>
<Values>
<EnumValue
Value="0"
DisplayName="Default"
/>
<EnumValue
Value="2"
Switch="-Wall"
DisplayName="All"
/>
</Values>
</EnumProperty>
</Properties>
</CustomBuildRule>
<CustomBuildRule
Name="arm-linux-link"
DisplayName="GCC Linker"
CommandLine="arm-linux-ld.exe $(IntDir)\*.o -o &quot;$(TargetPath)&quot; [AllOptions] [AdditionalOptions] -static 2&gt;&amp;1 | sed -e s/(.[a-zA-Z]\+):([0-9]\+):/\1(\2):/"
Outputs="never-exists"
FileExtensions="*.link"
ExecutionDescription="Linking $(TargetFileName)..."
>
<Properties>
<StringProperty
Name="LibPaths"
DisplayName="Additional Library Paths"
Description="Specifies one or more directories to add to the lib path; use semi-colon delimited list if more than one."
Switch="-L&quot;[value]&quot;"
Delimited="true"
Inheritable="true"
/>
<StringProperty
Name="Libraries"
DisplayName="Additional Dependencies"
Description="Specifies one or more libraries to link to; use semi-colon delimited list if more than one."
Switch="-l[value]"
DefaultValue="pthread"
Delimited="true"
Delimiters=";, "
Inheritable="true"
/>
</Properties>
</CustomBuildRule>
<CustomBuildRule
Name="arm-linux-ar"
DisplayName="GCC Archiver"
CommandLine="arm-linux-ar rcs [AdditionalOptions] &quot;$(TargetPath)&quot; $(IntDir)\*.o"
Outputs="never-exists"
FileExtensions="*.ar"
ExecutionDescription="Creating library $(TargetFileName)..."
>
<Properties>
</Properties>
</CustomBuildRule>
<CustomBuildRule
Name="arm-940-link"
DisplayName="GCC 940 Linker"
CommandLine="make_940_bin.bat $(TargetPath) $(TargetDir)$(TargetName).bin [AllOptions] [AdditionalOptions] $(IntDir)\*.o"
Outputs="never-exists"
FileExtensions="*.940"
ExecutionDescription="Linking 940 $(TargetFileName)..."
>
<Properties>
<StringProperty
Name="LibPaths"
DisplayName="Additional Library Paths"
Description="Specifies one or more directories to add to the lib path; use semi-colon delimited list if more than one."
Switch="-L[value]"
Delimited="true"
Inheritable="true"
/>
<StringProperty
Name="Libraries"
DisplayName="Additional Dependencies"
Description="Specifies one or more libraries to link to; use semi-colon delimited list if more than one."
Switch="-l[value]"
DefaultValue="pthread"
Delimited="true"
Delimiters=";, "
Inheritable="true"
/>
<StringProperty
Name="EntryPoint"
DisplayName="Entry point for 940T CPU"
Description="Specifies where the execution starts"
Switch="-e[value]"
Delimited="true"
Inheritable="true"
/>
</Properties>
</CustomBuildRule>
</Rules>
</VisualStudioToolFile>
 
Last edited by a moderator:
Thanks yaystar, I get what you mean (sorry for being thick, its pretty early) I've c+p your makefile but I'm not getting a build still, all i get is this...

CODE
1>Deleting intermediate and output files for project 'GP2X_SDL', configuration 'Debug|Win32'
1>main.cpp
1>Linking GP2X_SDL.gpe...
1>arm-linux-ld.exe: cannot find /usr/lib/ inside c:\devkitpro\devkitgp2x\bin\../sysroot
1>Embedding manifest...
1>mt.exe : general error c10100b1: Failed to load file ".\Debug\GP2X_SDL.gpe". The system cannot find the file specified.



what does arm-linux-ld.exe do exactly? Why wouldn't this be working?
 
arm-linux-ld.exe is the linker (Again, ask your University lecturer how a binary created from source).

It can't find the library paths so I am guessing the library paths have been setup incorrectly. Without the project in front of me, I am only guessing here.

If you can upload your entire project, it would be useful to look at.
 
yaustar said:
arm-linux-ld.exe is the linker (Again, ask your University lecturer how a binary created from source).

It can't find the library paths so I am guessing the library paths have been setup incorrectly. Without the project in front of me, I am only guessing here.

If you can upload your entire project, it would be useful to look at.
Okay, I've bundled it into a rar

http://www.petedermott.com/SDL_Basic.rar
 
Last edited by a moderator:
You can try adding the usr/lib directory explicitly. You should find it in devkitGP2x/sysroot/usr/lib

I can't open your project because it was created with a new version of VS then the one I have at work.
 
yaustar said:
You can try adding the usr/lib directory explicitly. You should find it in devkitGP2x/sysroot/usr/lib

I can't open your project because it was created with a new version of VS then the one I have at work.
Late bump!

So I've really got to compile this now, I've being routing around with visual studio for ages and I've just had enough. I've downloaded and installed codeblocks, standard SDL test works fine but my crappy pacman game thing just won't run, it compiles all the way down to the final link but then i get the following when building for the GP2X

CODE
c:\devkitgp2x\bin\..\sysroot\usr\lib\crt1.o||In function `_start':|
..\sysdeps\arm\elf\start.S|94|undefined reference to `main'|


Here's the full solution complete with code::blocks project. The code::blocks install is done using the file linked above.

EDIT: Building in windows goes fine till I try to run, where i get a dialog box with this:
CODE
Program received signal sigsegv, Segmentation fault.


Going into the backtrace I get this:
CODE
#0 00401AEF SDL_Toolbox::GFX_DrawImage() (??:confused:?)
#1 004016B5 GameLevel::drawGrid() (??:confused:?)
#2 00401E74 SDL_main() (??:confused:?)
#3 00402D8B console_main(argc=1, argv=0x3f2820) (./src/main/win32/SDL_win32_main.c:217)
#4 00402F69 WinMain(hInst=0x400000, hPrev=0x0, szCmdLine=0x241f05 "", sw=10) (./src/main/win32/SDL_win32_main.c:353)
#5 004027E8 main() (??:confused:?)
 
Last edited by a moderator:
-pete- said:
CODE
c:\devkitgp2x\bin\..\sysroot\usr\lib\crt1.o||In function `_start':|
..\sysdeps\arm\elf\start.S|94|undefined reference to `main'|
Sounds like it hasn't been linked properly with the usual C library - it's telling you it can't find a main() function which is pretty vital in a C program because that's where it starts. You might want to look at your linker options and check your code defines main() properly. It looks like you've done everything in WinMain and forgotten that that function is only used on Windows programs.

-pete- said:
CODE
#0 00401AEF SDL_Toolbox::GFX_DrawImage() (??:confused:?)
#1 004016B5 GameLevel::drawGrid() (??:confused:?)
#2 00401E74 SDL_main() (??:confused:?)
#3 00402D8B console_main(argc=1, argv=0x3f2820) (./src/main/win32/SDL_win32_main.c:217)
#4 00402F69 WinMain(hInst=0x400000, hPrev=0x0, szCmdLine=0x241f05 "", sw=10) (./src/main/win32/SDL_win32_main.c:353)
#5 004027E8 main() (??:confused:?)
Looks like your image drawing routine's crashed. Could be a million and one things.
 
Last edited by a moderator:
Change this line:
CODE
int SDL_main( int argc, char* argv[] )

to
CODE
int main( int argc, char* argv[] )

That should fix the GP2X build.

I don't think SDL_BlitSurface checks for NULL images, you might want to do a NULL check there.
CODE
int GameLevel::initGrid (int x, int y)
{
// Loads Mario.png into an SDL_Surface, imgMario.
imgBlockCell = IMG_Load( "../assets/0.png" );
imgClearCell = IMG_Load( "../assets/1.png" );
imgCollectable = IMG_Load( "../assets/2.png" );
imgPowerPill = IMG_Load( "../assets/3.png" );
imgGate = IMG_Load( "../assets/4.png" );
return 1;
}

You would also want to check that these files exist in the correct place and NULL check the pointer at this stage.
 
Amazingly I've actually kinda got a normal build running on both Vis and code::blocks, the only problem is that I get this

CODE
undefined reference to `IMG_Load'
when I do a gp2x build. Are there specific SDL_image libs for the GP2X?
 
You are missing a library from the link line, could be SDL_Image.

Edit: Hm.. I think I may have screwed up the order of the libraries for the GP2X. This:
CODE
-static -lSDL_gfx -lSDL_ttf -lfreetype -lSDL_image -ljpeg -lpng12 -lz -lSDL_mixer -lvorbisidec -lmikmod -lmad -lSDL -lgcc -lm -lc -lexpat -lpthread -msoft-float

Should be:
CODE
-static -lfreetype -lSDL_image -lSDL_gfx -lSDL_ttf -ljpeg -lpng12 -lz -lSDL_mixer -lvorbisidec -lmikmod -lmad -lSDL -lgcc -lm -lc -lexpat -lpthread -msoft-float


Or something similar. SDL_gfx should be right of SDL_image I think.
 
Back
Top