This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Attribute constructor and static libraries?
- From: Paco Moya <Francisco dot Moya at uclm dot es>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 11 Apr 2003 14:05:43 +0200
- Subject: 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