Hi
I am trying to cross compile a simple program for Windows CE using CodeBlocks. I am using mingw32ce (part of CEGCC) which is a set of tools and libraries for building WCE programs on XP. And some WCE SDL libraries I found here:
http://users.uoa.gr/~knakos/scummvm/libraries/release-0-10-0/wince-gcc-libs.tar.bz2

I have succeded in building and running the following program.

Link Libraries:
C:\wince-sdl-gcc-libs\libs\lib\SDL.lib
C:\mingw32ce\arm-mingw32ce\lib\libmingw32.a

Compiler search dirs:
C:\wince-sdl-gcc-libs\libs\include
C:\cygwin\include
C:\MinGW\include

Linker search dirs:
C:\wince-sdl-gcc-libs\libs\lib
C:\cygwin\lib
C:\MinGW\lib

C compiler: arm-mingw32ce-gcc-4.4.0.exe
Linker: arm-mingw32ce-gcc-4.4.0.exe

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <windows.h>
#include <SDL/SDL.h>

const int SCREEN_WIDTH = 640;const int SCREEN_HEIGHT = 480;const int SCREEN_DEPTH = 32;
SDL_Surface *gScreen;

int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
{
//MessageBoxW(0, L"HELLO!", L"H3LLO!", 0);
//fprintf(stderr,"%s: %s %s","FUNCTION","filename","EOL");
Uint8 *p;int x = 10;int y = 20;

	SDL_Init(SDL_INIT_VIDEO);      /* Initialize the screen / window */
    gScreen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_DEPTH, SDL_SWSURFACE);      /* Make p point to the place we want to draw the pixel */
    p = (Uint8 *)gScreen->pixels + y * gScreen->pitch + x * gScreen->format->BytesPerPixel;      /* Draw the pixel! */
    *p=0xff;      /* update the screen (aka double buffering) */
    SDL_Flip(gScreen);
    SDL_Delay(10000);
    return(0);
}

using -v on the Linker command I get:

-------------- Build: Debug in WinCETest ---------------
Compiling: main.c
Linking console executable: bin\Debug\WinCETest.exe
Using built-in specs.
Target: arm-mingw32ce
Configured with: /home/cartman/cegcc/src/gcc-4.4.0/configure --with-gcc --with-gnu-ld --with-gnu-as --build=i686-pc-cygwin --target=arm-mingw32ce --host=i686-pc-cygwin --prefix=/opt/mingw32ce --enable-threads=win32 --disable-nls --enable-languages=c,c++ --disable-win32-registry --disable-multilib --disable-interwork --without-newlib --enable-checking --with-headers --disable-__cxa_atexit
Thread model: win32
gcc version 4.4.0 (GCC) 
COMPILER_PATH=/cygdrive/c/mingw32ce/bin/../libexec/gcc/arm-mingw32ce/4.4.0/:/cygdrive/c/mingw32ce/bin/../libexec/gcc/:/cygdrive/c/mingw32ce/bin/../lib/gcc/arm-mingw32ce/4.4.0/../../../../arm-mingw32ce/bin/
LIBRARY_PATH=/cygdrive/c/mingw32ce/bin/../lib/gcc/arm-mingw32ce/4.4.0/:/cygdrive/c/mingw32ce/bin/../lib/gcc/:/cygdrive/c/mingw32ce/bin/../lib/gcc/arm-mingw32ce/4.4.0/../../../../arm-mingw32ce/lib/
COLLECT_GCC_OPTIONS='-v' '-LC:/wince-sdl-gcc-libs/libs/lib' '-LC:/cygwin/lib' '-LC:/MinGW/lib' '-o' 'bin/Debug/WinCETest.exe'
 /cygdrive/c/mingw32ce/bin/../libexec/gcc/arm-mingw32ce/4.4.0/collect2.exe -Bdynamic -o bin/Debug/WinCETest.exe /cygdrive/c/mingw32ce/bin/../lib/gcc/arm-mingw32ce/4.4.0/../../../../arm-mingw32ce/lib/crt3.o -LC:/wince-sdl-gcc-libs/libs/lib -LC:/cygwin/lib -LC:/MinGW/lib -L/cygdrive/c/mingw32ce/bin/../lib/gcc/arm-mingw32ce/4.4.0 -L/cygdrive/c/mingw32ce/bin/../lib/gcc -L/cygdrive/c/mingw32ce/bin/../lib/gcc/arm-mingw32ce/4.4.0/../../../../arm-mingw32ce/lib obj/Debug/main.o C:/wince-sdl-gcc-libs/libs/lib/SDL.lib C:/mingw32ce/arm-mingw32ce/lib/libmingw32.a -lmingw32 -lgcc -lgcc_eh -lceoldname -lmingwex -lcoredll -lcoredll -lmingw32 -lgcc -lgcc_eh -lceoldname -lmingwex -lcoredll
Process terminated with status 0 (0 minutes, 1 seconds)
0 errors, 0 warnings

But if I add the fprintf() then I get the following Link error:

obj/Debug/main.o: In function `WinMain':
C:/Documents and Settings/me/My Documents/gp2x/projects/WinCETest/main.c:38: undefined reference to `_iob'
collect2: ld returned 1 exit status

I am a bit lost. I would rather avoid installing a MSoft IDE.

Peter

Hi
I solved it

I was accidentally linking in non ARM libraries. Even if this built, it would obviously fail when I tried to run it on the ARM device.

The fix was to remove some Linker search directories that pointed to non ARM libraries (eg cygwin)

Peter

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.