This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
__attribute__ ((constructor))
- To: gcc-bugs at gcc dot gnu dot org
- Subject: __attribute__ ((constructor))
- From: DONCIEUX Stephane <Stephane dot Doncieux at lip6 dot fr>
- Date: Wed, 23 Feb 2000 13:42:19 +0100
- Cc: Samuel Landau <Samuel dot Landau at lip6 dot fr>
Hi,
i have some problems using __attribute__ ((constructor)) on gcc 2.95.2.
in fact, it doesn't work. Here follows a simple example:
$ cat test.cpp
int main()
{
exit(0);
}
$ cat bidon.cpp
#include <iostream.h>
void initialisation (void) __attribute__ ((constructor));
void initialisation(void)
{
cout << "initialisation" << endl;
}
$ g++ -Wall -shared -lc -Wl,-soname,libbidon.so -o libbidon.so bidon.cpp
$ g++ -Wall test.cpp -o test -L. -lbidon
Results with egcs-2.91.66:
$ ./test
initialisation
$
Results with 2.95.2:
$ ./test
./test: error in loading shared libraries: libbidon.so: cannot open
shared object file: No such file or directory
$ export LD_LIBRARY_PATH=.
$ ./test
$
The function 'initialisation()' is not executed (and -L. is not taken into
account).
stephane doncieux