Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make install target #97

Open
topilski opened this issue Apr 16, 2018 · 1 comment
Open

Make install target #97

topilski opened this issue Apr 16, 2018 · 1 comment

Comments

@topilski
Copy link

May be will be useful add make install target.

@oxr463
Copy link

oxr463 commented Feb 22, 2019

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!

oxr463 added a commit to oxr463/sds that referenced this issue May 6, 2019
oxr463 added a commit to oxr463/sds that referenced this issue May 12, 2020
oxr463 added a commit to oxr463/sds that referenced this issue May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants