File tree Expand file tree Collapse file tree 5 files changed +42
-13
lines changed
Expand file tree Collapse file tree 5 files changed +42
-13
lines changed Original file line number Diff line number Diff line change 11bin /*
22* .o
3+ lib *
Original file line number Diff line number Diff line change @@ -11,45 +11,68 @@ LOGFILE = test_server.log
1111
1212# binaries and folders
1313BINDIR = bin
14+ LIBDIR = lib
1415TEST = $(BINDIR ) /test
16+ LIBNAME = librestclient-cpp.so
17+ LIB = $(LIBDIR ) /$(LIBNAME )
18+ STATIC = $(LIBDIR ) /librestclient-cpp.a
1519
1620# set library and include paths
1721INCLUDE = -I. -I/usr/local/include
1822TESTLIBS = -lgtest -lcurl
1923LIBS = -lcurl
2024
2125# set compiler and linker flags
22- CCFLAGS = -O3 -W -Wall
26+ CCFLAGS = -fPIC - O3 -W -Wall
2327LDFLAGS = -W -Wall -L/usr/local/lib
2428
2529# source files
2630SRCS = source/restclient.cpp
27- SRCS += $(wildcard test/test* .cpp)
31+
32+ # test source files
33+ TESTSRCS = $(SRCS )
34+ TESTSRCS += $(wildcard test/test* .cpp)
2835
2936# dependencies
3037# object files
3138OBJS = $(SRCS:.cpp=.o )
39+ TESTOBJS = $(TESTSRCS:.cpp=.o )
3240
3341# linking rule
34- $(TEST ) : $(OBJS ) $(BINDIR )
35- $(LD ) $(LDFLAGS ) $(OBJS ) -o $(TEST ) $(TESTLIBS )
42+ $(TEST ) : $(TESTOBJS ) $(BINDIR )
43+ $(LD ) $(LDFLAGS ) $(TESTOBJS ) -o $(TEST ) $(TESTLIBS )
44+
45+ # dynamic lib rule
46+ $(LIB ) : $(OBJS ) $(LIBDIR )
47+ $(LD ) $(LDFLAGS ) -shared -soname,$(LIBNAME ) -o $(LIB ) $(OBJS ) $(LIBS )
48+
49+ # static lib rule
50+ $(STATIC ) : $(OBJS ) $(LIBDIR )
51+ ar rcs $(STATIC ) $(OBJS )
3652
3753# compile rule
3854.cpp.o :
3955 $(CC ) $(CCFLAGS ) $(INCLUDE ) -c $< -o $@
4056
41-
4257$(BINDIR ) :
4358 @mkdir -p $(BINDIR )
4459
60+ $(LIBDIR ) :
61+ @mkdir -p $(LIBDIR )
62+
4563# tasks
46- .PHONY : clean all
64+ .PHONY : clean
4765
4866clean :
4967 @rm -rf test/* .o
5068 @rm -rf source/* .o
5169 @rm -rf bin
70+ @rm -rf lib
5271
53- all : $(TEST )
72+ test : $(TEST )
5473 @echo Running tests...
5574 @./bin/test
75+
76+ dynamiclibrary : $(LIB )
77+
78+ staticlibrary : $(STATIC )
Original file line number Diff line number Diff line change 11# REST client for C++
22
33## About
4- This is a simple REST client for C++. It wraps libcurl for HTTP requests
5- and uses jsoncpp for parsing JSON responses.
4+ This is a simple REST client for C++. It wraps libcurl for HTTP requests.
65
76## Usage
87I tried to keep usage close to the [ ruby rest-client] [ ] . So the basic usage is:
@@ -18,11 +17,17 @@ Examples:
1817 RestClient::put("http://url.com/put", "text/json", "{"foo": "bla"}")
1918 RestClient::del("http://url.com/delete")
2019
20+ The response is of type RestClient::response and has two attributes:
21+
22+ RestClient::response.code // HTTP response code
23+ RestClient::response.body // HTTP response body
24+
25+
2126## Dependencies
2227- [ libcurl] [ ]
23- - [ jsoncpp ] [ ]
28+ - [ gtest ] [ ] for development
2429
2530
2631[ libcurl ] : http://curl.haxx.se/libcurl/
27- [ jsoncpp ] : http://jsoncpp.sourceforge.net/
2832[ ruby rest-client ] : http://github.com/archiloque/rest-client
33+ [ gtest ] : http://code.google.com/p/googletest/
Original file line number Diff line number Diff line change 88#define INCLUDE_META_H_
99
1010// version string normally set from makefile
11- #define VERSION "0.1.0 "
11+ #define VERSION "0.1.1 "
1212
1313#endif // INCLUDE_META_H_
1414
Original file line number Diff line number Diff line change 1111
1212#include < curl/curl.h>
1313#include < string>
14- #include " include/ meta.h"
14+ #include " meta.h"
1515
1616class RestClient
1717{
You can’t perform that action at this time.
0 commit comments