Hello,
I have a C++ application that performs Canny edge detection, among other things. The host platform is x86_64 (amd64) with Ubuntu 18.04 LTS 64-bit. The target platform is aarch64 (Kryo) CPU on Qualcomm SA6155. We were able to cross-compile the original C++ application for the target platform with the aarch64-linux-gnu-g++ compiler. We were also able to execute the binary thus created on the ARM CPU of SA6155 platform, which runs Linux.
Now, I am attempting to accelerate the Canny edge detection function. So I installed the FastCV library version 1.7.1 for Linux Embedded platform, substituted the original C++ function with the fcvFilterCannyu8() function from the FastCV library, and attempted to cross-compile the application. The build command lines are as follows:
$ aarch64-linux-gnu-g++-5 -c -std=c++11 -fPIC -march=armv8-a -pthread -O2 -I src <source-file> -o <object-file>
$ aarch64-linux-gnu-g++-5 -no-pie -L/usr/aarch64-linux-gnu/lib -L/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib <list-of-object-files> -lc -ldl -lfastcv -o my_executable
I placed the 64-bit version of libfastcv.a in the path /home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib. I expected that the other libs (pthread, dl, c) would be linked automatically from the path /usr/aarch64-linux-gnu/lib.
But when I attempted to build this way, I encountered the following errors:
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcv.o): In function `uR(fcvOperationMode, FCV_FUNC_MANAGER*, FCV_IMPL)':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/common/fastcv.cpp:4087: undefined reference to `dlsym'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/common/fastcv.cpp:4113: undefined reference to `dlsym'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/common/fastcv.cpp:4120: undefined reference to `dlsym'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/common/fastcv.cpp:4127: undefined reference to `dlsym'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/common/fastcv.cpp:4134: undefined reference to `dlsym'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcv.o):/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/common/fastcv.cpp:4141: more undefined references to `dlsym' follow
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcv.o): In function `uR(fcvOperationMode, FCV_FUNC_MANAGER*, FCV_IMPL)':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/common/fastcv.cpp:4098: undefined reference to `dlerror'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvHW.o): In function `fcvTableHWInitRemote(FCV_FUNC_MANAGER*, fcvOperationMode)':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/common/fastcvHW.cpp:165: undefined reference to `dlsym'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/common/fastcvHW.cpp:228: undefined reference to `dlsym'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/common/fastcvHW.cpp:243: undefined reference to `dlsym'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/common/fastcvHW.cpp:173: undefined reference to `dlerror'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/common/fastcvHW.cpp:236: undefined reference to `dlerror'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/common/fastcvHW.cpp:250: undefined reference to `dlerror'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvMserFxpC.o): In function `fcvThreadCreate(int (*)(void*), void*, void**)':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:55: undefined reference to `pthread_create'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:55: undefined reference to `pthread_create'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:55: undefined reference to `pthread_create'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:55: undefined reference to `pthread_create'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:55: undefined reference to `pthread_create'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvMserFxpC.o):/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:55: more undefined references to `pthread_create' follow
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvMserFxpC.o): In function `fcvThreadJoin(void*, int*)':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:72: undefined reference to `pthread_join'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:72: undefined reference to `pthread_join'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:72: undefined reference to `pthread_join'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:72: undefined reference to `pthread_join'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:72: undefined reference to `pthread_join'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvMserFxpC.o):/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:72: more undefined references to `pthread_join' follow
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvMserFxpC.o): In function `fcvThreadCreate(int (*)(void*), void*, void**)':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:55: undefined reference to `pthread_create'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvMserFxpC.o): In function `fcvThreadJoin(void*, int*)':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:72: undefined reference to `pthread_join'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvMserFxpC.o): In function `fcvThreadCreate(int (*)(void*), void*, void**)':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:55: undefined reference to `pthread_create'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:55: undefined reference to `pthread_create'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:55: undefined reference to `pthread_create'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:55: undefined reference to `pthread_create'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:55: undefined reference to `pthread_create'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvMserFxpC.o):/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:55: more undefined references to `pthread_create' follow
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvMserFxpC.o): In function `fcvThreadJoin(void*, int*)':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:72: undefined reference to `pthread_join'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:72: undefined reference to `pthread_join'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:72: undefined reference to `pthread_join'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:72: undefined reference to `pthread_join'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:72: undefined reference to `pthread_join'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvMserFxpC.o):/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:72: more undefined references to `pthread_join' follow
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvHwAndroid.o): In function `fcv_check_only_cpu':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvCpuFeatures.c:288: undefined reference to `pthread_once'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvHwAndroid.o): In function `fcv_android_getCpuFamily()':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvCpuFeatures.c:265: undefined reference to `pthread_once'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvHwAndroid.o): In function `fcv_android_getCpuImplementer()':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvCpuFeatures.c:282: undefined reference to `pthread_once'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvHwAndroid.o): In function `fcv_android_getCpuFeatures()':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvCpuFeatures.c:274: undefined reference to `pthread_once'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvRemoteLibAndroid.o): In function `fcvCheckRemoteLibPresent()':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvRemoteLibAndroid.cpp:186: undefined reference to `dlopen'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvRemoteLibAndroid.o): In function `fcvCheckRemoteLibSupport()':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvRemoteLibAndroid.cpp:58: undefined reference to `dlerror'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvRemoteLibAndroid.cpp:68: undefined reference to `dlsym'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvRemoteLibAndroid.o): In function `fcvCheckRemoteLibPresent()':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvRemoteLibAndroid.cpp:186: undefined reference to `dlopen'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvRemoteLibAndroid.cpp:186: undefined reference to `dlopen'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvRemoteLibAndroid.o): In function `fcvRemoteLibAvailableHWComponent(fcvOperationMode)':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvRemoteLibAndroid.cpp:133: undefined reference to `dlsym'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvRemoteLibAndroid.cpp:140: undefined reference to `dlerror'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvRemoteLibAndroid.cpp:141: undefined reference to `dlsym'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvRemoteLibAndroid.cpp:152: undefined reference to `dlsym'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvRemoteLibAndroid.cpp:155: undefined reference to `dlsym'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvRemoteLibAndroid.cpp:148: undefined reference to `dlerror'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvRemoteLibAndroid.o): In function `fcvCheckRemoteLibPresent()':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvRemoteLibAndroid.cpp:186: undefined reference to `dlopen'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvRemoteLibAndroid.o): In function `fcvRemoteLibCleanUp()':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvRemoteLibAndroid.cpp:173: undefined reference to `dlsym'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvRemoteLibAndroid.o): In function `fcvRemoteLibClean()':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvRemoteLibAndroid.cpp:198: undefined reference to `dlclose'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvRemoteLibAndroid.o): In function `fcvCheckRemoteLibPresent()':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvRemoteLibAndroid.cpp:186: undefined reference to `dlopen'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvRemoteLibAndroid.o): In function `fcvSelectQDSP6ModeRemoteLib':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvRemoteLibAndroid.cpp:210: undefined reference to `dlsym'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvRemoteLibAndroid.o): In function `fcvCheckRemoteLibPresent()':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvRemoteLibAndroid.cpp:186: undefined reference to `dlopen'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvRemoteLibAndroid.o): In function `fcvQ6GetClkRemoteLib':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvRemoteLibAndroid.cpp:225: undefined reference to `dlsym'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvMem.o): In function `fcvMutexTryLock(void*)':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:138: undefined reference to `pthread_mutex_trylock'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:138: undefined reference to `pthread_mutex_trylock'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvMem.o): In function `fcvOnceRun(void volatile*, void (*)())':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:165: undefined reference to `pthread_once'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:165: undefined reference to `pthread_once'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvMem.o): In function `_fcvSlbChk()':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/processor/x86/fastcvMem.cpp:485: undefined reference to `dlopen'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/processor/x86/fastcvMem.cpp:491: undefined reference to `dlsym'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/processor/x86/fastcvMem.cpp:494: undefined reference to `dlsym'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/processor/x86/fastcvMem.cpp:497: undefined reference to `dlsym'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/processor/x86/fastcvMem.cpp:500: undefined reference to `dlsym'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/processor/x86/fastcvMem.cpp:503: undefined reference to `dlsym'
/home/sagar/qualcomm/vfs_all_cam_repo/vfs_all_cam_arm_linux/lib/libfastcv.a(libfastcv_la-fastcvMem.o): In function `fcvOnceRun(void volatile*, void (*)())':
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:165: undefined reference to `pthread_once'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:165: undefined reference to `pthread_once'
/usr/src/debug/fastcv-noship/git-r0/fastcv-noship/src/platform/android/fastcvThread.inl:165: undefined reference to `pthread_once'
collect2: error: ld returned 1 exit status
Makefile:77: recipe for target 'my_executable' failed
make: *** [my_executable] Error 1
It looks like the 'pthread' and 'dl' libraries are not getting linked together with the FastCV library.
How can I resolve this problem?
Thank you.
FastCV 1.7.1 Linux Embedded - linking errors during cross compilation
Posted: Fri, 2020-08-28 07:13
Hi,
Follow below steps to build fastcv application with Hexagon SDK 64-bit, if you're platform is different means please replay which platform you're using
FastCV SDK environment setup
FastCV SDK download
https://developer.qualcomm.com/software/fast-cv-sdk/tools
Download v1.7.1 for Linux Embedded
FastCV installation and compilation
The FastCV binary file is fastcv-installer-linuxembedded-1-7-1.bin. Follow the steps below to install it:
chmod 777 fastcv-installer-linuxembedded-1-7-1.bin
./fastcv-installer-linuxembedded-1-7-1.bin
Building Sample Applications
fastcvSimpleTest using Hexagon sdk 64-bit
1. Download Hexagon DSP SDK from Qualcomm developer network
https://developer.qualcomm.com/software/hexagon-dsp-sdk
2. Download gcc-linaro-4.9-2014.11-x86_64_aarch64-linux-gnu.tar.xz
http://releases.linaro.org/archive/14.11/components/toolchain/binaries/aarch64-linux-gnu
Extract the tar file and copy folder gcc-linaro-4.9-2014.11-x86_64_aarch64-linux-gnu
To <Hexagon_SDK_ROOT>/tools/ folder.
Rename gcc-linaro-4.9-2014.11-x86_64_aarch64-linux-gnu folder to linaro64.
3. Copy the fastcvSimpleTest folder inside <Hexagon_SDK_ROOT>/examples/common/.
Copy 64-bit libfastcv.a from libs provided in the fastcv sdk
(fastcv-1-7-1_LinuxEmbedded\lib\64-bit\libfastcv.a) to
<Hexagon_SDK_ROOT>/examples/common/fastcvSimpleTest/lib/ folder.
4. Open a new terminal from the root directory <Hexagon_SDK_ROOT> of the Hexagon SDK
and run setup_sdk_env.source.
This script configures the local environment. These changes are not persistent in the
terminal instance, so you must run setup_sdk_env.source on each terminal you want to
develop in.
$ cd < Hexagon SDK root directory, default is: ~/Qualcomm/Hexagon_SDK/<version>>
$ source setup_sdk_env.source
5. Change the directory to fastcvSimpleTest folder
cd examples/common/fastcvSimpleTest
Execute command: make tree V=UbuntuARM_Debug_aarch64
6. A folder with name "UbuntuARM_Debug_aarch64" should get generated in
the fastcvSimpleTest folder. It will contain the fastcvSimpleTest binary file.
FastCV SDK Test
1. Push the fastcvSimpleTest binary file in the target:
adb push
<Hexagon_SDK_ROOT>\examples\common\fastcvSimpleTest\UbuntuARM_Debug_aarch64\s
hip\fastcvSimpleTest /usr/bin/
2. Change bin permissions and execute the fastcvSimpleTest:
adb shell chmod 777 /usr/bin/fastcvSimpleTest
adb shell /usr/bin/fastcvSimpleTest
*/ */
*/
*/ */
Hello,
We also studied the FastCV documentation.
Unfortunately, Hexagon SDK cannot be used to resolve this issue.
However, after some trial and error, we were able to resolve the problem.
Thank you.