Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

编译失败 #6

Closed
oska874 opened this issue Feb 25, 2018 · 4 comments
Closed

编译失败 #6

oska874 opened this issue Feb 25, 2018 · 4 comments

Comments

@oska874
Copy link

oska874 commented Feb 25, 2018

环境是 ubuntu 17.10 64bit
gcc 版本 gcc version 7.2.0 (Ubuntu 7.2.0-8ubuntu3.2)

错误记录如下:

./build_for_linux.sh
-- 找到openssl库:"/usr/include",ENABLE_OPENSSL宏已打开
-- Found MySQL: /usr/include, /usr/lib/x86_64-linux-gnu/libmysqlclient.so
-- MySQL Embedded not found.
-- 找到mysqlclient库:"/usr/include",ENABLE_MYSQL宏已打开
-- 将链接依赖库:/usr/lib/x86_64-linux-gnu/libssl.so;/usr/lib/x86_64-linux-gnu/libcrypto.so;/usr/lib/x86_64-linux-gnu/libmysqlclient.so
-- 添加测试程序:test_asyncTaskThrad
-- 添加测试程序:test_eventPoller
-- 添加测试程序:test_logger
-- 添加测试程序:test_noticeCenter
-- 添加测试程序:test_pipe
-- 添加测试程序:test_resourcePool
-- 添加测试程序:test_ringBuffer
-- 添加测试程序:test_rwmutex
-- 添加测试程序:test_semaphore
-- 添加测试程序:test_shell
-- 添加测试程序:test_spin_mutex
-- 添加测试程序:test_sql
-- 添加测试程序:test_ssl
-- 添加测试程序:test_tcpClient
-- 添加测试程序:test_tcpEchoServer
-- 添加测试程序:test_threadPool
-- 添加测试程序:test_threadPoolBenchmark
-- 添加测试程序:test_udpSock
-- Configuring done
-- Generating done
-- Build files have been written to: /home/zhang/src/cpp/ZLToolKit/linux_build
[  1%] Building CXX object CMakeFiles/ZLToolKit_shared.dir/src/Thread/AsyncTaskThread.cpp.o
[  1%] Building CXX object CMakeFiles/ZLToolKit_shared.dir/src/Util/SqlConnection.cpp.o
[  1%] Building CXX object CMakeFiles/ZLToolKit_static.dir/src/Thread/AsyncTaskThread.cpp.o
[  1%] Building CXX object CMakeFiles/ZLToolKit_static.dir/src/Util/File.cpp.o
In file included from /home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:27:0:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:50:2: error: ‘function’ does not name a type; did you mean ‘union’?
  function<bool()> task;
  ^~~~~~~~
  union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:59:62: error: ‘function’ does not name a type; did you mean ‘union’?
  void DoTaskDelay(uint64_t type, uint64_t millisecond, const function<bool()> &func);
                                                              ^~~~~~~~
                                                              union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:59:70: error: expected ‘,’ or ‘...’ before ‘<’ token
  void DoTaskDelay(uint64_t type, uint64_t millisecond, const function<bool()> &func);
                                                                      ^
