xmake-io / xmake-repo

📦 An official xmake package repository
https://xrepo.xmake.io
Apache License 2.0
664 stars 390 forks source link

protobuf-cpp 无法安装结束在checking for c++ snippet(test) 这一步 #2209

Closed FreeSoaring closed 4 months ago

FreeSoaring commented 1 year ago

Xmake 版本

xmake v2.7.9+master.960b46e79

操作系统版本和架构

win 11 x64

描述问题

`protoc test.proto --cpp_out=. checking for link.exe ... C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\bin\HostX64\x64\link.exe checking for the linker (ld) ... link.exe checking for C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\bin\HostX64\x64\cl.exe ... ok checking for flags (/MT) ... ok checking for flags (cl_external_includedir) ... ok

checking for c++ links(libprotobuf) checking for c++ snippet(test) error: cl: 命令行 warning D9002 :忽略未知选项“-std:c++11” _F293F10CBF5F45A0B74118667362BDD1.cpp .\test.pb.h(13): fatal error C1189: #error: "This file was generated by a newer version of protoc which is"

=> install protobuf-cpp 3.15.8 .. failed error: install failed!`

按照报错找到头文件描述

`#if PROTOBUF_VERSION < 4022000

error "This file was generated by a newer version of protoc which is"

error "incompatible with your Protocol Buffer headers. Please update"

error "your headers."

endif // PROTOBUF_VERSION`

好像是头文件版本不兼容的问题。应该需要更新源文件

期待的结果

正确安装

工程配置

`add_rules("mode.debug", "mode.release")

set_languages("c99", "c++20")

add_cxflags("/utf-8","/openmp") add_requires("openmp") add_packages("openmp") add_requires("opencv") add_packages("opencv") add_requires("vulkansdk") add_packages("vulkansdk")

add_requires("protobuf-cpp") add_packages("protobuf-cpp")

add_includedirs("C:/tools/ncnn-lib/windows/x64/include/") add_linkdirs("C:/tools/ncnn-lib/windows/x64/lib/") add_links("ncnn") add_links("glslang")

target("ncnn-yolov8")

add_files("src/*.cpp")

`

附加信息和错误日志

No response

HaroldCC commented 10 months ago

assert(package:check_cxxsnippets({test = io.readfile("test.pb.cc")}, {configs = {includedirs = {".", package:installdir("include")}, languages = "c++11"}})) 这里写死使用C++11,我在本地删除 languages="c++11"就可以了,我之前的想法是通过 接口 add_requireconfs("protobuf-cpp", {configs={languages="c++20"}}) 在自己项目的xmake.lua中设置语言标准,但是未起作用。

Issues-translate-bot commented 10 months ago

Bot detected the issue body's language is not English, translate it automatically.


assert(package:check_cxxsnippets({test = io.readfile("test.pb.cc")}, {configs = {includedirs = {".", package:installdir("include")}, languages ​​= "c+ +11"}})) This is written in C ++11, I can delete languages="c++11" locally. My previous idea was to use the interface add_requireconfs("protobuf-cpp", {configs={languages="c++20"}}) I set the language standard in xmake.lua of my own project, but it didn't work.

c8ef commented 4 months ago

Recent protobuf-cpp change already fixed the problem.