Coding In Ubuntu


norm

aka kapakux89
Joined
Sep 29, 2006
Messages
615
Age
35
Location
Kent, England
Website
kapakux89.com
I want to learn C or C++ (not really sure, suggestions?) but need help setting up a dev environment in Ubuntu 8.04, could someone recommend a setup for a beginner? As simple as possible, but if not I'm sure I'll cope.

Also could anyone recommend any decent sites or books for learning the basics?

Thanks
 
You definitely want the pre-compiled Open2x GCC 4.1.1 "Applications toolchain, which gets unpacked into the /opt/open2x folder on your linux machine:

http://wiki.open2x.org/open2x/wiki/index.php?title=Toolchain

You can find Makefiles there as well:

http://open2x.org/open2x/index.html


For learning C, you can probably find many free online tutorials that will work. and it won't be long before someone recommends K&R's book "The C Programming Language" which you should be able to pick up new or used very cheaply somewhere. It quite short, mainly because the language itself is simple.

For C++, someone else here will recommend something, I am sure. You won't be wasting effort learning C first, however. C is the foundation of C++ and there's nothing wrong with coding in either language.
 
good tutorial for C++:
http://www.cplusplus.com/doc/tutorial/

good tutorial for learning SDL (code should work as-is on the gp2x, but look for more specific tutorials for things like controls) for graphical stuff:
http://lazyfoo.net/SDL_tutorials/index.php



make sure you learn the basics of C or C++ before using something else such as SDL for graphics functions. if you don't, you'll most likely end up with bugs and/or code that won't compile.

for compiling C / C++ in ubuntu for native x86 (run on the PC) install gcc / g++ from apt (synaptic / apt-get etc) respectively. you can use many different tools but I tend to use gedit, save to a .cpp file, then run "g++ filename.cpp" on a terminal to compile. "./a.out" to run this program. you can PM me if you get confused with these instructions / need help ^^

honestly, i haven't started compiling things for the GP2X yet. i really need to set up a dev environment.
 
Setting up a build enviroment in linux? Install compiler. done! God bless packet managers!

I'd suggest you start off with just a texteditor (gedit maybe? or nedit) and compile manually.
I can't stress that enough. I've been a teacher assistent in a java course (in university level), and by the end of the course.. basically NOONE knew how to compile outside of jgrasp. Noone knew what the runtime enviroment or compiler was. I was depressed.
Do not let IDE's tempt you when their shiny buttons!!!
 
Thanks for all your advice, I've decided to go with C++ to begin with. I've got g++ /gcc installed along with Anjuta IDE, couldn't resist the shiny buttons :p but i will do some manual compiling as suggested.

One question about the pre-compiled Open2x applications toolchain. It says on the site "DO NOT install the toolchain as ROOT", but (and this is where I show my true 'noobishness') how else am I meant to get it to /opt/open2x?

Again thank you all for the advice and tutorials, I've got alot of reading to do :)
 
norm said:
Thanks for all your advice, I've decided to go with C++ to begin with. I've got g++ /gcc installed along with Anjuta IDE, couldn't resist the shiny buttons :p but i will do some manual compiling as suggested.

One question about the pre-compiled Open2x applications toolchain. It says on the site "DO NOT install the toolchain as ROOT", but (and this is where I show my true 'noobishness') how else am I meant to get it to /opt/open2x?

Again thank you all for the advice and tutorials, I've got alot of reading to do :)
http://wiki.gp2x.org/index.php?title=Insta...amp;redirect=no

$su <enter password for root>
#cd /opt
#mkdir open2x
#chown yourusername:yourgroup open2x
#exit
$cd /
$tar xfvj path-to-open2x/filename.tar.bz2

Then, place /opt/open2x/gcc-4.1.1-glibc-2.3.6/bin in your path, usually by modifying ~/.bash_profile to contain this line:
PATH=$PATH:/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin
 
Last edited by a moderator:
I started by grabbing Eclipse 3.2, and its C/C++ packages. It is in the repos, and a very nice IDE if you're looking for one.
 
At the moment I'm just using gedit, easier than messing around with Anjuta. I may try Code::Blocks and Eclipse at some point but for now I'm keeping it simple.

I've not had much time to learn much yet. Had a problem with my dumb Mac, it has no '#' key and a few other bugs I've had to fix. But all sorted now :)

*goes back to more reading*
 
Back
Top