This is the mail archive of the
mailing list for the Cygwin project.
Re: Why won't my files link?
- From: "Elfyn McBratney" <elfyn-cygwin at exposure dot org dot uk>
- To: "cygwin" <cygwin at cygwin dot com>,"Nick Miller" <nmiller at cs dot oberlin dot edu>
- Date: Mon, 3 Feb 2003 22:32:36 -0000
- Subject: Re: Why won't my files link?
- References: <Pine.OSF.email@example.com>
> So I am new to Cygwin, but I am enjoying it so far.
> I am having a
> problem, though, please respond if you can... I have three C files (all
> ending in .c), and I can compile them with GCC by using the -c switch.
> Then, I want to link all three of the object files that I have created
> (ending in .o) and make an executable which uses all three. My file
> called main.c has two include lines, which says to include
> "io_functions.h" and "fun.h". Then I am using this line to link
> everything and make the executable...
Right. To all of the files you are tryin to compile (the *.c files and the
*.h files) reside in the same directory? If so you should be using a command
$ gcc -I.-c fun.c
So that the current directory is added to the search path for included files
(-I.) . That is ofcourse if they reside in the same directory, if not then
you just s/./path/ (replace . with the path to where the files are). And
that the file (fun.c) is just compiled (-c) .
> gcc -o main fun.o io_functions.o main.o
> I have tried this exact thing with the exact same files on a Linux system
> and it works fine, but for some reason under Cygwin it is not working. I
> am thinking that the problem lies in that my files are not being accessed
> correctly. For instance, when I want to run executables I have made in my
> cygwin/home/Owner directory, I have to use "./executablename" because for
> some reason commands do not go directly to the home directory (this is in
> the Cygwin FAQ).
Mmmm... If you mean you want to be able to call `compiled-program' instead
of `./compiled-program' at the prompt then there's two things you can do.
The first is adding a . to the PATH (that symbolises the current working
directory) environment variable
or you can add the absolute directory path to your PATH env. var., if your
going to keep all of your executables in one place, you can do
> I am wondering if I need to do something to make all of
> the files in my home directory viewable or available when doing the
> compile command above. Any ideas? Thanks so much.
You might try compiling each file (into an executable) before, in-case there
are errors, so you'll have peace of mind that they'll actually compile.
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html