Hi Hayden and David,

I'm happy to report that the patch works, and I just noticed that it was merged to master (so there's no need to manually apply it now, just need a git pull). Thank you for the extremely quick support. smile I have marked this topic solved!

I am targetting Linux on the Raspberry Pi using the arm-linux-gnu cross-compiler on x86-64 Linux. My own project uses CMake, and the following are my list-file and toolchain-file:

# Usage:
# $ cmake -DCMAKE_BUILD_TYPE=Debug -B ./build -S ./ -G Ninja
# $ cmake --build ./build
#
# To build with debugging use:
# $ cmake -DCMAKE_TOOLCHAIN_FILE=arm-linux-gnueabihf-toolchain.cmake -DCMAKE_BUILD_TYPE=Debug \
# -B ./build -S ./ -G Ninja
#

cmake_minimum_required(VERSION 3.18)

project(wolfTPM_examples VERSION 2.4.0 LANGUAGES C CXX)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED TRUE)
set(CMAKE_C_EXTENSIONS OFF)
add_compile_options(-mfloat-abi=hard -mfpu=vfp -mtls-dialect=gnu -marm -march=armv8-a+crc+simd)

message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
message(STATUS "Prefix: ${ARM_PREFIX}")

# Include FetchContent modules to download, build, and install
# wolfSSL and wolfTPM libraries
include(FetchContent)

