ZLMediaKit / ZLToolKit

一个基于C++11的轻量级网络框架,基于线程池技术可以实现大并发网络IO
MIT License
1.88k stars 571 forks source link

Centos7 编译报错 #144

Closed ShineSea closed 1 year ago

ShineSea commented 1 year ago

gcc版本为7.5.0 错误内容如下: ZLToolKit/src/Util/mini.h:157:34: 错误:no match for ‘operator>>’ (operand types are ‘std::stringstream {aka std::__cxx11::basic_stringstream}’ and ‘toolkit::MD5’) return ss << *this && ss >> t ? t : T();


windows上是能编译通过的,不知道为什么centos7上一直报这个错。
xia-chu commented 1 year ago

有指定c++11编译吗: set(CMAKE_CXX_STANDARD 11) 或者 set(CMAKE_CXX_FLAGS "-std=c++11")

ShineSea commented 1 year ago

有指定c++11编译吗: set(CMAKE_CXX_STANDARD 11) 或者 set(CMAKE_CXX_FLAGS "-std=c++11")

刚刚发现单独编译这个库可以。这个错误是编译整个zlmediakit时报的,有指定C++编译

xia-chu commented 1 year ago

这个问题再开启c++17时会遇到

ShineSea commented 1 year ago

那我是指定的C++17,不能指定17嘛

xia-chu commented 1 year ago

对 暂时不要指定c++17

ShineSea commented 1 year ago

我是在zlmediakit的基础上开发的,用到了11之后的语法,这个问题有什么方法解决嘛,没有的话我就改一下我自己的代码

xia-chu commented 1 year ago

打个补丁支持下:

Index: src/Util/mini.h
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/Util/mini.h b/src/Util/mini.h
--- a/src/Util/mini.h   (revision 7d52e11ae4e8d6d2c20aa0349dbfea8a1d82a968)
+++ b/src/Util/mini.h   (date 1678266193581)
@@ -145,10 +145,21 @@
     }

     template <typename T>
-    T as() const {
+    typename std::enable_if<!std::is_class<T>::value, T>::type as() const {
         return as_default<T>();
     }

+    template <typename T>
+    typename std::enable_if<std::is_class<T>::value, T>::type as() const {
+        return T((const std::string &)*this);
+    }
+
+    template <>
+    bool as<bool>() const;
+
+    template <>
+    uint8_t as<uint8_t>() const;
+
 private:
     template <typename T>
     T as_default() const {
@@ -158,12 +169,6 @@
     }
 };

-template <>
-bool variant::as<bool>() const;
-
-template <>
-uint8_t variant::as<uint8_t>() const;
-
 using mINI = mINI_basic<std::string, variant>;

 }  // namespace toolkit
ShineSea commented 1 year ago

好的,我试试,谢谢

linuxarsenal commented 3 months ago

请问:ubuntu16.04上编译不通过,是什么原因?

信息如下:

-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test HAVE_MMSG_HDR
-- Performing Test HAVE_MMSG_HDR - Success
-- Looking for sendmmsg
-- Looking for sendmmsg - found
-- Looking for recvmmsg
-- Looking for recvmmsg - found
CMake Error at /usr/share/cmake-3.5/Modules/FindOpenSSL.cmake:335 (list):
  list GET given empty list
Call Stack (most recent call first):
  CMakeLists.txt:91 (find_package)

CMake Error at /usr/share/cmake-3.5/Modules/FindOpenSSL.cmake:336 (list):
  list GET given empty list
Call Stack (most recent call first):
  CMakeLists.txt:91 (find_package)

CMake Error at /usr/share/cmake-3.5/Modules/FindOpenSSL.cmake:338 (list):
  list GET given empty list
Call Stack (most recent call first):
  CMakeLists.txt:91 (find_package)

CMake Error at /usr/share/cmake-3.5/Modules/FindOpenSSL.cmake:340 (list):
  list GET given empty list
Call Stack (most recent call first):
  CMakeLists.txt:91 (find_package)

-- 找到openssl库:"/usr/include",ENABLE_OPENSSL宏已打开
-- Performing Test HAVE_MYSQL_OPT_EMBEDDED_CONNECTION
-- Performing Test HAVE_MYSQL_OPT_EMBEDDED_CONNECTION - Success
-- Found MySQL: /usr/include/mysql, /usr/lib/x86_64-linux-gnu/libmysqlclient.so
-- MySQL Embedded not found.
-- 找到mysqlclient库:"/usr/include/mysql",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
cp: cannot create regular file '/home/ubuntu/workspace/vsprj/OpenSourceCodes/ZLToolKit/linux_build/bin/': Not a directory
-- 添加测试程序:test_ssl
-- 添加测试程序:test_ringBuffer
-- 添加测试程序:test_shell
-- 添加测试程序:test_pingpong
-- 添加测试程序:test_tcpClient
-- 添加测试程序:test_semaphore
-- 添加测试程序:test_sql
-- 添加测试程序:test_eventPoller
-- 添加测试程序:test_logger
-- 添加测试程序:test_threadPoolBenchmark
-- 添加测试程序:test_noticeCenter
-- 添加测试程序:test_udpSock
-- 添加测试程序:test_resourcePool
-- 添加测试程序:test_ini
-- 添加测试程序:test_creator
-- 添加测试程序:test_threadPool
-- 添加测试程序:test_tcpEchoServer
-- 添加测试程序:test_delayTask
-- 添加测试程序:test_timer
-- 添加测试程序:test_pipe
-- 添加测试程序:test_variant
-- Configuring incomplete, errors occurred!
See also "/home/ubuntu/workspace/vsprj/OpenSourceCodes/ZLToolKit/linux_build/CMakeFiles/CMakeOutput.log".
make: *** No targets specified and no makefile found.  Stop.