happyfish100 / libfastcommon

c common functions library extracted from my open source project FastDFS. this library is very simple and stable. functions including: string, logger, chain, hash, socket, ini file reader, base64 encode / decode, url encode / decode, fast timer, skiplist, object pool etc. detail info please see the c header files.
http://bbs.chinaunix.net/forum-240-1.html
GNU Lesser General Public License v3.0
898 stars 530 forks source link

mac make error #26

Open wh-gd opened 5 years ago

wh-gd commented 5 years ago

./make.sh cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o shared_func.o shared_func.c
shared_func.c:2567:9: warning: 'syscall' is deprecated: first deprecated in macOS 10.12 - syscall(2) is unsupported; please switch to a supported interface. For SYS_kdebug_trace use kdebug_signpost(). [-Wdeprecated-declarations] return syscall(NR_gettid); ^ /usr/include/unistd.h:745:6: note: 'syscall' has been explicitly marked deprecated here int syscall(int, ...); ^ shared_func.c:2567:17: error: use of undeclared identifier 'NR_gettid' return syscall(__NR_gettid); ^ 1 warning and 1 error generated. make: *** [shared_func.o] Error 1

mac version:10.13.6

wh-gd commented 5 years ago

pid_t gettid(void) { // return syscall(__NR_gettid);// unit // return syscall(SYS_gettid);// osx

if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12

uint64_t tid64;
pthread_threadid_np(NULL, &tid64);
pid_t tid = (pid_t)tid64;
#else
pid_t tid = syscall(__NR_gettid);
#endif
return tid;

}

修改完后还是编译出错

wh-gd commented 5 years ago

./make.sh cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o shared_func.o shared_func.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o ini_file_reader.o ini_file_reader.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o logger.o logger.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o sockopt.o sockopt.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o base64.o base64.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o sched_thread.o sched_thread.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o http_func.o http_func.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o md5.o md5.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o pthread_func.o pthread_func.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o local_ip_func.o local_ip_func.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o avl_tree.o avl_tree.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o ioevent.o ioevent.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o ioevent_loop.o ioevent_loop.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o fast_task_queue.o fast_task_queue.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o fast_timer.o fast_timer.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o process_ctrl.o process_ctrl.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o fast_mblock.o fast_mblock.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o connection_pool.o connection_pool.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o fast_mpool.o fast_mpool.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o fast_allocator.o fast_allocator.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o fast_buffer.o fast_buffer.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o multi_skiplist.o multi_skiplist.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o flat_skiplist.o flat_skiplist.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o system_info.o system_info.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o fast_blocked_queue.o fast_blocked_queue.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o id_generator.o id_generator.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o char_converter.o char_converter.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o char_convert_loader.o char_convert_loader.c
c++ -Wall -std=c++11 -D_GNU_SOURCE -g -O3 -DDARWIN -c -o lk_queue.o lk_queue.cc
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o hash.lo hash.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o chain.lo chain.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o shared_func.lo shared_func.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o ini_file_reader.lo ini_file_reader.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o logger.lo logger.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o sockopt.lo sockopt.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o base64.lo base64.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o sched_thread.lo sched_thread.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o http_func.lo http_func.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o md5.lo md5.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o pthread_func.lo pthread_func.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o local_ip_func.lo local_ip_func.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o avl_tree.lo avl_tree.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o ioevent.lo ioevent.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o ioevent_loop.lo ioevent_loop.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o fast_task_queue.lo fast_task_queue.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o fast_timer.lo fast_timer.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o process_ctrl.lo process_ctrl.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o fast_mblock.lo fast_mblock.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o connection_pool.lo connection_pool.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o fast_mpool.lo fast_mpool.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o fast_allocator.lo fast_allocator.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o fast_buffer.lo fast_buffer.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o multi_skiplist.lo multi_skiplist.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o flat_skiplist.lo flat_skiplist.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o system_info.lo system_info.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o fast_blocked_queue.lo fast_blocked_queue.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o id_generator.lo id_generator.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o char_converter.lo char_converter.c
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o char_convert_loader.lo char_convert_loader.c
c++ -Wall -std=c++11 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o lk_queue.lo lk_queue.cc
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -DDARWIN -o libfastcommon.so -shared hash.lo chain.lo shared_func.lo ini_file_reader.lo logger.lo sockopt.lo base64.lo sched_thread.lo http_func.lo md5.lo pthread_func.lo local_ip_func.lo avl_tree.lo ioevent.lo ioevent_loop.lo fast_task_queue.lo fast_timer.lo process_ctrl.lo fast_mblock.lo connection_pool.lo fast_mpool.lo fast_allocator.lo fast_buffer.lo multi_skiplist.lo flat_skiplist.lo system_info.lo fast_blocked_queue.lo id_generator.lo char_converter.lo char_convert_loader.lo lk_queue.lo -lm Undefined symbols for architecture x86_64: "std::terminate()", referenced from: _clang_call_terminate in lk_queue.lo "vtable for cxxabiv1::class_type_info", referenced from: typeinfo for moodycamel::details::ConcurrentQueueProducerTypelessBase in lk_queue.lo NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. "vtable for cxxabiv1::si_class_type_info", referenced from: typeinfo for moodycamel::ConcurrentQueue<void, moodycamel::ConcurrentQueueDefaultTraits>::ImplicitProducer in lk_queue.lo NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. "vtable for cxxabiv1::vmi_class_type_info", referenced from: typeinfo for moodycamel::ConcurrentQueue<void, moodycamel::ConcurrentQueueDefaultTraits>::ProducerBase in lk_queue.lo NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. "operator delete(void)", referenced from: _new_lk_queue in lk_queue.lo _delete_lk_queue in lk_queue.lo moodycamel::ConcurrentQueue<void, moodycamel::ConcurrentQueueDefaultTraits>::ImplicitProducer::~ImplicitProducer() in lk_queue.lo "operator new(unsigned long)", referenced from: _new_lk_queue in lk_queue.lo "___cxa_begincatch", referenced from: clang_call_terminate in lk_queue.lo "_gxx_personality_v0", referenced from: _new_lk_queue in lk_queue.lo moodycamel::ConcurrentQueue<void, moodycamel::ConcurrentQueueDefaultTraits>::~ConcurrentQueue() in lk_queue.lo moodycamel::ConcurrentQueue<void, moodycamel::ConcurrentQueueDefaultTraits>::ImplicitProducer::~ImplicitProducer() in lk_queue.lo Dwarf Exception Unwind Info (eh_frame) in lk_queue.lo ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [libfastcommon.so] Error 1

happyfish100 commented 5 years ago

c++ -Wall -std=c++11 -D_GNU_SOURCE -g -O3 -DDARWIN -c -fPIC -o lk_queue.lo lk_queue.cc lk_queue.cc目测是C++文件。 C和C++混合编译惹的祸。生成 libfastcommon.so 时使用c++应该可以解决问题。

liruces commented 5 years ago

对makefile的语法不怎么熟悉,能说说具体更改那个地方吗?谢谢啦

yzjd19900517 commented 4 years ago

您后报这个错误:[root@iZ942yygvxkZ libfastcommon-master]# ./make.sh make: *** 没有规则可以创建“all”需要的目标“hash.o”。 停?