Commit 6a2aafc8 authored by gejun's avatar gejun

Fix compilation in ubuntu; Update README

Change-Id: I2a2ba1d9c9180f8d7210508207442b77d4f115da
parent 83507a6b
......@@ -261,7 +261,7 @@ libmcpack2pb.dbg.a:$(MCPACK2PB_DEBUG_OBJS)
protoc-gen-mcpack:mcpack2pb/generator.o libmcpack2pb.a libbase.a libbthread.a libbvar.a
@echo "Linking $@"
@$(CXX) -o $@ $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic $(DYNAMIC_LINKINGS) -Xlinker "-)"
@$(CXX) -o $@ $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS)
libbrpc.a:$(BRPC_OBJS)
@echo "Packing $@"
......
......@@ -8,18 +8,22 @@ protobuf: sudo apt-get install libprotobuf-dev libprotoc-dev protobuf-compiler
leveldb(used by rpcz): sudo apt-get install libleveldb-dev libsnappy-dev
openssl(for https): libssl-dev
**compile**
git clone this repo. cd into the repo and run: sh config_brpc.sh --incs=/usr/include --libs=/usr/lib
git clone this repo. cd into the repo and run: sh config_brpc.sh --headers=/usr/include --libs=/usr/lib
**run echo example**
cd into example/echo_c++, make, run echo_server and echo_client
**run examples with cpu/heap profilers**
sudo apt-get install libgoogle-perftools-dev libunwind-dev liblzma-dev
Rerun config_brpc.sh
**compile tests**
Install gmock and gtest, use the gtest embedded in gmock and don't install libgtest-dev
sudo apt-get install google-mock; cd /usr/src; sudo cmake .; sudo make; sudo mv lib*.a gtest/lib*.a /usr/lib; sudo mv gtest/include/gtest /usr/include/
Rerun config_brpc.sh and run make in test/
### Baidu-internal
**setup directories**
download deps: third-64/gflags@gflags_2-0-0-100_PD_BL third-64/protobuf@protobuf_2-4-1-1100_PD_BL third-64/leveldb@leveldb_1-0-0-0_PD_BL
**compile**
git clone this repo. cd into the repo and run: sh config_brpc.sh --incs=../../../third-64 --libs=../../../third-64
git clone this repo. cd into the repo and run: sh config_brpc.sh --headers=../../../third-64 --libs=../../../third-64
**run examples with cpu/heap profilers**
download deps: third-64/tcmalloc@tcmalloc_1-7-0-200_PD_BL
Rerun config_brpc.sh
......@@ -123,7 +123,9 @@ CONTENT="${CONTENT}\nDYNAMIC_LINKINGS=$DYNAMIC_LINKINGS"
CONTENT="${CONTENT}\nifeq (\$(NEED_GPERFTOOLS), 1)"
# required by cpu/heap profiler
TCMALLOC_LIB=$(find_dir_of_lib tcmalloc_and_profiler)
if [ ! -z "$TCMALLOC_LIB" ]; then
if [ -z "$TCMALLOC_LIB" ]; then
CONTENT="${CONTENT}\n \$(error \"Fail to find gperftools\")"
else
if absent_in_the_list "$TCMALLOC_LIB" "$LIBS2"; then
CONTENT="${CONTENT}\n LIBS+=$TCMALLOC_LIB"
LIBS2="${LIBS2}\n$TCMALLOC_LIB"
......@@ -159,26 +161,46 @@ CONTENT="${CONTENT}\nendif"
# required by UT
#gtest
GTEST_LIB=$(find_dir_of_lib gtest)
GTEST_HDR=$(find_dir_of_header gtest/gtest.h)
CONTENT="${CONTENT}\nifeq (\$(NEED_GTEST), 1)"
CONTENT="${CONTENT}\n HDRS+=$GTEST_HDR"
CONTENT="${CONTENT}\n LIBS+=$GTEST_LIB"
if [ -f $GTEST_LIB/libgtest.a ]; then
CONTENT="${CONTENT}\n STATIC_LINKINGS+=-lgtest -lgtest_main"
if [ -z "$GTEST_LIB" ]; then
CONTENT="${CONTENT}\n \$(error \"Fail to find gtest\")"
else
CONTENT="${CONTENT}\n DYNAMIC_LINKINGS+=-lgtest -lgtest_main"
GTEST_HDR=$(find_dir_of_header gtest/gtest.h)
if absent_in_the_list "$GTEST_LIB" "$LIBS2"; then
CONTENT="${CONTENT}\n LIBS+=$GTEST_LIB"
LIBS2="${LIBS2}\n$GTEST_LIB"
fi
if absent_in_the_list "$GTEST_HDR" "$HDRS2"; then
CONTENT="${CONTENT}\n HDRS+=$GTEST_HDR"
HDRS2="${HDRS2}\n$GTEST_HDR"
fi
if [ -f $GTEST_LIB/libgtest.a ]; then
CONTENT="${CONTENT}\n STATIC_LINKINGS+=-lgtest -lgtest_main"
else
CONTENT="${CONTENT}\n DYNAMIC_LINKINGS+=-lgtest -lgtest_main"
fi
fi
CONTENT="${CONTENT}\nendif"
#gmock
GMOCK_LIB=$(find_dir_of_lib gmock)
GMOCK_HDR=$(find_dir_of_header gmock/gmock.h)
CONTENT="${CONTENT}\nifeq (\$(NEED_GMOCK), 1)"
CONTENT="${CONTENT}\n HDRS+=$GMOCK_HDR"
CONTENT="${CONTENT}\n LIBS+=$GMOCK_LIB"
if [ -f $GMOCK_LIB/libgmock.a ]; then
CONTENT="${CONTENT}\n STATIC_LINKINGS+=-lgmock -lgmock_main"
if [ -z "$GMOCK_LIB" ]; then
CONTENT="${CONTENT}\n \$(error \"Fail to find gmock\")"
else
CONTENT="${CONTENT}\n DYNAMIC_LINKINGS+=-lgmock -lgmock_main"
GMOCK_HDR=$(find_dir_of_header gmock/gmock.h)
if absent_in_the_list "$GMOCK_LIB" "$LIBS2"; then
CONTENT="${CONTENT}\n LIBS+=$GMOCK_LIB"
LIBS2="${LIBS2}\n$GMOCK_LIB"
fi
if absent_in_the_list "$GMOCK_HDR" "$HDRS2"; then
CONTENT="${CONTENT}\n HDRS+=$GMOCK_HDR"
HDRS2="${HDRS2}\n$GMOCK_HDR"
fi
if [ -f $GMOCK_LIB/libgmock.a ]; then
CONTENT="${CONTENT}\n STATIC_LINKINGS+=-lgmock -lgmock_main"
else
CONTENT="${CONTENT}\n DYNAMIC_LINKINGS+=-lgmock -lgmock_main"
fi
fi
CONTENT="${CONTENT}\nendif"
$ECHO "$CONTENT" > config.mk
......@@ -25,11 +25,11 @@ clean:
echo_client:$(PROTO_OBJS) $(CLIENT_OBJS)
@echo "Linking $@"
@$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic $(DYNAMIC_LINKINGS) -Xlinker "-)" $(LDFLAGS) -o $@
@$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS) -o $@
echo_server:$(PROTO_OBJS) $(SERVER_OBJS)
@echo "Linking $@"
@$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic $(DYNAMIC_LINKINGS) -Xlinker "-)" $(LDFLAGS) -o $@
@$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS) -o $@
%.pb.cc:%.proto
@echo "Generating $@"
......
......@@ -32,15 +32,15 @@ clean:
http_client:$(CLIENT_OBJS)
@echo "Linking $@"
@$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic $(DYNAMIC_LINKINGS) -Xlinker "-)" -o $@
@$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS) -o $@
benchmark_http:$(BENCHMARK_OBJS)
@echo "Linking $@"
@$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic $(DYNAMIC_LINKINGS) -Xlinker "-)" -o $@
@$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS) -o $@
http_server:$(PROTO_OBJS) $(SERVER_OBJS)
@echo "Linking $@"
@$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic $(DYNAMIC_LINKINGS) -Xlinker "-)" -o $@
@$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS) -o $@
%.pb.cc:%.proto
@echo "Generating $@"
......
......@@ -19,7 +19,7 @@ clean:
memcache_client:$(OBJS)
@echo "Linking $@"
@$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic $(DYNAMIC_LINKINGS) -Xlinker "-)" -o $@
@$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS) -o $@
%.o:%.cpp
@echo "Compiling $@"
......
......@@ -30,11 +30,11 @@ clean:
echo_client:$(PROTO_OBJS) $(CLIENT_OBJS)
@echo "Linking $@"
@$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic $(DYNAMIC_LINKINGS) -Xlinker "-)" -o $@
@$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS) -o $@
echo_server:$(PROTO_OBJS) $(SERVER_OBJS)
@echo "Linking $@"
@$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic $(DYNAMIC_LINKINGS) -Xlinker "-)" -o $@
@$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS) -o $@
%.pb.cc:%.proto
@echo "Generating $@"
......
......@@ -23,11 +23,11 @@ clean:
redis_press:$(PRESS_OBJS)
@echo "Linking $@"
@$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic $(DYNAMIC_LINKINGS) -Xlinker "-)" -o $@
@$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS) -o $@
redis_cli:$(CLI_OBJS)
@echo "Linking $@"
@$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic $(DYNAMIC_LINKINGS) -Xlinker "-)" -o $@
@$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS) -o $@
%.o:%.cpp
@echo "Compiling $@"
......
......@@ -9,7 +9,6 @@ CFLAGS=$(CPPFLAGS) -g -pipe -Wall -W -Werror -fPIC -fstrict-aliasing -Wno-unused
HDRPATHS=-I. -I.. $(addprefix -I, $(HDRS))
LIBPATHS=$(addprefix -L, $(LIBS))
LDFLAGS=-Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic $(DYNAMIC_LINKINGS)
TEST_BASE_SOURCES = \
at_exit_unittest.cc \
......@@ -172,19 +171,19 @@ clean_bins:
test_base:$(TEST_BASE_OBJS) ../libbase.dbg.a
@echo "Linking $@"
@$(CXX) -o $@ $(LIBPATHS) -Xlinker "-(" $^ $(LDFLAGS) -Xlinker "-)"
@$(CXX) -o $@ $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS)
test_bvar:$(TEST_BVAR_OBJS) ../libbase.dbg.a ../libbvar.dbg.a
@echo "Linking $@"
@$(CXX) -o $@ $(LIBPATHS) -Xlinker "-(" $^ $(LDFLAGS) -Xlinker "-)"
@$(CXX) -o $@ $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS)
bthread%unittest:bthread%unittest.o ../libbase.dbg.a ../libbvar.dbg.a ../libbthread.dbg.a
@echo "Linking $@"
@$(CXX) -o $@ $(LIBPATHS) -Xlinker "-(" $^ $(LDFLAGS) -Xlinker "-)"
@$(CXX) -o $@ $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS)
brpc_%_unittest:brpc_%_unittest.o $(TEST_PROTO_OBJS) ../libbase.dbg.a ../libbvar.dbg.a ../libbthread.dbg.a ../libbrpc.dbg.a ../libmcpack2pb.dbg.a ../libjson2pb.dbg.a
brpc_%_unittest:$(TEST_PROTO_OBJS) brpc_%_unittest.o ../libbase.dbg.a ../libbvar.dbg.a ../libbthread.dbg.a ../libbrpc.dbg.a ../libmcpack2pb.dbg.a ../libjson2pb.dbg.a
@echo "Linking $@"
@$(CXX) -o $@ $(LIBPATHS) -Xlinker "-(" $^ $(LDFLAGS) -Xlinker "-)"
@$(CXX) -o $@ $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS)
%.pb.cc:%.proto
@echo "Generating $@"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment