xmake-io / xmake-repo

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

OpenCV与Protobuf冲突 #4413

Open jielyu opened 3 months ago

jielyu commented 3 months ago

Xmake Version

v2.9.2+HEAD.6b6557c

Operating System Version and Architecture

Ubuntu22.04

Describe Bug

同时依赖OpenCV 4.10.0 和 Protobuf 27.0的二进制目标,在链接时报错protobuf中的内容与opencv4/3rdpart/liblibprotobuf.a中定义重复。

奇怪的是 静态库和动态库都可以正常生成,只有二进制目标报错。

Expected Behavior

预期正常链接

Project Configuration

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

add_requires("gflags", "glog", "protobuf-cpp", "opencv") add_requires("grpc", {system = false})

target("my_proto") set_kind("static") set_languages("c++17") add_packages("protobuf-cpp", {public = true}) add_packages("grpc") add_rules("protobuf.cpp") add_files("protos/*.proto", {proto_public = true, proto_grpc_cpp_plugin = true})

target("test_proj") set_kind("binary") add_packages("gflags", "glog", "protobuf-cpp", "opencv") add_deps("my_proto") add_files("src/**.cpp") add_includedirs("./")

Additional Information and Error Logs

/usr/bin/ld: /home//.xmake/packages/p/protobuf-cpp/27.0/3a6ae090d364400a86d45d58d50c750c/lib/libprotobuf.a(zero_copy_stream.cc.o): in function `google::protobuf::io::ZeroCopyOutputStream::WriteAliasedRaw(void const, int)': zero_copy_stream.cc:(.text.unlikely+0x0): multiple definition of `google::protobuf::io::ZeroCopyOutputStream::WriteAliasedRaw(void const, int)'; /home//.xmake/packages/o/opencv/4.10.0/07fff2ddbc8647d392e888cc2a12d4a4/lib/opencv4/3rdparty/liblibprotobuf.a(zero_copy_stream.cc.o):zero_copy_stream.cc:(.text._ZN6google8protobuf2io20ZeroCopyOutputStream15WriteAliasedRawEPKvi+0x0): first defined here collect2: error: ld returned 1 exit status

star-hengxing commented 3 months ago

这是因为 opencv 包没有拆依赖,等我有时间来解决

Issues-translate-bot commented 3 months ago

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


This is because the opencv package has not removed its dependencies. I will solve it when I have time.

jielyu commented 3 months ago

这是因为 opencv 包没有拆依赖,等我有时间来解决

好的,感谢

Issues-translate-bot commented 3 months ago

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


This is because the opencv package has not removed its dependencies. I will solve it when I have time.

OK, thanks