This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC 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]

Attribute constructor and static libraries?


A simple example illustrates the problem:

p.c------------------------------------

void f(void) __attribute__((constructor));

void f(void)
{
	printf("Hola\n");
}

main.c----------------------------------

int
main()
{
	exit(0);
}
---------------------------------------

Now try compiling the example:

gcc -c p.c
gcc -c main.c
gcc -o first main.o p.o

And also in this way:

gcc -c p.c
gcc -c main.c
ar rcs libp.a p.o
gcc -o second main.o libp.a

The second version does not work as expected!

Any clue?

Thanks,

	Paco


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