Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlug] how to compile a C program without main() ?



Dear all,

I'm not sure how best to word the subject, as I am not sure what I should be looking to solve here.

I found this preload library (nocache) source code

http://enricozini.org/2010/tips/nocache/

and want to test it on a server running CentOS4.8 with kernel 2.6.9-89.EL to see if it reduces RAM usage when doing backups with tar (apparently, it would be run as "nocache tar .....".
However, I have been unable to link the program, only compile the object code.

During the Googling/looking for solutions, I made one addition to the code at the start of the defines. I added the line:

#define _GNU_SOURCE

since the RTLD_NEXT symbols are now extensions and not in the normal dlcfn.h header file.

So then I could successfully obtain the object code:
$ gcc -Wall -c nocache.c
$

To link I needed to link the "dl" library also, but still, I get an error owing to lack of main():

$ gcc -Wall -ldl -o nocache nocache.o
/usr/lib/gcc/i386-redhat-
linux/3.4.6/../../../crt1.o(.text+0x18): In function `_start':
: undefined reference to `main'
collect2: ld returned 1 exit status
$

Any pointers most appreciated.

Best regards,
Gernot Hassenpflug

Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links