aboutsummaryrefslogtreecommitdiffstats
path: root/runme.sh
diff options
context:
space:
mode:
authorWe-unite <3205135446@qq.com>2025-01-04 14:52:55 +0800
committerWe-unite <3205135446@qq.com>2025-01-04 14:52:55 +0800
commitab091cb4661aed9b9da997e58a8b5ec1f5853951 (patch)
tree0abdf7f99b5fc069536d975b39e1bcb8cf8e77b9 /runme.sh
parent6c06f515f18f5913a027ba2c84092c4861e8cf45 (diff)
downloadWheelCtrl-ab091cb4661aed9b9da997e58a8b5ec1f5853951.tar.gz
WheelCtrl-ab091cb4661aed9b9da997e58a8b5ec1f5853951.zip
Fix linking error caused by wrong lib pathHEADmaster
In the old commit, CMakeLists is set to find liblcm in ${CMAKE_SOURCE_ROOT}/libs, and there are two dirs: aarch64 and x86. When I compile it for x86-64 computer using the cmake on host machine, it will automatically find lib under ${CMAKE_SOURCE_ROOT}/lib/x86, and when compiling for arm using cmake/compiler provided by ohos, it will also find under ${CMAKE_SOURCE_ROOT}/lib/aarch64. Sounds good. But, this is just a feature of special version for cmake/make/binutils, causing error on other linux distributions. The path should be given, but tools wouldn't find libs there recursively, which means path should be spercific. So in this commit, I use runme.sh to compile. It will work depending on the argument(named arch) given by user, and pass it as a macro named OHOS_ARCH to cmake, which is used in linking path of CMakeLists. Besides, libpthread.so is not always default linked. So let's write it in CMakeLists. Last but not least, keeping source code clean is our duty. There's a .clang-format under ${CMAKE_SOURCE_ROOT} to help. Use it. Moving for the better!
Diffstat (limited to 'runme.sh')
-rwxr-xr-xrunme.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/runme.sh b/runme.sh
new file mode 100755
index 0000000..947d50a
--- /dev/null
+++ b/runme.sh
@@ -0,0 +1,34 @@
1#!/bin/bash
2
3##########################################################################
4# File Name : compile.sh
5# Encoding : utf-8
6# Author : We-unite
7# Email : weunite1848@gmail.com
8# Created Time : 2024-02-29 15:19:15
9##########################################################################
10
11set -e
12
13if [ $UID -eq 0 ]; then
14 echo "Please do not run this script as root"
15 exit 1
16fi
17
18if [ $# -ne 1 ]; then
19 echo "ERROR: $0 <arm64-v8a|x86_64>"
20 exit 1
21fi
22
23arch=$1
24link=static # or shared
25native_path=/home/player/app/native
26
27if [ $arch == "arm64-v8a" ]; then
28 export PATH=$native_path/build-tools/cmake/bin:$PATH
29 cmake -B build -D OHOS_STL=c++_$link -D OHOS_ARCH=$arch -D OHOS_PLATFORM=OHOS -D CMAKE_TOOLCHAIN_FILE=$(find $native_path -name ohos.toolchain.cmake)
30else
31 cmake -B build -D OHOS_ARCH=$arch
32fi
33
34cmake --build build