Re: (OT) Learning C (in order to patch nethack, so not entirely OT after all)
- From: Janis <janis_papanagnou@xxxxxxxxxxx>
- Date: Wed, 21 Nov 2007 05:23:03 -0800 (PST)
On 21 Nov., 13:31, dogscoff <dogsc...@xxxxxxxxxxxxxx> wrote:
I've decided to have a go at learning C. [...]
I will have to use this winXP machine for my tuition, [...]
I've downloaded the gnu C compiler for Windows and installed it.
Are you working with the GNU compiler in a pure Windows environment?
Or do you use a Cygwin environment? (It may be helpful to download the
latter to have a Unix'y environment available; that would be the way I
go, but I've heared about other environments that are more popular on
Windows, the ported GNU compiler DJGPP, but I don't know anything
about it's development environment.)
But I'm stuck already. Something neither the tutorial nor the gcc docs
mention is where I should be working.
Usually you create some project home directory which is somewhere
beneath your own home directory.
Anyway, what I can't figure out is where I should store the .c files
I've written, what folder I should cd to before trying to compile
stuff, and whether the compiler just knows where all the libraries and
whatnot are kept or whether I have to tell it where to look in the .c
file or the compiler's parameters or what.
In the most simple setup you will call the compiler from the directory
where your .c files are located. I assume that the gcc installation
procedure has set up the paths to the executables (compiler, linker)
and to the system libraries and system include files (lib and include)
correctly.
So far I can't even compile a simple "hello world". (The "hello world"
demonstration program promised by gcc's documentation doesn't exist,
by the way, so no help there.) The "undefined reference" errors that
\usr\m6811-elf\bin\gcc.exe spits out seem to indicate that it doesn't
recognise the print command I'm using, which kind of implies that
maybe it hasn't been able to find stdio to #include it.
To define additional include paths use the -I option to the compiler,
as in gcc -I. -I/home/dogscoff/projects/include -I/usr/games/include
in addition to the other options (like -L to specify non-default
linkpaths, -l to add non-default libraries).
If I can just get off the starting blocks and compile a "hello world"
I'm sure I can build on that and learn lots of stuff on my own with
only very occasional appeals for help. Assume a complete noob here, I
can put up with being patronised if it will just get me off the
ground.
Thanks,
a potential nethack code contributor.
If you want to focus on NH contributions another approach might be
more effective; create a standard source environment to compile
Nethack (I seem to recall it's described in the NH Wiki) and modify
that environment in small steps.
Janis
.
- Follow-Ups:
- References:
- Prev by Date: Re: {ot} non-Google Groups free news interface
- Next by Date: Re: (OT) Learning C (in order to patch nethack, so not entirely OT after all)
- Previous by thread: (OT) Learning C (in order to patch nethack, so not entirely OT after all)
- Next by thread: Re: (OT) Learning C (in order to patch nethack, so not entirely OT after all)
- Index(es):
Relevant Pages
|