GP2X How To Use Visual C++ 2005 Express


slygamer

Active Member
Joined
Sep 19, 2005
Messages
795
Location
Brisbane, Australia
Website
Visit site
I've added a page to the GP2X wiki on how to use Visual C++ 2005 Express to build GP2X applications, without using a makefile. It uses the new custom build rules feature to use the arm-linux-gcc compiler in place of the built-in C/C++ compiler and a post-build step to link it all together.

Using Visual C++ 2005 Express Edition

Now I just need my GP2X to arrive so I can run the applications. :)

Constructive comments welcome.
 
I've added a page to the GP2X wiki on how to use Visual C++ 2005 Express to build GP2X applications, without using a makefile. It uses the new custom build rules feature to use the arm-linux-gcc compiler in place of the built-in C/C++ compiler and a post-build step to link it all together.
Thank you very much.

Have you tried compiling something that uses SDL, SDL_mixer and SDL_image with your setup? I'm trying it (not with VC++ 2005 Express Ed. but with Makefiles and command line) and it works for plain SDL but not after including SDL_mixer and SDL_image (yes, they are linked as well).
 
Last edited by a moderator:
will this work with the visual c++ from visual studio 2005?


Well, Visual C++ Express edition is a free* download from Microsoft's web site, and is basically a cut-down version of VisualC++ Studio 2005 (eg. no MFC). So it should work no problems. If it doesn't however, you should be able to just grab the express version and install that.

* = free until November 2006 if I remember correct, then becomes chargable. Anyone who grabs it before then however can use it for as long as they want (it doesn't expire).

So, whether you think you need it or not, go grab it and stick it on a CD somewhere :)
 
Last edited by a moderator:
will this work with the visual c++ from visual studio 2005?


Well, Visual C++ Express edition is a free* download from Microsoft's web site, and is basically a cut-down version of VisualC++ Studio 2005 (eg. no MFC). So it should work no problems. If it doesn't however, you should be able to just grab the express version and install that.

* = free until November 2006 if I remember correct, then becomes chargable. Anyone who grabs it before then however can use it for as long as they want (it doesn't expire).

So, whether you think you need it or not, go grab it and stick it on a CD somewhere :)
aha ok thanks for the info :).
 
Last edited by a moderator:
Have you tried compiling something that uses SDL, SDL_mixer and SDL_image with your setup? I'm trying it (not with VC++ 2005 Express Ed. but with Makefiles and command line) and it works for plain SDL but not after including SDL_mixer and SDL_image (yes, they are linked as well).
I haven't tried using SDL. I'm using Rlyeh's Minimal SDK.
 
Last edited by a moderator:
That ampersand is part of the redirection of stderr to stdout so sed can reformat the output of GCC. Without the ampersand, you are redirecting stderr to a file called '1'.

I think I know what's happened here. The >& need to be escaped because it is a XML file, but your web browser is un-escaping them. Replace the >& with >& in the rules file. I'll try to work out how to get the wiki page to display it correctly.

Edit: Wiki page fixed.
 
On compiling - I get the error "Error Result 255 returned from 'C:\Windows\system\cmd.exe'" I'm guessing this is to do with some path variables?
 
Yes. Error result 255 is returned when it cannot find the executable on the path. Make sure that c:\devkitpro\devkitgp2x (if that is where you unzipped the devkit to) is in the path (Control Panel->System->Advanced->Environment Variables if you are using Windows XP) and re-start the IDE.

One other thing to do is to look at the build log that has been written to the project/debug directory. It will list the command lines that were executed.
 
The simple way to find out if your PATH is correct is to open a command prompt and type 'arm-linux-gcc' (followed by Enter) and 'sed' (followed by Enter). If either of these comes back with 'not recognized as an internal or external command', then your PATH is not setup correctly.
 
Is there any way to get only certain configurations to use the custom build rules? This would be great for compiling using "Debug" for testing out on windows, and "Debug_GP2X" for compiling straight for the device
 
Finally got this thing to compile, but it's not linking any external libraries - how would I do that?

