Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Building the Qiniu C SDK on Linux Systems

Tech 2

ARM64 Build Process

  1. Clone the Repository

    Fetch the source code from the official repository:

    git clone https://github.com/qiniu/c-sdk.git
    

    If network speeds from the primary source are slow, you can use a mirror repository:

    git clone https://gitee.com/cqnews/c-qiniu-sdk.git
    
  2. Install Dependencies

    The SDK requires the libcurl and openssl development libraries. Install them using your package menager:

    sudo apt-get install libcurl4-openssl-dev libssl-dev
    
  3. 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
    
  4. Create a Stattic Library

    After generating the object files (.o), you can archive them into a static library using the ar tool:

    ar rcs libqiniu.a *.o
    
  5. 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
    
  6. 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
    
Tags: qiniuc-sdk

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.