Re: (OT) Learning C (in order to patch nethack, so not entirely OT after all)



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
.



Relevant Pages

  • Re: Windows Compilation Madness
    ... There is a compiler, ... the compilation problems that arise in the Windows environment? ... Can a Windows expert confirm my understanding that: ... MinGW uses the VC6 runtime libraries, but the compilers ...
    (comp.lang.ruby)
  • Re: Aztec C compilers
    ... M-86 code which runs quite happily in a CP/M-86 emulator within the ... and he sure did a wonderful thing when he wrote the Windows CE Kernel ... Aztec-C compiler ever produced for everything and offer them all on ... CP/M-86 development environment for 8086 and compatible computers ...
    (comp.os.cpm)
  • Windows Compilation Madness
    ... There is a compiler, ... the compilation problems that arise in the Windows environment? ... Can a Windows expert confirm my understanding that: ... install a development environment of some sort and to manage the ...
    (comp.lang.ruby)
  • Re: compiling c-client on windows xp
    ... The compile error messages indicate that you do not have the current SDK; or at least that the security.h file that was picked up by the compiler isn't the current version. ... Then you wouldn't need to worry about the SDK install, since modern versions have the modern includes and libraries. ... The problem which you have is a C build environment setup problem on your Windows system, ...
    (comp.mail.imap)
  • Re: What is Forth?
    ... the target, and then tell me why those aren't advantages for seaForth. ... But now there is Forth hardware, ... support both a Forth development environment and the target application. ... My only point was that he said he wanted to put Forth compiler into ...
    (comp.lang.forth)