Package: gcc Version: 10.2.1
When I try to create shared libraries and link to them, I get "undefined reference to" errors, where linker cannot find referenced symbols in the shared library. I tried the same program on Debian 10 x86_64 and it links correctly. The issue can be reproduced with the following steps: Create libtest.c: cat > libtest.c << 'EOF' #include <stdio.h> void test(void) { printf("This is a test\n"); } EOF Create main.c that uses symbols from libtest: cat > main.c << 'EOF' void test(void); int main(void) { test(); } EOF Create libtest.so shared library: gcc -O2 -fPIC -DPIC -c libtest.c && \ gcc -O2 -fPIC -DPIC -shared -Wl,--default-symver -Wl,-soname,libtest.so. 1 -o libtest.so.1.0 libtest.o && \ ln -sf libtest.so.1.0 libtest.so Create main executable, linking it with libtest.so: gcc -O2 -c main.c && \ gcc -O2 -L./ -ltest -o main main.c The above step fails with the following error: /bin/ld: /tmp/ccZq9tP1.o: in function `main': main.c:(.text.startup+0x8): undefined reference to `test' collect2: error: ld returned 1 exit status Below are the specifics of my dev environment: $ uname -a Linux rp4 5.10.0-13-arm64 #1 SMP Debian 5.10.106-1 (2022-03-17) aarch64 GNU/Linux $ cat /etc/os-release PRETTY_NAME="Debian GNU/Linux 11 (bullseye)" NAME="Debian GNU/Linux" VERSION_ID="11" VERSION="11 (bullseye)" VERSION_CODENAME=bullseye ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/" $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/10/lto-wrapper Target: aarch64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 10.2.1-6' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=aarch64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 10.2.1 20210110 (Debian 10.2.1-6)