cinatra icon indicating copy to clipboard operation
cinatra copied to clipboard

cinatra对编译器的要求

Open yyyywwwwpppp opened this issue 6 years ago • 25 comments

cinatra gcc 是不是 要求 GCC8+ clang+llvm 是不是要求 llvm7+

Apple LLVM version 9.1.0 (clang-902.0.39.2) 对应的应该是 llvm6版本 linux安装的gcc7.3 都编译不通过

yyyywwwwpppp avatar Jul 29 '18 08:07 yyyywwwwpppp

gcc7.2+即可 支持c17

xmh0511 avatar Jul 29 '18 08:07 xmh0511

在windows上要求vs2017 15.5+版本。 另外编译不通过的错误能否发出来。

qicosmos avatar Jul 29 '18 08:07 qicosmos

centos7.5 yum install centos-release-scl yum install devtoolset-7 scl enable devtoolset-7 bash gcc -v gcc version 7.3.1 20180303 (Red Hat 7.3.1-5) (GCC) git clone cinatra cd cinatra && mkdir gcc-build && cd gcc-build cmake .. make /root/cinatra/uuid.h: In member function ‘uuids::uuid uuids::uuid_system_generator::operator()()’: /root/cinatra/uuid.h:833:17: error: aggregate ‘uuid_t id’ has incomplete type and cannot be defined uuid_t id; ^~ /root/cinatra/uuid.h:834:10: error: ‘uuid_generate’ was not declared in this scope uuid_generate(id); ^~~~~~~~~~~~~ /root/cinatra/uuid.h:834:10: note: suggested alternative: ‘uuid_create’ uuid_generate(id); ^~~~~~~~~~~~~ uuid_create 截图: qq20180729-171952

yyyywwwwpppp avatar Jul 29 '18 09:07 yyyywwwwpppp

这里需要安装一下uuid库 sudo apt-get install uuid 或者 sudo yum install libuuid-devel.x86_64

qicosmos avatar Jul 29 '18 09:07 qicosmos

这个库文件已经装过了 Package libuuid-devel-2.23.2-52.el7.x86_64 already installed and latest version Package uuid-1.6.2-26.el7.x86_64 already installed and latest version

yyyywwwwpppp avatar Jul 29 '18 09:07 yyyywwwwpppp

mac 10.13.6 Apple LLVM version 9.1.0 (clang-902.0.39.2) http_server.hpp:11:10: fatal error: 'experimental/filesystem' file not found #include <experimental/filesystem> 这个实验性的文件夹已经没有这个文件了 /Library/Developer/CommandLineTools/usr/include/c++/v1/experimental /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/experimental 用clion打开 cinatra 这个工程,也是个找不到这个文件,找的路径也是 上面的路径

yyyywwwwpppp avatar Jul 29 '18 09:07 yyyywwwwpppp

Clang 下是不是已经在std里面了?

qicosmos avatar Jul 29 '18 09:07 qicosmos

这个错误有点奇怪,按理说你是mac的话,不应该会进到__linux__的编译选项里。

qicosmos avatar Jul 29 '18 12:07 qicosmos

mac中没有带 filesystem这个头文件 find / 也找不到

#include <any> connection.hpp:6:10: fatal error: 'any' file not found std中没有这个头文件

#include <experimental/any> any头文件 在 experimental这个试验性功能文件夹中

yyyywwwwpppp avatar Jul 29 '18 13:07 yyyywwwwpppp

你的编译器版本可能低了,或者是你没有打开c++17的编译选项的,any是c++17编译器都支持了的。

qicosmos avatar Jul 29 '18 13:07 qicosmos

Apple's LLVM and Clang from Xcode 9 are based on version 4.0 of the main LLVM/Clang. You'll need at least LLVM/Clang 5.0 for more C++17 compatibility. To be fair, modern C++ support is not a priority for Apple, their efforts are more toward Swift.

没准还真是 xcode9系列是基于 llvm/clang-4 的,,,,,不然不会这么奇怪

yyyywwwwpppp avatar Jul 29 '18 13:07 yyyywwwwpppp

https://news.ycombinator.com/item?id=16545037 4个月前的帖子

yyyywwwwpppp avatar Jul 29 '18 13:07 yyyywwwwpppp

