Creating Shared Object libraries
Posted: Thu Jun 16, 2016 7:33 am
Hello!
To compile userspace executables I am using full GCC cross compiler - the usual Binutils-GCC-Newlib combo, basically OS Specific Toolchain with few modifications. It works fine, compiles and links static executables without any issues.
I am going to experiment with Shared Object libraries. However, I have issues while producing one using my cross-toolchain.
Second command does not work as expected. I get error:
Obviously, I am missing something Please advise.
To compile userspace executables I am using full GCC cross compiler - the usual Binutils-GCC-Newlib combo, basically OS Specific Toolchain with few modifications. It works fine, compiles and links static executables without any issues.
I am going to experiment with Shared Object libraries. However, I have issues while producing one using my cross-toolchain.
Code: Select all
x86_64-pc-myos-gcc -c -fPIC foo.c -o foo.o
x86_64-pc-myos-gcc -shared foo.o -o libfoo.so
I configured Binutils & GCC using commands/switches:x86_64-pc-myos-gcc: error: unrecognized command line option '-shared'
Code: Select all
../binutils-src/configure --prefix=/usr/local/cross --disable-nls --disable-werror --target=x86_64-pc-myos --enable-64-bit-bfd --with-sysroot=/usr/local/cross/x86_64-pc-myos --enable-shared
../gcc-src/configure --target=x86_64-pc-myos --prefix=/usr/local/cross --disable-nls --enable-languages=c,c++ --with-newlib --with-sysroot=/usr/local/cross/x86_64-pc-myos --enable-shared