This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Adding a function to glibc?


On Wed, Oct 21, 2009 at 8:11 PM, Almohri, Hussain <almohri@gmail.com> wrote:
> I removed --sysroot:
> $ gcc -I/${nheaders} -I/${nkheaders} -Wl,--rpath=${SYSROOT}/lib
> -Wl,--dynamic-linker=${SYSROOT}/lib/ld-linux.so.2/usr/lib/gcc/i586-redhat-linux/4.4.0/../../../crt1.o:
> In function `_start':
> (.text+0x18): undefined reference to `main'
> collect2: ld returned 1 exit status

Exactly what command line did you use to link your application?

The above command line is incomplete.

You need something like this:
$ gcc -I/${nheaders} -I/${nkheaders} \
-Wl,--rpath=${SYSROOT}/lib:${SYSROOT}/usr/lib \
-Wl,--dynamic-linker=${SYSROOT}/lib/ld-linux.so.2 \
-o application file1.o file2.o file3.o

Where application is the name of the binary you are creating and
file*.o are all of the object files that should be linked to produce
the application.

As with all C programs you must have a main function to act as the
"starting point" (entry point) of the program.

I recommend you read the GCC manual to learn how to use the compiler:
http://gcc.gnu.org/onlinedocs/


Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]