devkitPro / pacman-packages

https://devkitpro.org
131 stars 104 forks source link

sdl2_net undefined reference to `inet_addr` #324

Closed paulober closed 9 months ago

paulober commented 9 months ago

I wanted to build a switch executable and use sdl2_net from the switch portlib and got following linker error:

/opt/devkitpro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.2.0/../../../../aarch64-none-elf/bin/ld: /opt/devkitpro/portlibs/switch/lib/libSDL2_net.a(SDLnet.o): in function `SDLNet_ResolveHost':
SDLnet.c:(.text.SDLNet_ResolveHost+0x2c): undefined reference to `inet_addr'
/opt/devkitpro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.2.0/../../../../aarch64-none-elf/bin/ld: SDLnet.c:(.text.SDLNet_ResolveHost+0x88): undefined reference to `gethostbyname'
/opt/devkitpro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.2.0/../../../../aarch64-none-elf/bin/ld: /opt/devkitpro/portlibs/switch/lib/libSDL2_net.a(SDLnetUDP.o): in function `SDLNet_UDP_Open':
SDLnetUDP.c:(.text.SDLNet_UDP_Open+0xe0): undefined reference to `inet_addr'
collect2: error: ld returned 1 exit status
WinterMute commented 9 months ago

You're not adding the libs you need to link. If you're using stock Makefiles then add `$(PREFIX)pkg-config --cflags SDL2_net` to CFLAGS and `$(PREFIX)pkg-config --libs SDL2_net` to LIBS. If not then post on the forums instead with details of the build system you're using.

https://devkitpro.org/viewforum.php?f=42

paulober commented 9 months ago

Sorry for bothering you. I'm new to Makefiles and your suggestion fixed it.