So, I have modified the gcc line to:
$: sudo gcc mycode.c -o mycode -L. -lmylib myfuns.o
.... to specify mycode.c file. Below are the mycode.c and myfuncs.c
files. Here is the new error that I am getting:
$ sudo gcc mycode.c -o mycode -L. -lmylib myfuns.o
mycode.c: In function 'main':
mycode.c:7: warning: return type of 'main' is not 'int'
/tmp/ccgzNw0T.o: In function `main':
mycode.c:(.text+0x1d): undefined reference to `myfun1'
mycode.c:(.text+0x22): undefined reference to `myfun2'
collect2: ld returned 1 exit status
So, even though I am declaring the prototypes in mycode.c file as
extern functions, the compiler still complains.
AND here are my files.
---> mycode.c
#include <stdio.h>
extern void myfun1();
extern void myfun2();
void main() {
myfun1();
myfun2();
}
---> myfuncs.c
#include <stdio.h>
void fun1() {
printf("This is fun1()\n");
}
void fun2() {
printf("This is fun2()\n");
}
bobrics wrote:
Yes, I do have a main function in mycode.c file
Ben Pfaff wrote: "bobrics" <bo*****@gmail.com> writes:
/usr/lib/gcc/i486-linux-gnu/4.0.2/../../../../lib/crt1.o: In function
`_start':
../sysdeps/i386/elf/start.S:115: undefined reference to `main'
Does your program have a main() function?
--
"Am I missing something?"
--Dan Pop