Page 1 of 1

Link error undefined reference to _getentropy.o

Posted: Sun Jul 21, 2024 8:20 am
by cy33hc
Hi. I'm using devkitA64-r26.1-2 and getting a link error below.

/opt/devkitpro/devkitA64/bin/../lib/gcc/aarch64-none-elf/14.1.0/../../../../aarch64-none-elf/bin/ld: /opt/devkitpro/devkitA64/bin/../lib/gcc/aarch64-none-elf/14.1.0/../../../../aarch64-none-elf/lib/pic/libg.a(libc_a-sysgetentropy.o): in function `getentropy':
(.text.getentropy+0x28): undefined reference to `_getentropy_r'
collect2: error: ld returned 1 exit status

Re: Link error undefined reference to _getentropy.o

Posted: Sun Jul 21, 2024 3:20 pm
by WinterMute
What's pulling in getentropy?

We can have a look & see what we can do, will take a little toolchain fiddling though.

Re: Link error undefined reference to _getentropy.o

Posted: Sun Jul 21, 2024 7:45 pm
by cy33hc
I believe it's from libarchive. If I exclude libarchive, then I just get a bunch of link errors related to libarchive and don't see getentropy link error

Re: Link error undefined reference to _getentropy.o

Posted: Sun Jul 21, 2024 10:11 pm
by cy33hc
I built libarchive myself and I dont get the getentropy link error. Used cmake instead. Used same version 3.7.2 and patches distributed with pacman.

cmake -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Switch.cmake -DBUILD_TESTING=OFF -DENABLE_BZip2=OFF -DENABLE_CAT=OFF -DENABLE_CPIO=OFF -DENABLE_TAR=OFF -DENABLE_TEST=OFF -DENABLE_UNZIP=OFF -DENABLE_ZSTD=ON -DENABLE_OPENSSL=OFF ..

Re: Link error undefined reference to _getentropy.o

Posted: Tue Jul 23, 2024 5:43 pm
by WinterMute
Your self build has disabled half the options in libarchive and I'm not sure that's actually the source of your issue. As far as I can tell none of our portlibs reference getentropy so I'm not really sure what's happening. Can you by any chance provide a small code sample which shows the error you've reported?

Re: Link error undefined reference to _getentropy.o

Posted: Wed Jul 24, 2024 2:29 am
by cy33hc
Rebuilt again using cmake, using same disabled options from configure except for disabling additionally the TEST code. Didn't get link error to getentropy

cmake -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Switch.cmake -DENABLE_CAT=OFF -DENABLE_CPIO=OFF -DENABLE_TAR=OFF -DENABLE_UNZIP=OFF -DENABLE_ZSTD=ON -DENABLE_OPENSSL=OFF -DENABLE_LIBXML2=OFF -DENABLE_ACL=OFF -DENABLE_TEST=OFF -DBUILD_TESTING=OFF ..

The ENABLE_CAT=OFF, ENABLE_CPIO=OFF, ENABLE_TAR=OFF, ENABLE_UNZIP=OFF etc.. are the same as disable-bsdcat, disable-bsdtar , disable-bsdunzip, disable-bsdcpio etc..

./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \
--disable-shared --enable-static \
--disable-bsdtar --disable-bsdcat \
--disable-bsdunzip --disable-bsdcpio --disable-acl \
--without-xml2 --without-openssl

I used libarchive in my project. https://github.com/cy33hc/switch-ezremo ... p_util.cpp

Currently building the app using libarchive that I built myself.