Page 1 of 1

How to use Portlibs in MacOSX

Posted: Wed Apr 15, 2020 7:04 am
by invalid_username
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?

Re: How to use Portlibs in MacOSX

Posted: Mon Jun 01, 2020 1:16 pm
by WinterMute
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