amandeepgautam
Programmer
I want to create a shared lib with certain libs statically linked to it. I can generate a fully shared lib as follows:
[tt]gcc -maix64 -DHAVE_CONFIG_H -I. -I./src -DHAVE_OPENSSL -I/usr/include/openssl -I/usr/include -I/usr/include/apr-1 -D_LARGEFILE64_SOURCE -I/usr/java8_64/include -shared -o libnetty_tcnative.so src/jnilib.c src/bb.c src/error.c src/native_constants.c src/ssl.c src/sslcontext.c src/sslutils.c -lc -L/opt/freeware/lib64 -lapr-1 -lssl -lcrypto -lpthread -Wl,-bnoentry -maix64 -O3 -pthread -Wl,-bnoquiet
[/tt]
If I do ldd on this lib, I get:
[tt]libnetty_tcnative.so needs:
/opt/freeware/lib64/libgcc_s.a(shr.o)
/opt/freeware/lib64/libssl.a(libssl.so.1.1.0)
/opt/freeware/lib64/libcrypto.a(libcrypto.so.1.1.0)
/usr/lib/libpthread.a(shr_xpg5_64.o)
/usr/lib/libc.a(shr_64.o)
/unix
/usr/lib/libcrypt.a(shr_64.o)
[/tt]
Now, let's say I want to remove the dependency from libs in the folder /opt/freeware. For this, I am thinking to statically link libgcc_s.a, libssl.a and libcrypto.a. What flags can I pass to gcc so that it links these libs statically? It might also be okay to link everything statically so there is no dependence on any external libs. Also, would like to mention that I use /usr/bin/ld (native) with gcc.
[tt]gcc -maix64 -DHAVE_CONFIG_H -I. -I./src -DHAVE_OPENSSL -I/usr/include/openssl -I/usr/include -I/usr/include/apr-1 -D_LARGEFILE64_SOURCE -I/usr/java8_64/include -shared -o libnetty_tcnative.so src/jnilib.c src/bb.c src/error.c src/native_constants.c src/ssl.c src/sslcontext.c src/sslutils.c -lc -L/opt/freeware/lib64 -lapr-1 -lssl -lcrypto -lpthread -Wl,-bnoentry -maix64 -O3 -pthread -Wl,-bnoquiet
[/tt]
If I do ldd on this lib, I get:
[tt]libnetty_tcnative.so needs:
/opt/freeware/lib64/libgcc_s.a(shr.o)
/opt/freeware/lib64/libssl.a(libssl.so.1.1.0)
/opt/freeware/lib64/libcrypto.a(libcrypto.so.1.1.0)
/usr/lib/libpthread.a(shr_xpg5_64.o)
/usr/lib/libc.a(shr_64.o)
/unix
/usr/lib/libcrypt.a(shr_64.o)
[/tt]
Now, let's say I want to remove the dependency from libs in the folder /opt/freeware. For this, I am thinking to statically link libgcc_s.a, libssl.a and libcrypto.a. What flags can I pass to gcc so that it links these libs statically? It might also be okay to link everything statically so there is no dependence on any external libs. Also, would like to mention that I use /usr/bin/ld (native) with gcc.