gpt4 book ai didi

c++ - 使用 gcc 是否可以链接库,但前提是它存在?

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

我们有一些困惑的 makefile 系统,我们将对其进行修复。但与此同时,我需要添加一个解决方法,如果您可以要求编译器(或链接器)链接一个库,我正在徘徊,但前提是它存在。我知道如何修复 makefile,但这需要一些时间,同时我想快速破解...

所以我有这样的东西:

gcc <...other options...> -L ./some/path -l somelibrary

libsomelibrary.so不存在这会产生错误。我希望它在这种情况下继续而不链接。那可能吗? - 一些链接器选项?

最佳答案

可以替换

gcc <...other options...> -L ./some/path -l somelibrary

在生成文件中

gcc <...other options...> -L ./some/path -l somelibrary || gcc <...other options...> -Wl,--unresolved-symbols=ignore-in-object-files

作为旁注,而不是 -L ./some/path -l somelibrary你可以简单地做 ./some/path/libsomelibrary.so .

关于c++ - 使用 gcc 是否可以链接库,但前提是它存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53085524/

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