Static initializer in shared libraries on Linux #3

H . J . Lu hjl@lucon.org
Mon Sep 17 11:32:00 GMT 2001


On Mon, Sep 17, 2001 at 06:52:17PM +0200, Marcel Ruff wrote:
> > H . J . Lu wrote:
>  > Please provide a small, complete testcase.
> 
> Here it is (this time attached):
> 
> If you run the simple shell script on Linux
> 
>    ./compile.sh
> 
> it creates two shared libraries,
> an executable xy.exe (which runs fine)
> and compiles the java file (which fails on running).

Where do you get the idea to use

# ld -o libInitTest.so -shared -rpath . InitTest.o
# ld -o libxy.so -shared -rpath . xy.o

on Linux? It won't work on Linux. Please NEVER EVER use ld directly
for anything unless you know what you are doing. Please use

# gcc -o libInitTest.so -shared -rpath . InitTest.o
# gcc -o libxy.so -shared -rpath . xy.o

or

# g++ -o libInitTest.so -shared -rpath . InitTest.o
# g++ -o libxy.so -shared -rpath . xy.o


H.J.



More information about the Gcc mailing list