In file included from /home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:27:0:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:50:2: error: ‘function’ does not name a type; did you mean ‘union’?
  function<bool()> task;
  ^~~~~~~~
  union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:59:62: error: ‘function’ does not name a type; did you mean ‘union’?
  void DoTaskDelay(uint64_t type, uint64_t millisecond, const function<bool()> &func);
                                                              ^~~~~~~~
                                                              union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:59:70: error: expected ‘,’ or ‘...’ before ‘<’ token
  void DoTaskDelay(uint64_t type, uint64_t millisecond, const function<bool()> &func);
                                                                      ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:83:45: error: ‘function’ does not name a type; did you mean ‘union’?
  AsyncTaskHelper(uint64_t millisecond,const function<bool()> &task){
                                             ^~~~~~~~
                                             union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:83:53: error: expected ‘,’ or ‘...’ before ‘<’ token
  AsyncTaskHelper(uint64_t millisecond,const function<bool()> &task){
                                                     ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h: In constructor ‘ZL::Thread::AsyncTaskHelper::AsyncTaskHelper(uint64_t, int)’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:84:88: error: ‘task’ was not declared in this scope
   AsyncTaskThread::Instance().DoTaskDelay(reinterpret_cast<uint64_t>(this),millisecond,task);
                                                                                        ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: At global scope:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:50:77: error: ‘function’ does not name a type; did you mean ‘union’?
 void AsyncTaskThread::DoTaskDelay(uint64_t type, uint64_t millisecond,const function<bool()> &func) {
                                                                             ^~~~~~~~
                                                                             union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:50:85: error: expected ‘,’ or ‘...’ before ‘<’ token
 void AsyncTaskThread::DoTaskDelay(uint64_t type, uint64_t millisecond,const function<bool()> &func) {
                                                                                     ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: In member function ‘void ZL::Thread::AsyncTaskThread::DoTaskDelay(uint64_t, uint64_t, int)’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:8: error: ‘using element_type = struct ZL::Thread::TaskInfo {aka struct ZL::Thread::TaskInfo}’ has no member named ‘task’
  info->task = func;
        ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:15: error: ‘func’ was not declared in this scope
  info->task = func;
               ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:15: note: suggested alternative: ‘sync’
  info->task = func;
               ^~~~
               sync
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:83:45: error: ‘function’ does not name a type; did you mean ‘union’?
  AsyncTaskHelper(uint64_t millisecond,const function<bool()> &task){
                                             ^~~~~~~~
                                             union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:83:53: error: expected ‘,’ or ‘...’ before ‘<’ token
  AsyncTaskHelper(uint64_t millisecond,const function<bool()> &task){
                                                     ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h: In constructor ‘ZL::Thread::AsyncTaskHelper::AsyncTaskHelper(uint64_t, int)’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:84:88: error: ‘task’ was not declared in this scope
   AsyncTaskThread::Instance().DoTaskDelay(reinterpret_cast<uint64_t>(this),millisecond,task);
                                                                                        ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: In member function ‘void ZL::Thread::AsyncTaskThread::DoTask()’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:100:18: error: ‘using element_type = struct ZL::Thread::TaskInfo {aka struct ZL::Thread::TaskInfo}’ has no member named ‘task’
     flag = info->task();
                  ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: At global scope:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:50:77: error: ‘function’ does not name a type; did you mean ‘union’?
 void AsyncTaskThread::DoTaskDelay(uint64_t type, uint64_t millisecond,const function<bool()> &func) {
                                                                             ^~~~~~~~
                                                                             union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:50:85: error: expected ‘,’ or ‘...’ before ‘<’ token
 void AsyncTaskThread::DoTaskDelay(uint64_t type, uint64_t millisecond,const function<bool()> &func) {
                                                                                     ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: In member function ‘void ZL::Thread::AsyncTaskThread::DoTaskDelay(uint64_t, uint64_t, int)’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:8: error: ‘using element_type = struct ZL::Thread::TaskInfo {aka struct ZL::Thread::TaskInfo}’ has no member named ‘task’
  info->task = func;
        ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:15: error: ‘func’ was not declared in this scope
  info->task = func;
               ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:15: note: suggested alternative: ‘sync’
  info->task = func;
               ^~~~
               sync
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: In member function ‘void ZL::Thread::AsyncTaskThread::DoTask()’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:100:18: error: ‘using element_type = struct ZL::Thread::TaskInfo {aka struct ZL::Thread::TaskInfo}’ has no member named ‘task’
     flag = info->task();
                  ^~~~
[  1%] Building CXX object CMakeFiles/ZLToolKit_shared.dir/src/Util/util.cpp.o
[  1%] Building CXX object CMakeFiles/ZLToolKit_static.dir/src/Util/MD5.cpp.o
At global scope:
cc1plus: warning: unrecognized command line option ‘-Wno-predefined-identifier-outside-function’
At global scope:
cc1plus: warning: unrecognized command line option ‘-Wno-predefined-identifier-outside-function’
CMakeFiles/ZLToolKit_shared.dir/build.make:254: recipe for target 'CMakeFiles/ZLToolKit_shared.dir/src/Thread/AsyncTaskThread.cpp.o' failed
make[2]: *** [CMakeFiles/ZLToolKit_shared.dir/src/Thread/AsyncTaskThread.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/ZLToolKit_static.dir/build.make:254: recipe for target 'CMakeFiles/ZLToolKit_static.dir/src/Thread/AsyncTaskThread.cpp.o' failed
make[2]: *** [CMakeFiles/ZLToolKit_static.dir/src/Thread/AsyncTaskThread.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[  1%] Building CXX object CMakeFiles/ZLToolKit_static.dir/src/Util/SSLBox.cpp.o
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/ZLToolKit_shared.dir/all' failed
make[1]: *** [CMakeFiles/ZLToolKit_shared.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/ZLToolKit_static.dir/all' failed
make[1]: *** [CMakeFiles/ZLToolKit_static.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
[  1%] Building CXX object CMakeFiles/ZLToolKit_shared.dir/src/Thread/AsyncTaskThread.cpp.o
In file included from /home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:27:0:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:50:2: error: ‘function’ does not name a type; did you mean ‘union’?
  function<bool()> task;
  ^~~~~~~~
  union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:59:62: error: ‘function’ does not name a type; did you mean ‘union’?
  void DoTaskDelay(uint64_t type, uint64_t millisecond, const function<bool()> &func);
                                                              ^~~~~~~~
                                                              union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:59:70: error: expected ‘,’ or ‘...’ before ‘<’ token
  void DoTaskDelay(uint64_t type, uint64_t millisecond, const function<bool()> &func);
                                                                      ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:83:45: error: ‘function’ does not name a type; did you mean ‘union’?
  AsyncTaskHelper(uint64_t millisecond,const function<bool()> &task){
                                             ^~~~~~~~
                                             union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:83:53: error: expected ‘,’ or ‘...’ before ‘<’ token
  AsyncTaskHelper(uint64_t millisecond,const function<bool()> &task){
                                                     ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h: In constructor ‘ZL::Thread::AsyncTaskHelper::AsyncTaskHelper(uint64_t, int)’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:84:88: error: ‘task’ was not declared in this scope
   AsyncTaskThread::Instance().DoTaskDelay(reinterpret_cast<uint64_t>(this),millisecond,task);
                                                                                        ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: At global scope:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:50:77: error: ‘function’ does not name a type; did you mean ‘union’?
 void AsyncTaskThread::DoTaskDelay(uint64_t type, uint64_t millisecond,const function<bool()> &func) {
                                                                             ^~~~~~~~
                                                                             union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:50:85: error: expected ‘,’ or ‘...’ before ‘<’ token
 void AsyncTaskThread::DoTaskDelay(uint64_t type, uint64_t millisecond,const function<bool()> &func) {
                                                                                     ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: In member function ‘void ZL::Thread::AsyncTaskThread::DoTaskDelay(uint64_t, uint64_t, int)’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:8: error: ‘using element_type = struct ZL::Thread::TaskInfo {aka struct ZL::Thread::TaskInfo}’ has no member named ‘task’
  info->task = func;
        ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:15: error: ‘func’ was not declared in this scope
  info->task = func;
               ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:15: note: suggested alternative: ‘sync’
  info->task = func;
               ^~~~
               sync
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: In member function ‘void ZL::Thread::AsyncTaskThread::DoTask()’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:100:18: error: ‘using element_type = struct ZL::Thread::TaskInfo {aka struct ZL::Thread::TaskInfo}’ has no member named ‘task’
     flag = info->task();
                  ^~~~
At global scope:
cc1plus: warning: unrecognized command line option ‘-Wno-predefined-identifier-outside-function’
CMakeFiles/ZLToolKit_shared.dir/build.make:254: recipe for target 'CMakeFiles/ZLToolKit_shared.dir/src/Thread/AsyncTaskThread.cpp.o' failed
make[2]: *** [CMakeFiles/ZLToolKit_shared.dir/src/Thread/AsyncTaskThread.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/ZLToolKit_shared.dir/all' failed
make[1]: *** [CMakeFiles/ZLToolKit_shared.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

看上去像是function模板不支持,应该怎么办?

@oska874
Copy link
Author

oska874 commented Feb 25, 2018

Thread/AsyncTaskThread.h 中引用 functional 头文件就解决一批问题,但是其他用到function的文件也有类似问题。

@oska874
Copy link
Author

oska874 commented Feb 25, 2018

这个项目在linux 编译通过了吗?我看编译状态是 build|passing,比较疑惑

@xia-chu
Copy link
Member

xia-chu commented Feb 26, 2018

这个项目在 linux、macOS、windows、iOS、android上都编译过,从没遇到您所述问题,我也很疑惑!不知道是不是你GCC版本太高的原因,我最高只用过gcc6.2编译这个项目,也没遇到你所述问题,也没有其他朋友反馈这个问题

@oska874
Copy link
Author

oska874 commented Feb 26, 2018

刚好我电脑上有gcc6,试了下ok了,看起来就是因为编译器版本的问题 ——不支持7.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants