OP-TEE/optee_test

Question about build error

coach-bin opened this issue · 5 comments

I'm using 3.21.0.
Building xtest, I got the error message below.
optee_test/host/xtest/regression_1000.c:10:10: fatal error: openssl/bn.h: No such file or directory

Should it be able to find the header file from optee_test/host/openssl/include/openssl? What should I need to check more?

I have CMakeLists.txt and the directories like below:
{root}
└ optee_os
└ optee_client
└ optee_test
└ CMakeLists.txt

CMakeLists.txt contains two lines below:
add_subdirectory (optee_client)
add_subdirectory (optee_test)

And I ran the commands below from {root} :
cmake -D OPTEE_TEST_SDK=$PWD/../optee_os/out/plat-xxx/export-ta_arm64 -D CMAKE_INSTALL_PREFIX= -D CMAKE_BUILD_TYPE=Debug -D BUILD_SHARED_LIBS=y -D CMAKE_TOOLCHAIN_FILE=toolchain.arm.cmake
make

toolchain.arm.cmake has :
SET(CMAKE_SYSTEM_NAME "Linux")
SET(CMAKE_SYSTEM_PROCESSOR "arm64")
get_filename_component(COMPILER_PATH "../../../xxx/aarch64-linux-gnu/bin/aarch64-linux-gnu-" ABSOLUTE)
SET(CMAKE_C_COMPILER ${COMPILER_PATH}gcc)
SET(CMAKE_CXX_COMPILER ${COMPILER_PATH}g++)
SET(CMAKE_LINKER ${COMPILER_PATH}ld)
SET(CMAKE_NM ${COMPILER_PATH}nm)
SET(CMAKE_OBJCOPY ${COMPILER_PATH}objcopy)
SET(CMAKE_OBJDUMP ${COMPILER_PATH}objdump)
SET(CMAKE_RANLIB ${COMPILER_PATH}ranlib)

OpenSSL is in optee_test/host.openssl/{include,lib/{arm,aarch64}}. You probably need to add something to the build flags for xtest. In the OP-TEE dev environment (https://optee.readthedocs.io/en/latest/building/devices/qemu.html?#qemu-v8) we rely on Buildroot for providing OpenSSL.

Thanks!

@jforissier
From the code below, xtest CMakeLists.txt is trying to find openssl package from host machine.

find_package(OpenSSL)
if(OPENSSL_FOUND)
add_compile_options(-DOPENSSL_FOUND=1)
set (OPENSSL_PRIVATE_LINK OpenSSL::Crypto)
endif()

And I think that it finally leads to link failure (see error message below). Do I need to update libssl-dev for arm64?(I'm using ubuntu20.04) or is there another way to build?
aarch64-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libcrypto.so: error adding symbols: file in wrong format

is there another way to build

In addition to CMakeLists.txt there is a Makefile in the top level of the project. It might be better suited to what you are trying to accomplish.
However I recommend you follow the instructions in the document I linked above. It will build the full stack using cross compilation and the Buildroot environment.

@jforissier Thanks, I succeeded to build optee_test with Makefile. I ported optee to our own platform, so I'm not using build(of OPTEE repo)