GP2X How To Use Visual C++ 2005 Express


all right, I'm still a clueless retard, but I think I'm 80% of the way to something useful and am giving it fair effort.

I followed the instructions on the wiki, got myself a little hung up on where the mouse had to be when I went into project properties, but I survived B)

I haven't added any libs, since my thought is that I shouldn't need them yet (do I?). all I want to compile is this:

Code:
#include <iostream.h>

int main()
{
	cout << "Hello World!" << endl;
	return 0;
}

I wonder if that can even be displayed on the 2x. but anyway, it chucks out a couple warnings one about an antiquated header and another about no 'newline at end of file' but seems to suck it up and continue...at least for a ways.

What I get in my debug directory is a log and an *.o file--which I thought it was supposed to clean (yes, the extension is in the list). what do I do to get it to spit out a proper executable. (I have followed the wiki on adjusting the .exe to .gpe)

is it my code? is it my lack of libs? what's the easiest way to progress? is there some test code (which perhaps doesn't require sdl) that I can use to test my setup? maybe I'm just hitting the wrong menu item or I'm completely missing the point and I need more in my project than a single cpp file.

still clueless, but as soon as I get something firm to stand on (sample code, compiler, libs), I'll feel a lot better.
 
In C++ source files, you generally do not include the .h on standard include files.

No, you will not see that output on the GP2X screen. If you had a GP2X serial cable connecting your GP2X to a serial port on your PC, you would see it on a terminal program running on your PC.

GCC expects a new line at the end of the file. So position the cursor at the end and press Enter.

The *.o files are cleaned, but cleaning happens before compiling. The compiler creates the .o files from the source files.

The linker rule requires a file to be in the project for it to be triggered. In the wiki, the linker rule uses any .txt file. So add a .txt file to your project, and make sure that the linker rule is moved down to near the other linker tools in Tool Build Order (right-click on project). This is all mentioned in the last few steps on the wiki page.

Because you are compiling C++, you will probably need to add stdc++ to your Additional Dependencies property in GCC Linker in the project properties.
 
i just set up this environment today and i can compile some examples successfully.
but i can't manage to get SDL working.

i installed the SDL files like it is said in gp2xuserguide and now the SDL files are in C:\devkitpro\devkitGP2X\include and C:\devkitpro\devkitGP2X\include\SDL and C:\devkitpro\devkitGP2X\lib (as far as i can see...)

