user42933
user42933

Reputation: 15

Error in object file while compiling on gcc

I have several .h files which are included in the beginning of a .c file.

When I compile the .c file using the -c flag :

gcc -Wall -c parserv9-3.c

There are no errors, or any warnings.

However when I remove the -c flag it gives an error in the temporary object file.

That is, when I run

gcc -Wall parserv9-3.c

I get the following error :

/tmp/cc5IWBiC.o: In function `parseInputSourceCode':
parserv9-3.c:(.text+0x204b): undefined reference to `getStream'
collect2: error: ld returned 1 exit status

What is the problem? Any help would be greatly appreciated.

Upvotes: 0

Views: 790

Answers (1)

littleadv
littleadv

Reputation: 20272

-c flag means compile only, not link. When you remove it - gcc will also link the object into an executable (invoke the ld command, rather), and then it must find all the referenced external symbols.

In your case, the symbol getStream doesn't exist. It's probably in a different .c file.

Upvotes: 1

Related Questions