Adding a function to glibc?

Carlos O'Donell carlos@systemhalted.org
Thu Oct 22 15:01:00 GMT 2009


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.



More information about the Libc-help mailing list