compiling and linking 2 C files ...??

Thread Tools Search this Thread
Top Forums Programming compiling and linking 2 C files ...??
# 1  
Old 09-18-2001
compiling and linking 2 C files ...??

Hi mates,
I am trying to copile and link to C programs with command:

cc file1,file2

but i raises the error "file not found" ... am i doing the right way?

any suggestion will be appreciated.


# 2  
Old 09-18-2001
Try with a space in between, instead of a comma.
# 3  
Old 09-24-2001

Or, put a space after the comma.
# 4  
Old 09-29-2001
Maybe I'm reading too much in...


Maybe I'm interpreting this wrong, but you want to compile two SEPARATE progs, not use one as an include for the other?
In the first case, I yield to the other posts and say go with the space in between, but it really looks to me like you want to compile some related progs that are function declarations or something (forgive the c++, it is my first love over and above C)???
In that case, make the one that needs to be compiled first an include:

gcc -include

If that helps at all, I'm pleased,


# 5  
Old 10-02-2001

try this:

cc -c file1.c
cc file2.c file1.o

a.out is the executable created

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Linker errors linking to .a files on OS X

Basically my problem is that when I try to compile anything using ./configure && make, it fails because of linker errors. I can reproduce the behavior I'm getting as follows: I have the two following files main.c: #include <stdio.h> extern void func(void); int main(int argc, char... (5 Replies)
Discussion started by: MarshallBanana
5 Replies

2. Shell Programming and Scripting

Script for linking files with paths in 2 text files

I have 2 txt files, 1.txt and 2.txt which contain the paths to files that need to be linked. Example 1.txt: /root/001/folder2/image4.nii.gz /root/002/folder2/image4.nii.gz Example 2.txt: /root/001/folder2/image5.nii.gz /root/002/folder2/image5.nii.gz Each line represents images from... (7 Replies)
Discussion started by: LeftoverStew
7 Replies

3. SuSE

Problem compiling the kernel and linking problems in OpenSuse 12.3

Hi everyone I installed OpenSuse 12.3 and many development tools but when i propose build the kernel from the source (the first step make menuconfig) i saw this: HOSTLD scripts/kconfig/mconf /usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: warning:,... (2 Replies)
Discussion started by: bacesado
2 Replies

4. Programming

Compiling and linking Shared Libraries.

I have one C program which contains a function call. I have been given some .so and .h files. I want to know how to compile and link the c program with .so files. I tried following: $ gcc My_program.c My_program.c: In function āmainā: My_program.c:11: warning: parameter names... (3 Replies)
Discussion started by: junaid.nehvi
3 Replies

5. Shell Programming and Scripting

Recursively hard linking files -- bonehead question

I used to program ksh a while back, but I've been off in Oracle/Windows land (for clients -- not by choice) for so long that I can't remember what should be an easy thing. Here's the scenario: 1)Find all files and directories beneath some directory point (A). 2)If directory, make the... (7 Replies)
Discussion started by: scyphers
7 Replies

6. Programming

C files searching and Linking

Dear friends, First off all , let me apologize for my inexperience. I am just starting use of Linux and gcc . Actually I ve some .c files in the present directory , and now I am giving +vc <my_file1.c> <my.file2.c> <myfile3.c>. All the c files are in present directory.... (2 Replies)
Discussion started by: user_prady
2 Replies

7. UNIX for Dummies Questions & Answers

Linking Files in UNIX (shortcuts)

Hello, Can anyone tell me how I can make a file link or shortcut in UNIX 4.0, several file links where damaged during an outage examples below. Examples: file -> file -> /usr/shlib/ All of the file links that were damaged were in /shlib and point to... (3 Replies)
Discussion started by: jays337
3 Replies

8. UNIX for Dummies Questions & Answers

modifying C file and linking back to project files

hi, This is the first time I work in a big C project. All source code files are located in say directory /source/pp and all header files are in /include/pp. I've created a link to both of these directories from my home dir, say /home/ss. So in the /home/ss dir I have the /source/pp and /include/pp... (1 Reply)
Discussion started by: bruins2005
1 Replies

9. Programming

beginner at C: Need help compiling/linking with gcc

I'm trying to do something fairly simple but keep getting frustrating messages.. Here it is: I have 3 files: init.h <header> init.c <#include <curses.h> and "init.h"> main.c <#include "init.h"> now, how can I compile my main.c using gcc? ( I have a hard time making the init.o) ... (1 Reply)
Discussion started by: My_Name
1 Replies

10. Programming

Linking problem while linking to shared library

Hi I'm getting ld: fatal: option -h and building a dynamic executable are incompatible ld: fatal: Flags processing errors When I run ld -shared -L/usr/dt/lib -lDtSvc -o Workspace.o after running gcc -fPIC -I/usr/X11R6/include -I/usr/dt/include -c Workspace.c I'm... (6 Replies)
Discussion started by: laho
6 Replies
Login or Register to Ask a Question