vs2017 版本15.6.7无法编译。报错如下: default

已经启用了c++最新草案标准及实验性模块: /std:c++latest /experimental:module

tfjiang avatar Jul 31 '18 15:07 tfjiang

代码更新导致的编译错误,正在处理。

qicosmos avatar Aug 01 '18 00:08 qicosmos

@tfjiang 已经修复更新代码即可。

qicosmos avatar Aug 01 '18 01:08 qicosmos

mac osx 10.13 llvm6.0

clang++ --version
clang version 6.0.1 (tags/RELEASE_601/final)
Target: x86_64-apple-darwin17.7.0
Thread model: posix

编译通过,测试运行正常,,,真是扎心呀,老铁!!!!!!!!!!!

brew install llvm --with-toolchain --with-shared-libs   主要这两项ok

export PATH="/usr/local/opt/llvm/bin:$PATH"
export CC="/usr/local/opt/llvm/bin/clang"
export CXX="/usr/local/opt/llvm/bin/clang++"
这样`cmake ..`时用的 CC CXX 就会是你安装的新版本编译器

需要修改CMakeLists.txt 在 CMakeLists.txt 添加llvm类库搜索路径

link_directories(/usr/local/opt/llvm/lib)

在CMakeLists.txt中替换 -lstdc++fs-lc++experimental 因为llvm中没有这个动态类库(lib),,,,gcc中才带有这个类库(lib) 在cinatra中针对 mac osx 系统,使用的 uuid ,是 #include <CoreFoundation/CFUUID.h> 在项目源文件 uuid.h 所以编译时还需要链接 mac osx 平台自己framework library 在 CMakeLists.txt 中添加 "-framework CoreFoundation" 完整形式 target_link_libraries(cinatra ${Boost_LIBRARIES} uuid -lc++experimental "-framework CoreFoundation")

开始编译
mkdir clang-build && clang-build
cmake ..
make
./cinatra
打开浏览器  看到   ` hello world`

在build目录中(clang-build)/CMakeFiles/cinatra.dir 的几个 文件可以帮助找到一些问题的推断.

yyyywwwwpppp avatar Aug 01 '18 07:08 yyyywwwwpppp

mac上的llvm编译我们没环境测试,现在你测试通过了太棒了,谢谢。

qicosmos avatar Aug 01 '18 07:08 qicosmos

另外请用最新的代码,最近做了较大的更新。

qicosmos avatar Aug 01 '18 07:08 qicosmos

囧~ 嗯,代码一直用的最近的 git pull

yyyywwwwpppp avatar Aug 01 '18 08:08 yyyywwwwpppp

vs2017 update 15.8 0o td6s jcxas5gf 3ic6j

问题发生在shared_ptr.hpp: 813 image

也许是我这边的问题……?

sunhao474 avatar Aug 31 '18 06:08 sunhao474

@sunhao474 其他头文件呢 还有项目是依赖boost的

xmh0511 avatar Aug 31 '18 06:08 xmh0511

@xmh0511 抱歉没有注意是boost库内部报的错误……跟本项目应该无关,不好意思,我再看看

sunhao474 avatar Aug 31 '18 06:08 sunhao474

m_flag{ ATOMIC_FLAG_INIT }

error C2664: “std::atomic_flag::atomic_flag(const std::atomic_flag &)”: 无法将参数 1 从“initializer list”转换为“const std::atomic_flag &”

vs2019 遇到了这个问题。

shuax avatar May 22 '19 06:05 shuax

不好意思,升级到最新VS2019 16.1.0以后没错了。

shuax avatar May 22 '19 06:05 shuax

VC2017 版本15.9.41 X64

严重性 代码 说明 项目 文件 行 禁止显示状态 错误 C2664 “cinatra::simple_client::simple_client(cinatra::simple_client &&)”: 无法将参数 1 从“_Ty2”转换为“const cinatra::simple_client &” ssPixrClient c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.16.27023\include\memory 1801

查了下是这句编译不通过 auto client = cinatra::client_factory::instance().new_client();

manuel76413 avatar Dec 17 '21 01:12 manuel76413

最新代码需要C++20

qicosmos avatar Jan 14 '24 12:01 qicosmos