Integrating Qiniu Cloud services into ARM64 embedded devices necessitates cross-compiling the C SDK along with its dependencies. The following procedure outlines the build process for targets such as the RK1808 core within a Linux host environment.
Dependency: libcurl
Obtain the libcurl source archive and extract it into the working directory.
tar -xf curl-7.58.0.tar.xz
cd curl-7.58.0
Create a dedicated directory for the build artifacts.
mkdir -p build_arm
cd build_arm
Configure the environment to include the cross-compilation toolchain binaries. Replace the placeholder path with the actual SDK location.
export TOOLCHAIN_ROOT="/opt/embedded/arm64-sdk"
export PATH="${TOOLCHAIN_ROOT}/bin:${PATH}"
Verify the compiler configuration.
aarch64-linux-gnu-gcc --version
Run the configuration script specifying the host architecture and installation prefix.
../configure --host=aarch64-linux-gnu --prefix=/usr/local
make -j$(nproc)
make install DESTDIR="<STAGING_DIR_PATH>"
This generates the required ARM64 libraries for libcurl.
Qiniu C SDK Build
Retrieve the SDK source code from the repository.
git clone https://github.com/qiniu/c-sdk.git
cd c-sdk
Create a Makefile tailored for the cross-compilation environment. Define the source modules and include directories using distinct variables.
INC_DIRS := -I./base64 -I./cJSON -I./qiniu
SRC_MODULES := b64/b64.c b64/urlsafe_b64.c cJSON/cJSON.c qiniu/auth_mac.c qiniu/base.c qiniu/base_io.c qiniu/cdn.c qiniu/conf.c qiniu/fop.c qiniu/http.c qiniu/io.c qiniu/qetag.c qiniu/reader.c qiniu/resumable_io.c qiniu/rs.c qiniu/tm.c
OBJ_LIST := $(SRC_MODULES:.c=.o)
CROSS_CC := aarch64-linux-gnu-gcc
STATIC_LIB := libqiniu.a
SHARED_LIB := libqiniu.so
all: $(OBJ_LIST) libs
%.o: %.c
$(CROSS_CC) -c -fPIC $(INC_DIRS) $< -o $@
libs: $(OBJ_LIST)
ar rcs $(STATIC_LIB) $(OBJ_LIST)
$(CROSS_CC) -shared -o $(SHARED_LIB) $(OBJ_LIST) -lcurl -lcrypto -lssl -lm
clean:
rm -f $(OBJ_LIST) $(STATIC_LIB) $(SHARED_LIB)
Execute the build process to generate object files.
make
The compilation produces both static and dynamic libraries. Organize the headers and binaries into a standard distribution structure.
.
├── include
│ ├── b64
│ ├── cJSON
│ └── qiniu
└── lib
├── libqiniu.a
└── libqiniu.so