Page 1 of 1

"undefined reference to waitpid" when compiling with libarchive

Posted: Fri Dec 22, 2023 12:32 am
by SMB_Fan2010
Hello,
I'm trying to make a 3DS homebrew app that needs to extract files from a ZIP archive using libarchive. However, when I try to compile it with make, I get a lot of undefined references. The one at the top always has to do with waitpid. Here's the full list of them:

Code: Select all

C:/devkitPro/devkitARM/bin/../lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/bin/ld.exe: C:/
devkitPro/portlibs/3ds/lib\libarchive.a(archive_read_support_filter_program.o): in function `child_s
top.isra.1':
archive_read_support_filter_program.c:(.text.child_stop.isra.1+0xa0): undefined reference to `waitpi
d'
C:/devkitPro/devkitARM/bin/../lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/bin/ld.exe: C:/
devkitPro/portlibs/3ds/lib\libarchive.a(archive_read_support_filter_program.o): in function `program
_filter_read':
archive_read_support_filter_program.c:(.text.program_filter_read+0x110): undefined reference to `__a
rchive_check_child'
C:/devkitPro/devkitARM/bin/../lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/bin/ld.exe: arc
hive_read_support_filter_program.c:(.text.program_filter_read+0x20c): undefined reference to `__arch
ive_check_child'
C:/devkitPro/devkitARM/bin/../lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/bin/ld.exe: C:/
devkitPro/portlibs/3ds/lib\libarchive.a(archive_read_support_filter_program.o): in function `__archi
ve_read_program':
archive_read_support_filter_program.c:(.text.__archive_read_program+0xa8): undefined reference to `_
_archive_create_child'
C:/devkitPro/devkitARM/bin/../lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/bin/ld.exe: C:/
devkitPro/portlibs/3ds/lib\libarchive.a(archive_write_disk_set_standard_lookup.o): in function `look
up_uid':
archive_write_disk_set_standard_lookup.c:(.text.lookup_uid+0xa4): undefined reference to `getpwnam'
C:/devkitPro/devkitARM/bin/../lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/bin/ld.exe: C:/
devkitPro/portlibs/3ds/lib\libarchive.a(archive_write_disk_set_standard_lookup.o): in function `look
up_gid':
archive_write_disk_set_standard_lookup.c:(.text.lookup_gid+0xa4): undefined reference to `getgrnam'
In my Makefile:

Code: Select all

LIBS	:= -lcurl -lmbedtls -lmbedx509 -lmbedcrypto -larchive -lcitro2d -lcitro3d -lctru -lm -lbz2 -llzma -lz

Code: Select all

LIBDIRS	:= $(PORTLIBS) $(CTRULIB)
How do I fix this? Thanks in advance!

Re: "undefined reference to waitpid" when compiling with libarchive

Posted: Fri Dec 22, 2023 4:25 pm
by WinterMute
I've upgraded 3ds libarchive to 3.7.2 and done some work on the patchsets. Update using (dkp-)pacman -Syu.

Rather than attempting to figure out all these libraries manually you'll be much better off using pkg-config which knows dependencies and their order.

Code: Select all

LIBS := 	-lcitro2d -lcitro3d `$(PREFIX)pkg-config --libs libarchive libcurl`
Should do what you need.

Re: "undefined reference to waitpid" when compiling with libarchive

Posted: Fri Dec 22, 2023 9:08 pm
by SMB_Fan2010
Sorry, didn't work 😒
I updated libarchive, but it still doesn't work. Here's the error i'm getting now:

Code: Select all

C:/devkitPro/devkitARM/bin/../lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/bin/ld.exe: can
not find -l-L/opt/devkitpro/portlibs/3ds/lib: No such file or directory
If your "solution" didn't actually work, how else can i fix this?

Re: "undefined reference to waitpid" when compiling with libarchive

Posted: Fri Dec 22, 2023 11:38 pm
by WinterMute
SMB_Fan2010 wrote: ↑Fri Dec 22, 2023 9:08 pm Sorry, didn't work 😒
I updated libarchive, but it still doesn't work. Here's the error i'm getting now:

Code: Select all

C:/devkitPro/devkitARM/bin/../lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/bin/ld.exe: can
not find -l-L/opt/devkitpro/portlibs/3ds/lib: No such file or directory
If your "solution" didn't actually work, how else can i fix this?
Apologies. I added an extra -l to the line I gave you originally. I've corrected the line in my reply above - there was an extra -l in front of `$(PREFIX)