Simplest usage would be to configure and build libusual locally and point your projects CPPFLAGS and LDFLAGS there.
That way you get access to not only code but also various autoconfigued symbols without any complexities in your project.
Build libusual
$ git clone git://github.com/libusual/libusual.git lib Cloning into 'lib'... done. $ cd lib $ ./autogen.sh [...] $ ./configure --disable-shared --prefix=/opt [...] $ make [...] $ make install DESTDIR=`pwd`/../inst [...] $ cd ..
Build our own code
Now we prepare our own code.
First, this is the source file:
File: prog.c
#include <stdio.h> #include <string.h> #include <usual/hashing/crc32.h> int main(void) { const char *data = "CECSFXX"; uint32_t crc; crc = calc_crc32(data, strlen(data), 0); printf("crc: %08x\n", crc); return 0; }
Here is corresponding Makefile:
File: Makefile
# here we describe our program SRCS = prog.c OBJS = $(SRCS:.c=.o) # here we link to libusual CPPFLAGS = -I./inst/opt/include LDFLAGS = -L./inst/opt/lib LIBS = -lusual CC = gcc CFLAGS = -O -g -Wall all: prog prog: $(OBJS) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
Build the project
$ make gcc -O -g -Wall -I./inst/opt/include -c -o prog.o prog.c gcc -O -g -Wall -L./inst/opt/lib prog.o -lusual -o prog $ ls Makefile inst lib prog prog.c prog.o $ ./prog crc: 12345678
Done!