gpt4 book ai didi

c++ - 使用针对 CPP 应用程序的 BUCK 构建链接 X11

转载 作者:行者123 更新时间:2023-11-30 04:50:11 32 4
gpt4 key购买 nike

我在尝试使用 buck 编译依赖于 X11 的 CPP 应用程序时遇到问题,因为它似乎没有链接 X11 Lib 并导致 undefined reference 错误:

 undefined reference to `XOpenDisplay'
collect2: error: ld returned 1 exit status

在研究错误后,我尝试修改 BUCK 文件 以提供正确的标志并尝试了几种不同的格式:

  platform_linker_flags = [
# ('^linux.*', ['-lX11','-L/usr/X11/lib','-I/opt/X11/include'])
('^linux.*', []),
('^linux.*', ['-lX11']),
('^linux.*', ['-L/usr/X11/lib']),
],

如您在上面看到的那样,我尝试更改结构等以查看它是否在链接过程中有所不同,但它仍然没有解决 XOpenDisplay 所需的依赖关系。

任何人都可以解释或引用将系统库应用于降压项目的正确方法,或暗示此构建中可能出现的问题。

最佳答案

尝试为系统库创建一个“虚拟”目标:

prebuilt_cxx_library(
name = 'x11',
header_only = True,
exported_platform_linker_flags = [
('linux.*', [ '-lX11' ]),
],
)

cxx_library(
name = 'foo',
srcs = glob([
'**/*.cpp',
]),
deps = [
':x11',
],
)

这是 Buckaroo 使用的方法

这里有一些讨论:https://github.com/facebook/buck/issues/1443

关于c++ - 使用针对 CPP 应用程序的 BUCK 构建链接 X11,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55089870/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com