Commit 77180e84 authored by zhujiashun's avatar zhujiashun

Make all examples can be compiled in MacOSX

parent 68190988
...@@ -71,16 +71,40 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB)) ...@@ -71,16 +71,40 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
endif() endif()
include_directories(${LEVELDB_INCLUDE_PATH}) include_directories(${LEVELDB_INCLUDE_PATH})
find_library(SSL_LIB NAMES ssl)
if (NOT SSL_LIB)
message(FATAL_ERROR "Fail to find ssl")
endif()
find_library(CRYPTO_LIB NAMES crypto)
if (NOT CRYPTO_LIB)
message(FATAL_ERROR "Fail to find crypto")
endif()
set(DYNAMIC_LIB set(DYNAMIC_LIB
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_THREAD_LIBS_INIT}
${GFLAGS_LIBRARY} ${GFLAGS_LIBRARY}
${PROTOBUF_LIBRARIES} ${PROTOBUF_LIBRARIES}
${LEVELDB_LIB} ${LEVELDB_LIB}
ssl ${SSL_LIB}
crypto ${CRYPTO_LIB}
dl dl
) )
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(DYNAMIC_LIB ${DYNAMIC_LIB}
pthread
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework CoreData"
"-framework CoreText"
"-framework Security"
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop")
endif()
add_executable(redis_cli redis_cli.cpp) add_executable(redis_cli redis_cli.cpp)
add_executable(redis_press redis_press.cpp) add_executable(redis_press redis_press.cpp)
......
...@@ -151,7 +151,7 @@ int main(int argc, char* argv[]) { ...@@ -151,7 +151,7 @@ int main(int argc, char* argv[]) {
args[i].base_index = i * FLAGS_batch; args[i].base_index = i * FLAGS_batch;
args[i].redis_channel = &channel; args[i].redis_channel = &channel;
if (!FLAGS_use_bthread) { if (!FLAGS_use_bthread) {
if (pthread_create(&tids[i], NULL, sender, &args[i]) != 0) { if (pthread_create((pthread_t*)&tids[i], NULL, sender, &args[i]) != 0) {
LOG(ERROR) << "Fail to create pthread"; LOG(ERROR) << "Fail to create pthread";
return -1; return -1;
} }
...@@ -174,7 +174,7 @@ int main(int argc, char* argv[]) { ...@@ -174,7 +174,7 @@ int main(int argc, char* argv[]) {
LOG(INFO) << "redis_client is going to quit"; LOG(INFO) << "redis_client is going to quit";
for (int i = 0; i < FLAGS_thread_num; ++i) { for (int i = 0; i < FLAGS_thread_num; ++i) {
if (!FLAGS_use_bthread) { if (!FLAGS_use_bthread) {
pthread_join(tids[i], NULL); pthread_join((pthread_t)tids[i], NULL);
} else { } else {
bthread_join(tids[i], NULL); bthread_join(tids[i], NULL);
} }
......
...@@ -71,16 +71,40 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB)) ...@@ -71,16 +71,40 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
endif() endif()
include_directories(${LEVELDB_INCLUDE_PATH}) include_directories(${LEVELDB_INCLUDE_PATH})
find_library(SSL_LIB NAMES ssl)
if (NOT SSL_LIB)
message(FATAL_ERROR "Fail to find ssl")
endif()
find_library(CRYPTO_LIB NAMES crypto)
if (NOT CRYPTO_LIB)
message(FATAL_ERROR "Fail to find crypto")
endif()
set(DYNAMIC_LIB set(DYNAMIC_LIB
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_THREAD_LIBS_INIT}
${GFLAGS_LIBRARY} ${GFLAGS_LIBRARY}
${PROTOBUF_LIBRARIES} ${PROTOBUF_LIBRARIES}
${LEVELDB_LIB} ${LEVELDB_LIB}
ssl ${SSL_LIB}
crypto ${CRYPTO_LIB}
dl dl
) )
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(DYNAMIC_LIB ${DYNAMIC_LIB}
pthread
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework CoreData"
"-framework CoreText"
"-framework Security"
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop")
endif()
add_executable(selective_echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER}) add_executable(selective_echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
add_executable(selective_echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER}) add_executable(selective_echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
......
...@@ -201,7 +201,7 @@ int main(int argc, char* argv[]) { ...@@ -201,7 +201,7 @@ int main(int argc, char* argv[]) {
tids.resize(FLAGS_thread_num); tids.resize(FLAGS_thread_num);
if (!FLAGS_use_bthread) { if (!FLAGS_use_bthread) {
for (int i = 0; i < FLAGS_thread_num; ++i) { for (int i = 0; i < FLAGS_thread_num; ++i) {
if (pthread_create(&tids[i], NULL, sender, &channel) != 0) { if (pthread_create((pthread_t*)&tids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create pthread"; LOG(ERROR) << "Fail to create pthread";
return -1; return -1;
} }
...@@ -225,7 +225,7 @@ int main(int argc, char* argv[]) { ...@@ -225,7 +225,7 @@ int main(int argc, char* argv[]) {
LOG(INFO) << "EchoClient is going to quit"; LOG(INFO) << "EchoClient is going to quit";
for (int i = 0; i < FLAGS_thread_num; ++i) { for (int i = 0; i < FLAGS_thread_num; ++i) {
if (!FLAGS_use_bthread) { if (!FLAGS_use_bthread) {
pthread_join(tids[i], NULL); pthread_join((pthread_t)tids[i], NULL);
} else { } else {
bthread_join(tids[i], NULL); bthread_join(tids[i], NULL);
} }
......
...@@ -71,16 +71,47 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB)) ...@@ -71,16 +71,47 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
endif() endif()
include_directories(${LEVELDB_INCLUDE_PATH}) include_directories(${LEVELDB_INCLUDE_PATH})
find_path(LEVELDB_INCLUDE_PATH NAMES leveldb/db.h)
find_library(LEVELDB_LIB NAMES leveldb)
if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
message(FATAL_ERROR "Fail to find leveldb")
endif()
include_directories(${LEVELDB_INCLUDE_PATH})
find_library(SSL_LIB NAMES ssl)
if (NOT SSL_LIB)
message(FATAL_ERROR "Fail to find ssl")
endif()
find_library(CRYPTO_LIB NAMES crypto)
if (NOT CRYPTO_LIB)
message(FATAL_ERROR "Fail to find crypto")
endif()
set(DYNAMIC_LIB set(DYNAMIC_LIB
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_THREAD_LIBS_INIT}
${GFLAGS_LIBRARY} ${GFLAGS_LIBRARY}
${PROTOBUF_LIBRARIES} ${PROTOBUF_LIBRARIES}
${LEVELDB_LIB} ${LEVELDB_LIB}
ssl ${SSL_LIB}
crypto ${CRYPTO_LIB}
dl dl
) )
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(DYNAMIC_LIB ${DYNAMIC_LIB}
pthread
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework CoreData"
"-framework CoreText"
"-framework Security"
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop")
endif()
add_executable(session_data_and_thread_local_client client.cpp ${PROTO_SRC} ${PROTO_HEADER}) add_executable(session_data_and_thread_local_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
add_executable(session_data_and_thread_local_server server.cpp ${PROTO_SRC} ${PROTO_HEADER}) add_executable(session_data_and_thread_local_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
......
...@@ -112,7 +112,7 @@ int main(int argc, char* argv[]) { ...@@ -112,7 +112,7 @@ int main(int argc, char* argv[]) {
tids.resize(FLAGS_thread_num); tids.resize(FLAGS_thread_num);
if (!FLAGS_use_bthread) { if (!FLAGS_use_bthread) {
for (int i = 0; i < FLAGS_thread_num; ++i) { for (int i = 0; i < FLAGS_thread_num; ++i) {
if (pthread_create(&tids[i], NULL, sender, &channel) != 0) { if (pthread_create((pthread_t*)&tids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create pthread"; LOG(ERROR) << "Fail to create pthread";
return -1; return -1;
} }
...@@ -136,7 +136,7 @@ int main(int argc, char* argv[]) { ...@@ -136,7 +136,7 @@ int main(int argc, char* argv[]) {
LOG(INFO) << "EchoClient is going to quit"; LOG(INFO) << "EchoClient is going to quit";
for (int i = 0; i < FLAGS_thread_num; ++i) { for (int i = 0; i < FLAGS_thread_num; ++i) {
if (!FLAGS_use_bthread) { if (!FLAGS_use_bthread) {
pthread_join(tids[i], NULL); pthread_join((pthread_t)tids[i], NULL);
} else { } else {
bthread_join(tids[i], NULL); bthread_join(tids[i], NULL);
} }
......
...@@ -66,16 +66,40 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB)) ...@@ -66,16 +66,40 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
endif() endif()
include_directories(${LEVELDB_INCLUDE_PATH}) include_directories(${LEVELDB_INCLUDE_PATH})
find_library(SSL_LIB NAMES ssl)
if (NOT SSL_LIB)
message(FATAL_ERROR "Fail to find ssl")
endif()
find_library(CRYPTO_LIB NAMES crypto)
if (NOT CRYPTO_LIB)
message(FATAL_ERROR "Fail to find crypto")
endif()
set(DYNAMIC_LIB set(DYNAMIC_LIB
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_THREAD_LIBS_INIT}
${GFLAGS_LIBRARY} ${GFLAGS_LIBRARY}
${PROTOBUF_LIBRARIES} ${PROTOBUF_LIBRARIES}
${LEVELDB_LIB} ${LEVELDB_LIB}
ssl ${SSL_LIB}
crypto ${CRYPTO_LIB}
dl dl
) )
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(DYNAMIC_LIB ${DYNAMIC_LIB}
pthread
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework CoreData"
"-framework CoreText"
"-framework Security"
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop")
endif()
add_executable(streaming_echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER}) add_executable(streaming_echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
add_executable(streaming_echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER}) add_executable(streaming_echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
......
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