|
-
Reef Shark
3 files: .c .c .h
I want to compile and link 2 .c files, and include 1 .h file.
I have BCC for windows, and GCC for linux. I can try this on either one. I believe I need to create a makefile, or is there an easier way?
Thanks
- 1.5GHZ Pentium M | 768MB PC2700 | ATI Radeon 9600 pro 128MB Turbo | 60GB 7200RPM | 4X DVD+RW | 15.4" WSXGA+ | 802.11b | Logitech MX310 | XP Pro | Slackware 10
-
should be able to do:
gcc -o file.o file.c
gcc -o file file.o
it's been awhile but I"m pretty sure that's right.
Oh yah, you'll prolly want to include the file in the .c files.
Last edited by anfpunk; 09-24-2003 at 01:21 AM.
-
Hammerhead Shark
Assuming the .h file is included by a #include in one of the two .c files...
gcc file1.c file2.c
or
gcc -c file1.c
gcc -c file2.c
gcc file1.o file2.o
or
gcc -c file1.c
gcc file1.o file2.c
or
gcc -c file2.c
gcc file2.o file1.c
or
any other variation on this
Note: Add -o executablename if you want an program name other than the default one.
Stay cool
and be somebody's fool this year
-
Catfish
echo "test: file1.c file2.c file.h" > Makefile
echo " gcc -o test file1.c file2.c" >> Makefile
make
After that, just type "make" to rebuild. Only works in Unix land, or if you've installed msys and mingw on your Windows system. Makes an executable called test (or test.exe under windows).
Last edited by gameboy1234; 09-25-2003 at 04:12 AM.
-
Hammerhead Shark
Originally posted by gameboy1234
echo "test: file1.c file2.c file.h" > Makefile
echo " gcc -o test file1.c file2.c" >> Makefile
make
I think the forum chopped the whitespace... should be a tab before "gcc"
Stay cool
and be somebody's fool this year
-
Catfish
Yeah that's a tab not a space.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|