Page 1 of 1

undefined reference with curl

Posted: Wed May 10, 2023 4:21 pm
by hukad2
I am trying to build a homebrew switch app in which I need amongst others to make requuests to https endpoints. For this purpose I use curl, but I get undefined references errors to random number generators:

Code: Select all

/opt/devkitpro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld: /opt/devkitpro/portlibs/switch/lib/libcurl.a(libcurl_la-libnx.o): in function `Curl_libnx_random':
libnx.c:(.text.Curl_libnx_random+0x10): undefined reference to `csrngGetRandomBytes'
/opt/devkitpro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld: /opt/devkitpro/portlibs/switch/lib/libcurl.a(libcurl_la-libnx.o): in function `Curl_libnx_cleanup':
libnx.c:(.text.Curl_libnx_cleanup+0x8): undefined reference to `csrngExit'
/opt/devkitpro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld: /opt/devkitpro/portlibs/switch/lib/libcurl.a(libcurl_la-libnx.o): in function `Curl_libnx_init':
libnx.c:(.text.Curl_libnx_init+0x24): undefined reference to `csrngInitialize'
collect2: error: ld returned 1 exit status
make[1]: *** [/opt/devkitpro/libnx/switch_rules:80: XXX.elf] Error 1
make: *** [Makefile:168: build] Error 2
I even tried with a very similar code to https://github.com/switchbrew/switch-ex ... twork/curl but get the same error. I don't really know what the issue is as I think that I installed all the right packages.

Any help is appreciated, thanks in advance

Re: undefined reference with curl

Posted: Wed May 10, 2023 6:56 pm
by WinterMute
hukad2 wrote: Wed May 10, 2023 4:21 pm I even tried with a very similar code to https://github.com/switchbrew/switch-ex ... twork/curl but get the same error. I don't really know what the issue is as I think that I installed all the right packages.

Any help is appreciated, thanks in advance
The problem is likely to be in the differences between your project and that example. The key is using curl-config for CFLAGS & LIBS. See this line and [this one.

Re: undefined reference with curl

Posted: Wed May 10, 2023 9:38 pm
by hukad2
You are a wizard, indeed it seems to have worked. My bad for overlooking that part of the Makefile. Thank you