This is the mail archive of the gcc-bugs@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]

__attribute__ ((constructor))


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

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