# Disable shared libraries, as we are cross-compiling and sending the executable to the rPi
set(BUILD_SHARED_LIBS OFF)
set(WOLFSSL_TPM ON CACHE INTERNAL "")
FetchContent_Declare(wolfSSL
    GIT_REPOSITORY https://github.com/wolfSSL/wolfSSL.git
    GIT_TAG origin/master
    GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(wolfSSL)

## Download and prepare wolfTPM
#set(WITH_WOLFSSL_TREE ${wolfssl_SOURCE_DIR} CACHE INTERNAL "")
#set(WOLFTPM_INTERFACE "I2C" CACHE INTERNAL "Set interface to I2C")
#FetchContent_Declare(wolfTPM
#    GIT_REPOSITORY https://github.com/wolfSSL/wolfTPM.git
#    GIT_TAG origin/master
#    GIT_PROGRESS TRUE
#    PATCH_COMMAND cd ${CMAKE_BINARY_DIR}/_deps/wolftpm-src
#    COMMAND pwd
#    COMMAND patch -p0 --forward < ${CMAKE_CURRENT_SOURCE_DIR}/i2c_cmake.patch || true
#)
#FetchContent_MakeAvailable(wolfTPM)

add_executable(test src/test.cpp)
target_link_libraries(test wolfssl)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(ARM_PREFIX "arm-linux-gnueabihf")

# specify cross-compilers and tools
set(CMAKE_C_COMPILER ${ARM_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${ARM_PREFIX}-g++)
set(CMAKE_ASM_COMPILER  ${ARM_PREFIX}-gcc)
set(CMAKE_AR ${ARM_PREFIX}-ar)
set(CMAKE_OBJCOPY ${ARM_PREFIX}-objcopy)
set(CMAKE_OBJDUMP ${ARM_PREFIX}-objdump)
set(CMAKE_RANLIB  ${ARM_PREFIX}-ranlib)
set(SIZE ${ARM_PREFIX}-size)

As shown, I am trying to compile my small test file which calls some wolfSSL function (in fact, I want to compile the wolfTPM examples, but I provide a minimum viable example here):

#include <wolfssl/options.h>
#include <wolfssl/ssl.h>

int main()
{
    wc_AllocDer(nullptr, 4, TRUSTED_PEER_TYPE, nullptr);
    return 0;
}

When attempting to build: CMake throws the following linker errors:

/usr/lib/gcc/aarch64-linux-gnu/12.1.0/../../../../aarch64-linux-gnu/bin/ld: _deps/wolfssl-build/libwolfssl.a(pwdbased.c.o): in function `wc_PKCS12_PBKDF_ex':
/home/SRSR333/Desktop/pseudo_tpm/Raspi/rpi_tpm/cmake-build-debug/_deps/wolfssl-src/wolfcrypt/src/pwdbased.c:480: undefined reference to `sp_init'
/usr/lib/gcc/aarch64-linux-gnu/12.1.0/../../../../aarch64-linux-gnu/bin/ld: /home/SRSR333/Desktop/pseudo_tpm/Raspi/rpi_tpm/cmake-build-debug/_deps/wolfssl-src/wolfcrypt/src/pwdbased.c:482: undefined reference to `sp_read_unsigned_bin'
/usr/lib/gcc/aarch64-linux-gnu/12.1.0/../../../../aarch64-linux-gnu/bin/ld: /home/SRSR333/Desktop/pseudo_tpm/Raspi/rpi_tpm/cmake-build-debug/_deps/wolfssl-src/wolfcrypt/src/pwdbased.c:484: undefined reference to `sp_add_d'
/usr/lib/gcc/aarch64-linux-gnu/12.1.0/../../../../aarch64-linux-gnu/bin/ld: /home/SRSR333/Desktop/pseudo_tpm/Raspi/rpi_tpm/cmake-build-debug/_deps/wolfssl-src/wolfcrypt/src/pwdbased.c:488: undefined reference to `sp_clear'
/usr/lib/gcc/aarch64-linux-gnu/12.1.0/../../../../aarch64-linux-gnu/bin/ld: /home/SRSR333/Desktop/pseudo_tpm/Raspi/rpi_tpm/cmake-build-debug/_deps/wolfssl-src/wolfcrypt/src/pwdbased.c:495: undefined reference to `sp_init_multi'
/usr/lib/gcc/aarch64-linux-gnu/12.1.0/../../../../aarch64-linux-gnu/bin/ld: /home/SRSR333/Desktop/pseudo_tpm/Raspi/rpi_tpm/cmake-build-debug/_deps/wolfssl-src/wolfcrypt/src/pwdbased.c:499: undefined reference to `sp_read_unsigned_bin'
/usr/lib/gcc/aarch64-linux-gnu/12.1.0/../../../../aarch64-linux-gnu/bin/ld: /home/SRSR333/Desktop/pseudo_tpm/Raspi/rpi_tpm/cmake-build-debug/_deps/wolfssl-src/wolfcrypt/src/pwdbased.c:501: undefined reference to `sp_add'
/usr/lib/gcc/aarch64-linux-gnu/12.1.0/../../../../aarch64-linux-gnu/bin/ld: /home/SRSR333/Desktop/pseudo_tpm/Raspi/rpi_tpm/cmake-build-debug/_deps/wolfssl-src/wolfcrypt/src/pwdbased.c:503: undefined reference to `sp_unsigned_bin_size'
/usr/lib/gcc/aarch64-linux-gnu/12.1.0/../../../../aarch64-linux-gnu/bin/ld: /home/SRSR333/Desktop/pseudo_tpm/Raspi/rpi_tpm/cmake-build-debug/_deps/wolfssl-src/wolfcrypt/src/pwdbased.c:509: undefined reference to `sp_to_unsigned_bin'
/usr/lib/gcc/aarch64-linux-gnu/12.1.0/../../../../aarch64-linux-gnu/bin/ld: /home/SRSR333/Desktop/pseudo_tpm/Raspi/rpi_tpm/cmake-build-debug/_deps/wolfssl-src/wolfcrypt/src/pwdbased.c:514: undefined reference to `sp_to_unsigned_bin'
/usr/lib/gcc/aarch64-linux-gnu/12.1.0/../../../../aarch64-linux-gnu/bin/ld: /home/SRSR333/Desktop/pseudo_tpm/Raspi/rpi_tpm/cmake-build-debug/_deps/wolfssl-src/wolfcrypt/src/pwdbased.c:517: undefined reference to `sp_to_unsigned_bin'
/usr/lib/gcc/aarch64-linux-gnu/12.1.0/../../../../aarch64-linux-gnu/bin/ld: /home/SRSR333/Desktop/pseudo_tpm/Raspi/rpi_tpm/cmake-build-debug/_deps/wolfssl-src/wolfcrypt/src/pwdbased.c:520: undefined reference to `sp_clear'
/usr/lib/gcc/aarch64-linux-gnu/12.1.0/../../../../aarch64-linux-gnu/bin/ld: /home/SRSR333/Desktop/pseudo_tpm/Raspi/rpi_tpm/cmake-build-debug/_deps/wolfssl-src/wolfcrypt/src/pwdbased.c:521: undefined reference to `sp_clear'
/usr/lib/gcc/aarch64-linux-gnu/12.1.0/../../../../aarch64-linux-gnu/bin/ld: /home/SRSR333/Desktop/pseudo_tpm/Raspi/rpi_tpm/cmake-build-debug/_deps/wolfssl-src/wolfcrypt/src/pwdbased.c:526: undefined reference to `sp_clear'
/usr/lib/gcc/aarch64-linux-gnu/12.1.0/../../../../aarch64-linux-gnu/bin/ld: /home/SRSR333/Desktop/pseudo_tpm/Raspi/rpi_tpm/cmake-build-debug/_deps/wolfssl-src/wolfcrypt/src/pwdbased.c:534: undefined reference to `sp_clear'
/usr/lib/gcc/aarch64-linux-gnu/12.1.0/../../../../aarch64-linux-gnu/bin/ld: _deps/wolfssl-build/libwolfssl.a(internal.c.o): in function `VerifyRsaSign':
/home/SRSR333/Desktop/pseudo_tpm/Raspi/rpi_tpm/cmake-build-debug/_deps/wolfssl-src/src/internal.c:4569: undefined reference to `sp_count_bits'
/usr/lib/gcc/aarch64-linux-gnu/12.1.0/../../../../aarch64-linux-gnu/bin/ld: _deps/wolfssl-build/libwolfssl.a(internal.c.o): in function `DoServerKeyExchange':
/home/SRSR333/Desktop/pseudo_tpm/Raspi/rpi_tpm/cmake-build-debug/_deps/wolfssl-src/src/internal.c:26350: undefined reference to `sp_count_bits'
/usr/lib/gcc/aarch64-linux-gnu/12.1.0/../../../../aarch64-linux-gnu/bin/ld: _deps/wolfssl-build/libwolfssl.a(internal.c.o): in function `DoCertificateVerify':
/home/SRSR333/Desktop/pseudo_tpm/Raspi/rpi_tpm/cmake-build-debug/_deps/wolfssl-src/src/internal.c:31951: undefined reference to `sp_count_bits'
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/test.dir/build.make:98: bin/test] Error 1
make[2]: *** [CMakeFiles/Makefile2:116: CMakeFiles/test.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:123: CMakeFiles/test.dir/rule] Error 2
make: *** [Makefile:169: test] Error 2

These linker errors are truncated; in fact, they are thousands of lines long. What can I do?

Thanks.