undefined reference with curl

Post Reply
hukad2
Posts: 2
Joined: Wed May 10, 2023 3:55 pm

undefined reference with curl

Post by hukad2 » Wed May 10, 2023 4:21 pm

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

WinterMute
Site Admin
Posts: 1986
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: undefined reference with curl

Post by WinterMute » Wed May 10, 2023 6:56 pm

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.
Help keep devkitPro toolchains free, Donate today

Personal Blog

hukad2
Posts: 2
Joined: Wed May 10, 2023 3:55 pm

Re: undefined reference with curl

Post by hukad2 » Wed May 10, 2023 9:38 pm

You are a wizard, indeed it seems to have worked. My bad for overlooking that part of the Makefile. Thank you

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests