How to use Portlibs in MacOSX

Post Reply
invalid_username
Posts: 1
Joined: Wed Apr 15, 2020 6:55 am

How to use Portlibs in MacOSX

Post by invalid_username » Wed Apr 15, 2020 7:04 am

I'm having trouble using devkitpro's portlibs, curl in particular. I have run dkp-pacman -S switch-curl and made sure it's installed. However, when I try to build it with -lcurl in the Makefile, I get linker errors like this.
/opt/devkitpro/portlibs/switch/lib/libcurl.a(libcurl_la-mbedtls.o): in function `Curl_mbedtls_version':
mbedtls.c:(.text.Curl_mbedtls_version+0x14): undefined reference to `mbedtls_version_get_number'

It compiles just fine if I don't use any functions from libcurl. The code I am trying to run that gives me an error is this:

curl_global_init(CURL_GLOBAL_SSL);

The header looks like this:
#include <string>
#include <switch.h>
#include <curl/curl.h>

I am using C++, could that be the issue?

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

Re: How to use Portlibs in MacOSX

Post by WinterMute » Mon Jun 01, 2020 1:16 pm

For curl you mainly need to use the curl-config script with --cflags to obtain include paths and with --libs libraries. With the current stock Makefiles that means the section for flags should look like this :-

Code: Select all

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH	:=	-march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE

CFLAGS	:=	-g -Wall -O2 -ffunction-sections `cur-config --cflags` \
			$(ARCH) $(DEFINES)

CFLAGS	+=	$(INCLUDE) -D__SWITCH__

CXXFLAGS	:= $(CFLAGS) -fno-rtti -fno-exceptions

ASFLAGS	:=	-g $(ARCH)
LDFLAGS	=	-specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)

LIBS	:= 'curl-config --libs` -lnx
Help keep devkitPro toolchains free, Donate today

Personal Blog

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests