Archive for the 'c' Category

05th Feb 2008

CeGCC Hello World

First, copy this into a file “hello.c”

#include <windows.h>
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
{
          MessageBox(0, L"Hello!", L"CeGCC says...", MB_OK);
}

Here we have the generic MessageBox function, but with one twist: because we are in unicode, we need to prepend all string literals with ‘L’ (we could use the _T(”mystring”) macro, but I think it looks more ugly). If you try do compile

MessageBox(0, "Hello!", "CeGCC says...", MB_OK);

You will get an error complaining something about converting to LPCWSTR (meaning it wants unicode and didn’t get it).
To compile this source (you need to have first installed CeGCC), enter this at command line:

arm-wince-mingw32ce-gcc hello.c -o hello.exe

You can then copy the .exe file over to your Windows Mobile device and double click on it in the file manager to run your first program!

Posted in axim, c, how-to, ubuntu, windows mobile | No Comments »

30th Jan 2008

VensterCE: Hello World

In keeping with tradition, lets start off with a simple “hello world”

from venster.ce import *
msg = MessageBox(None,u"Hello World",u"Venster Says",MB_OK);

First line:

from venster.ce import *

This merely includes the basic functions and classes from the venster library. We will use this in every program.

msg = MessageBox(None,u"Hello World",u"Venster Says",MB_OK);

Here create a simple messagebox and store the return value in the variable “msg”. The function definition for MessageBox is MessageBox(window,message,title,buttons). Here the parent window is None, as we haven’t created one (It’s ok, windows can handle that). Next are the Message and Title strings, but make sure you keep them unicode (bad things can happen if you dont). The “buttons” variable is combination of flags. A few popular ones are MB_OK, MB_OKCANCEL, and MB_HELP for buttons, and MB_ICONWARNING and MB_ICONINFORMATION for the icon. For a full reference of the different flags, go Here.

Posted in axim, c, how-to, pocketpc, ubuntu, windows mobile | No Comments »

31st Dec 2007

Installing CeGCC on Ubuntu

On the CeGCC sourceforge download page, they give linux binaries, but in rpm format (not the .deb’s that Ubuntu uses), so to make this work, we need to install the rmps with alien:

sudo alien -i cegcc-cegcc-0.51.0-1.i586.rpm mandriva-cegcc-mingw32ce-0.51.0-1.i586.rpm

Once those are installed, we still aren’t finished, because the package installs to /opt/ so the binaries (arm-wince-cegcc-gcc etc.) aren’t available to us without using long complicated prefixes. So we just need to symlink the the binaries to our /usr/bin/.

sudo ln -s /opt/mingw32ce/bin/* /usr/bin/
sudo ln -s /opt/cegcc/bin/* /usr/bin/

(thanks to Pablo Rogina for the tip on symlinking)
After that, you’re all set!

Posted in axim, c, pocketpc, windows mobile | 3 Comments »

28th Dec 2007

Cross-Compiling for Windows Mobile on Ubuntu

There are a few compilers I’ve found that will do this:

  • the (only for windows) Pelles C compiler through WINE
  • the PocketPC-GCC ubuntu package
  • the CeGCC cross-compiler for pocketpc

Pelles C

Pelles C is a great IDE, not only for windows mobile, but also for windows smart phone and regular old windows. My only objection to it is that it takes really, really long to compile even the simplest programs. Now, this might seem a small failing to some, but having to wait up to a minute for hello world to compile drives me nuts, especially since the others compile soo much faster.
Links:

PocketPC-GCC

This package is great for general C, and (though I haven’t tried this) might be excellent for porting linux apps to the PocketPC. Unfortunately, It doesn’t come with the windows headers/libs (these can probably be added, but I’m lazy, and CeGCC comes with them pre-loaded). In a few days I will probably experiment with getting Win32 programming to work with this compiler, so check back to see if I’m successful ;).
To install this, just do “sudo apt-get install pocketpc-gcc”. You might want to install pocketpc-g++ and pocketpc-sdk as well. I haven’t found any docs/tutorials/etc. for this package, witch is part of the reason I’m hesitant to use it.

Update: On closer inspection, I’ve found that this compiler results in massively bigger files: For the standard “helloworld.c”, the resulting exe was 338kb! in contrast to the 10kb exe compiled by CeGCC ;). Thats it, I’m definitely sticking w/ cegcc.

CeGCC

This is my champion for the moment, and the one I’m leaning win32 c on. It comes with the windows and pocketpc specific headers (though no directx or opengl). This will be the one that I will be using in my upcoming tutorials.
Links:

My CeGCC Tutorials:

Posted in axim, c, how-to, pocketpc, ubuntu, windows mobile | No Comments »

27th Dec 2007

Dell Axim

A few weeks ago, I got a Dell Axim x51v, running Windows Mobile 5 (ouch), and this has consumed most of my tinkering time since (which is the reason, along with school, that I hav’nt posted anything in a while). So I plan to do a series of posts on Dell Axims, Windows Mobile, Programs, and Axim+Ubuntu in the near future.

Posted in axim, c, ubuntu | No Comments »

12th Nov 2007

Installing Qosmic on Ubuntu

It took some doing to install Qosmic (a flam3 fractal generator) on Ubuntu, so i figured i’d package it up into a simple little bin file.
Download as text

sudo apt-get install libqt4-dev libpng12-dev libjpeg62-dev libxml2-dev expat
wget http://students.washington.edu/bitsed/qosmic/public/qosmic-1.1.2.tar.bz2
tar -jxvf qosmic-1.1.2.tar.bz2
cd qosmic
./build.sh

For some examples of what Qosmic (and flam3) can do, head over to my deviantArt gallery.

Posted in c, ubuntu | 3 Comments »

10th Nov 2007

MandelBrot

I’ve been playing around with Mandelbrot fractals over the past couple of days, and ive come up with a pretty reasonable Generator (first written in python, and then in c for speed).
Source:

Setup:

  • Python: make sure you have python and pygame installed, then run “python mandelbrot.py”
  • C: (on linux) type “gcc mandelbrot.c -lm -lSDL -o mandelbrot”
    when that finishes, just run “mandelbrot”

Usage:

  • Click somewhere to zoom in.
  • right-click to increase the detail.
  • Ctrl-click to zoom out.
  • Ctrl-right-click to decrease the detail.

Compiled for Ubuntu Feisty Fawn
I took a bunch of screenshots of my program at various zooms (Flickr page)
Here are my favorite:






Posted in c, python | No Comments »