Git Product home page Git Product logo

Comments (1)

oxr463 avatar oxr463 commented on June 22, 2024

Here is a rough draft,

all: sds-install sds-lib sds-test

sds-install: sds-lib
        cp -a libsds.so.2.0.0 /usr/local/lib/
        ln -s /usr/local/lib/libsds.so.2.0.0 /usr/local/lib/libsds.so
        ln -s /usr/local/lib/libsds.so.2.0.0 /usr/local/lib/libsds.so.2
        mkdir -p /usr/local/include/sds
        cp -a sds.h /usr/local/include/sds/

sds-lib: sds.c sds.h sdsalloc.h
        $(CC) -fPIC -fstack-protector -std=c99 -pedantic -Wall -Werror -shared \
                -o libsds.so.2.0.0 -Wl,-soname=libsds.so.2.0.0 sds.c sds.h sdsalloc.h

sds-test: sds.c sds.h testhelp.h
        $(CC) -o sds-test sds.c -Wall -std=c99 -pedantic -O2 -DSDS_TEST_MAIN
        @echo ">>> Type ./sds-test to run the sds.c unit tests."

clean:
        rm -f sds-test libsd.so.2.0.0

See also: cJSON/Makefile

Also, the compiler complains about sdsalloc.h with -pedantic, so I appended the following,

echo "typedef int sdsvoid;" >> sdsalloc.h

Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64502

Here is an example program,

#include <sds/sds.h>
#include <stdio.h>

int main (void)
{
    sds mystring = sdsnew("Hello World!");
    printf("%s\n", mystring);
    sdsfree(mystring);
    return 0;
}

Compile with gcc -o hello hello.c -lsds, and run,

./hello
Hello World!

NOTE: Don't forget to run ldconfig!

from sds.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.