Building the Qiniu C SDK on Linux Systems
ARM64 Build Process
-
Clone the Repository
Fetch the source code from the official repository:
git clone https://github.com/qiniu/c-sdk.gitIf network speeds from the primary source are slow, you can use a mirror repository:
git clone https://gitee.com/cqnews/c-qiniu-sdk.git -
Install Dependencies
The SDK requires the
libcurlandopenssldevelopment libraries. Install them using your package menager:sudo apt-get install libcurl4-openssl-dev libssl-dev -
Create a Makefile
The following Makefile compiels all source files into object files and links them into a shared library.
INCLUDE_DIRS=-Ibase64 -IcJSON -Iqiniu SOURCE_LIST=\ 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 all: $(SOURCE_LIST) gcc -g -c -fPIC $^ $(INCLUDE_DIRS) -lcurl -lcrypto -lssl -lm gcc -shared -o libqiniu.so *.o -lcurl -lcrypto -lssl -lm install: sudo cp libqiniu.so /usr/local/lib uninstall: sudo rm -f /usr/local/lib/libqiniu.so clean: rm -f *.o *.so -
Create a Stattic Library
After generating the object files (
.o), you can archive them into a static library using theartool:ar rcs libqiniu.a *.o -
Create a Dynamic/Shared Library
Alternatively, you can link the object files in to a shared library:
gcc -shared -o libqiniu.so *.o -lcurl -lcrypto -lssl -lm -
Final Package Structure
A complete build will produce a package with the following layout:
. ├── include │ ├── b64 │ │ ├── b64.h │ │ └── urlsafe_b64.h │ ├── cJSON │ │ └── cJSON.h │ └── qiniu │ ├── base.h │ ├── cdn.h │ ├── conf.h │ ├── fop.h │ ├── http.h │ ├── io.h │ ├── qetag.h │ ├── reader.h │ ├── region.h │ ├── resumable_io.h │ ├── rs.h │ └── tm.h └── lib ├── libqiniu.a └── libqiniu.so