i created a project and added the SDL Hello Pixel (http://wiki.gp2x.org/wiki/Writing_an_SDL_Hello_World)

i added the two include paths (C:\devkitpro\devkitGP2X\include and C:\devkitpro\devkitGP2X\include\SDL) and the lib path (C:\devkitpro\devkitGP2X\lib) to the project and in GCC linker there is: "pthread SDL" (i even added SDLmain, but no difference).

i get errors like this:
Code:
Linking sdltest.gpe...
C:\devkitpro\devkitGP2X\lib\libSDL.a(SDL_systhread.o): In function `RunThread':
SDL_systhread.c:(.text+0x20): undefined reference to `pthread_exit'
C:\devkitpro\devkitGP2X\lib\libSDL.a(SDL_systhread.o): In function `SDL_SYS_CreateThread':
SDL_systhread.c:(.text+0x4c): undefined reference to `pthread_attr_init'
SDL_systhread.c:(.text+0x84): undefined reference to `pthread_attr_setdetachstate'
SDL_systhread.c:(.text+0xac): undefined reference to `pthread_create'
C:\devkitpro\devkitGP2X\lib\libSDL.a(SDL_systhread.o): In function `SDL_SYS_SetupThread':
SDL_systhread.c:(.text+0x184): undefined reference to `pthread_sigmask'
and so on. i didn't quote all of them...

what is the probem? i don't get it.
 
I get these errors:
Code:
main.cpp:(.text+0x2c): undefined reference to `SDL_Init'
main.cpp:(.text+0x40): undefined reference to `SDL_SetVideoMode'
main.cpp:(.text+0xa4): undefined reference to `SDL_Flip'
I put C:\devkitpro\devkitGP2X\include and C:\devkitpro\devkitGP2X\include\SDL in the includes thing, and C:\devkitpro\devkitGP2X\lib to the library path.
Any help would be greatly appreciated.
 
GCC automatically adds the standard includes and libs folders to the search paths, so you just have to add any extra paths.

It sounds like you haven't added SDL to the Additional Dependencies property in GCC Linker.
 
GCC automatically adds the standard includes and libs folders to the search paths, so you just have to add any extra paths.

It sounds like you haven't added SDL to the Additional Dependencies property in GCC Linker.
Ok, thanks. It builds now without errors, but it won't make the .gpe. Here's the build output:
Code:
------ Build started: Project: pixel, Configuration: Debug Win32 ------
Linking pixel.gpe...
c:\devkitpro\devkitgp2x\bin\..\lib\gcc\arm-linux\4.0.2\..\..\..\..\arm-linux\bin\ld.exe: cannot find -lSDL
Build log was saved at "file://c:\Documents and Settings\Sean Roth\My Documents\Visual Studio 2005\Projects\pixel\Debug\BuildLog.htm"
pixel - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
 
Last edited by a moderator:
Ok, thanks everyone for the help. :D I finally got it producing a .gpe, so now I just need a gp2x to test it on...
Just if anyone can use this in the future, here is my setup:
In Project->(project name) Properties I have:
In GCC Compiler for Additional Include Paths I have C:\devkitpro\devkitGP2X\include\SDL.
In GCC Linker for Additional Library Paths I have C:\devkitpro\devkitGP2X\lib and for Additional Dependencies I have SDL.

It's worked that way for me (as far as I know.. I haven't tried it on an actual gp2x). There may be something not needed, so someone correct me if there's anything wrong/not needed.
 
Ok, thanks everyone for the help. :D I finally got it producing a .gpe, so now I just need a gp2x to test it on...
Just if anyone can use this in the future, here is my setup:
In Project->(project name) Properties I have:
In GCC Compiler for Additional Include Paths I have C:\devkitpro\devkitGP2X\include\SDL.
In GCC Linker for Additional Library Paths I have C:\devkitpro\devkitGP2X\lib and for Additional Dependencies I have SDL.

It's worked that way for me (as far as I know.. I haven't tried it on an actual gp2x). There may be something not needed, so someone correct me if there's anything wrong/not needed.

absolutely amazing. i set up the entire thing today (got my unit today :) ) anyways - i have exactly the same error, and now ive got the same vars in studio as well, but it still does not work.

the cmdline is:
Code:
arm-elf-ld.exe Debug\*.o -o "c:\gp2xdev\mfapp\debug\mfapp.gpe"  -L"C:\devkitPro\devkitARM\lib\" -lSDL  -static 2>&1 | sed -e s/(.[a-zA-Z]\+):([0-9]\+):/\1(\2):/

and the error:
Code:
Linking mfapp.gpe...
arm-elf-ld.exe: warning: cannot find entry symbol _start; defaulting to 00008000
Debug\main.o: In function `main':
main.cpp:(.text+0x2c): undefined reference to `SDL_Init'
main.cpp:(.text+0x40): undefined reference to `SDL_SetVideoMode'
main.cpp:(.text+0xf4): undefined reference to `SDL_Flip'

anyone got any more ideas?
 
Last edited by a moderator:
I found it. An extra slash on the lib path made it fail. Now I got another error, but that I havent had a chance to look at yet.
 
Looking at your previous post, you need to add pthread to your Additional Dependencies along with SDL. You might have to experiment with the order of them (pthread then SDL, or SDL then pthread).
 
Just if anyone can use this in the future, here is my setup:
In Project->(project name) Properties I have:
In GCC Compiler for Additional Include Paths I have C:\devkitpro\devkitGP2X\include\SDL.
In GCC Linker for Additional Library Paths I have C:\devkitpro\devkitGP2X\lib and for Additional Dependencies I have SDL.
That last bit SDL - Dependency was what got me. Now that I added it, it works and I ran the .gpe on the GP2X. Yay! :)
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.

Constructive comments welcome.
Big thanks for putting that together! :D
 
Last edited by a moderator:
Excellent! I'm glad that this setup is working for so many people now. It's so easy.

I've extended the custom build rules to include using arm-linux-ar to build libs. So now we can have a solution that includes multiple projects with one project creating the gpe and the rest building libs for that gpe. I will post the updated custom build rules and step-by-step instructions to the wiki later this week.
 
I got it working now. I switch devkit and everything worked well.

I dont really understand the relationship between custom build rules, tool order and configuration manager.

It would be nice to be able to switch between win32 compilation and target compilation with switches. The configuration manager works well for defining configurations, but the build rules does not seem to be set per configuration.

Am I missing something? I will have to look into that a little closer.
 
Custom build rules specify the commands to be executed for files with the specified extensions.

Tool order specifies when those build rules are executed. This is why the linker rule must be moved down the tool order because a linker rule must be executed after all compile build rules have been executed.

Configuration manager allows you to setup different build configurations. For example, a debug configuration with no optimization and verbose logging, and a release configuration with full optimization and minimal logging.

Unfortunately, the custom build rules are set per project, not per configuration. To have a Win32 build and a GP2X build, you need two separate projects. Perhaps in a future version of the IDE we will get per-configuration custom build rules, but at least this current version is a huge step up from previous versions of the IDE that had very primitive build rules.
 
Back
Top