Edit:I took the rule file provided on the wiki and modified it a bit to give another supplemental rule file.
Copy the following XML file and paste it into a file called arm-linux-link.rules in c:\devkitpro\devkitGP2X:
Code:
<?xml version="1.0" encoding="utf-8"?>
<VisualStudioToolFile
 Name="GCC Linker"
 Version="8.00"
 >
 <Rules>
  <CustomBuildRule
   Name="arm-linux-g++-link"
   DisplayName="GCC Linker"
   CommandLine="arm-linux-g++.exe $(IntDir)\*.o -o $(TargetPath) [AllOptions] [AdditionalOptions] -lpthread -static 2&gt;&amp;1 | sed -e s/(.[a-zA-Z]\+):([0-9]\+):/\1(\2):/"
   Outputs="$(TargetPath)"
   FileExtensions="*.txt"
   ExecutionDescription="$(InputFileName)"
   >
   <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]"
     Delimited="true"
     Inheritable="true"
    />
   </Properties>
  </CustomBuildRule>
 </Rules>
</VisualStudioToolFile>

1) Add this custom build rule to your project in the same way you added the compiler rule.
2) Open the Tool Build Order dialog (Project->Tool Build Order)
3) Move the entry GCC Linker to the very end, after Post-build Event Tool
4) Select Ok
5) Open the project settings (Project->Properties).
6) Open the GCC Linker category and select the General property page.
7) Fill in any additional library paths and libraries needed to build your project
8) Remove the Post-build Event as described in the wiki (otherwise you'd be trying to link twice).
9) Select Ok on the project settings dialog.
10) Add any file with the extension .txt to the project, and build as normal

This is just a hacked together way of getting things to build, and allows you to link the SDL libraries etc. The text file isn't actually used by the linker, but is just a trigger to make sure the linker is called. If anybody can tidy up how I've done this, or give an alternative better way, feel free to do so :D
 
Last edited by a moderator:
On Windows XP, this is how it is done.
1. Go to Control Panel.
2. Double-click the Settings icon.
3. Select the Advanced tab.
4. Click the Environment Variables button.
5. In the User Variables at the top, if there is an entry for Path, select that and click the Edit button. In the Value field add a semi-colon to the end followed by c:\devkitpro\devkitgp2x\bin. Click Ok all the way out.
6. If there is no entry for Path in the User Variables, click New, enter Path as the name and c:\devkitpro\devkitgp2x\bin as the value. Click Ok all the way out.
 
Kalakian posted on Dec 1 2005 at 12:56 AM said:
Is there any way to get only certain configurations to use the custom build rules? This would be great for compiling using "Debug" for testing out on windows, and "Debug_GP2X" for compiling straight for the device
I don't think so. Custom Build Rules is a good feature, but it is only half-way to being a great feature.
 
Last edited by a moderator:
Kalakian posted on Dec 1 2005 at 02:17 AM said:
Finally got this thing to compile, but it's not linking any external libraries - how would I do that?
I edited the wiki last night to re-arrange the parameters on the linker command-line so it could link pthreads. I didn't realise that order of parameters was important for linking.

Edit:I took the rule file provided on the wiki and modified it a bit to give another supplemental rule file.
Copy the following XML file and paste it into a file called arm-linux-link.rules in c:\devkitpro\devkitGP2X:

<snip>

This is just a hacked together way of getting things to build, and allows you to link the SDL libraries etc. The text file isn't actually used by the linker, but is just a trigger to make sure the linker is called. If anybody can tidy up how I've done this, or give an alternative better way, feel free to do so :D
I had tried to do that as well, but tried to make it dependant on the *.o files that the GCC Compiler build rule produces. That doesn't work, so I went with the post-build event. Adding a dummy text file to the project to trigger the linker should work, but it may try to link the files even though one or more of the source files failed to compile.

I'll give that method a bit more of a play, because it is nice to have the property pages to set additional library paths and libraries to link in.
 
Last edited by a moderator:
I had tried to do that as well, but tried to make it dependant on the *.o files that the GCC Compiler build rule produces. That doesn't work, so I went with the post-build event. Adding a dummy text file to the project to trigger the linker should work, but it may try to link the files even though one or more of the source files failed to compile.

I'll give that method a bit more of a play, because it is nice to have the property pages to set additional library paths and libraries to link in.
Yeah, I tried to use the *.o files, but as there are no *.o files actually in the project (they're just output files), it doesn't do anything.
 
Last edited by a moderator:
Still having a right game getting this setup! I think I'm half way there...GCC Linker doesn't even seem to exist :S
 
Back
Top