Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持 link 完整路径的库文件 #3889

Closed
ivanallen opened this issue Jun 26, 2023 · 19 comments
Closed

支持 link 完整路径的库文件 #3889

ivanallen opened this issue Jun 26, 2023 · 19 comments

Comments

@ivanallen
Copy link

你在什么场景下需要该功能?

当系统中存在相同的库时,使用 -L -l 方式可能产生 link 错误。

例如下面的 lflags 会导致 link 错误,本意是想 link /usr/lib64/librdmacm.a /path/to/fmt/lib/libfmt.a,但是实际会导致 link 成 /usr/lib64/libfmt.a

-L/usr/lib64 -L/path/to/fmt/lib -lrdmacm -lfmt

描述可能的解决方案

如果 xmake link 的时候,直接指定 /path/to/fmt/lib/libfmt.a 就不会有这个问题。

描述你认为的候选方案

No response

其他信息

No response

@Issues-translate-bot
Copy link

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


Title: Support library files with link full path

In what scenario do you need this function?

When the same library exists in the system, using the -L -l method may cause link errors.

For example, the following lflags will cause a link error. The original intention is to link /usr/lib64/librdmacm.a /path/to/fmt/lib/libfmt.a, but it will actually cause the link to /usr/lib64/libfmt.a

-L/usr/lib64 -L/path/to/fmt/lib -lrdmacm -lfmt

describe possible solutions

If you directly specify /path/to/fmt/lib/libfmt.a during xmake link, there will be no such problem.

Describe what you think is a candidate

No response

other information

No response

@waruqi
Copy link
Member

waruqi commented Jun 26, 2023

自己走 add_ldflags 就行了

@Issues-translate-bot
Copy link

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


Just go add_ldflags by yourself

waruqi added a commit that referenced this issue Jun 29, 2023
waruqi added a commit that referenced this issue Jun 29, 2023
support lib path for add_links #3889
@waruqi
Copy link
Member

waruqi commented Jun 29, 2023

可以了,xmake update -s dev

@waruqi waruqi closed this as completed Jun 29, 2023
@waruqi waruqi added this to the v2.8.1 milestone Jun 29, 2023
@Issues-translate-bot
Copy link

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


OK, xmake update -s dev

@ivanallen
Copy link
Author

在我的环境上看起来没有生效

image

xmake update -s dev
xmake clean -a
xmake f -cv
xmake -v

@waruqi
Copy link
Member

waruqi commented Jun 29, 2023

target("test")
    set_kind("binary")
    add_files("src/*.cpp")
    add_links("/usr/local/libtest.a")
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -o
 build/macosx/x86_64/release/test build/.objs/test/macosx/x86_64/release/src/main.cpp.o -target x
86_64-apple-macos12.6 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platf
orm/Developer/SDKs/MacOSX13.0.sdk -stdlib=libc++ -Wl,-x -Wl,-dead_strip /usr/local/libtest.a -lz

不是有的么

@ivanallen
Copy link
Author

ivanallen commented Jun 29, 2023

target("test")
    set_kind("binary")
    add_files("src/*.cpp")
    add_links("/usr/local/libtest.a")
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -o
 build/macosx/x86_64/release/test build/.objs/test/macosx/x86_64/release/src/main.cpp.o -target x
86_64-apple-macos12.6 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platf
orm/Developer/SDKs/MacOSX13.0.sdk -stdlib=libc++ -Wl,-x -Wl,-dead_strip /usr/local/libtest.a -lz

不是有的么

你是显式的 add_links 的呀。其实我是想自动 add_deps add_packages 的库,也能 link 全路径

@Issues-translate-bot
Copy link

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


target("test")
set_kind("binary")
add_files("src/*.cpp")
add_links("/usr/local/libtest.a")
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -o
build/macosx/x86_64/release/test build/.objs/test/macosx/x86_64/release/src/main.cpp.o -target x
86_64-apple-macos12.6-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platf
orm/Developer/SDKs/MacOSX13.0.sdk -stdlib=libc++ -Wl,-x -Wl,-dead_strip /usr/local/libtest.a -lz

isn't there?

You explicitly add_links the way. In fact, I want to automatically add_deps library, and also link the full path

@ivanallen
Copy link
Author

这个需求是我 add_packages 了第三方的库,可能非常多的库,我没有办法一个一个手动去 link 全路径,因为实在是太多了。。。

@Issues-translate-bot
Copy link

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


This requirement is that I add_packages third-party libraries, there may be a lot of libraries, I can't manually link the full path one by one, because there are too many. . .

@ivanallen
Copy link
Author

然后每个人的机器环境可能都不一样,有的人在本地安装了系统库,就导致各种问题

@Issues-translate-bot
Copy link

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


Then everyone's machine environment may be different. Some people have installed the system library locally, which leads to various problems.

@waruqi
Copy link
Member

waruqi commented Jun 29, 2023

target("test")
    set_kind("binary")
    add_files("src/*.cpp")
    add_links("/usr/local/libtest.a")
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -o
 build/macosx/x86_64/release/test build/.objs/test/macosx/x86_64/release/src/main.cpp.o -target x
86_64-apple-macos12.6 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platf
orm/Developer/SDKs/MacOSX13.0.sdk -stdlib=libc++ -Wl,-x -Wl,-dead_strip /usr/local/libtest.a -lz

不是有的么

你是显式的 add_links 的呀。其实我是想自动 add_deps add_packages 的库,也能 link 全路径

这个不考虑

@Issues-translate-bot
Copy link

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


target("test")
set_kind("binary")
add_files("src/*.cpp")
add_links("/usr/local/libtest.a")
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -o
build/macosx/x86_64/release/test build/.objs/test/macosx/x86_64/release/src/main.cpp.o -target x
86_64-apple-macos12.6-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platf
orm/Developer/SDKs/MacOSX13.0.sdk -stdlib=libc++ -Wl,-x -Wl,-dead_strip /usr/local/libtest.a -lz

Isn't there?

You did add_links explicitly. In fact, I want to automatically add_deps add_packages library, and also link the full path

This is not considered

@ivanallen
Copy link
Author

target("test")
    set_kind("binary")
    add_files("src/*.cpp")
    add_links("/usr/local/libtest.a")
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -o
 build/macosx/x86_64/release/test build/.objs/test/macosx/x86_64/release/src/main.cpp.o -target x
86_64-apple-macos12.6 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platf
orm/Developer/SDKs/MacOSX13.0.sdk -stdlib=libc++ -Wl,-x -Wl,-dead_strip /usr/local/libtest.a -lz

不是有的么

你是显式的 add_links 的呀。其实我是想自动 add_deps add_packages 的库,也能 link 全路径

这个不考虑

为什么呢,我看 cmake 也都是 link 全路径的,这种方式,能避免依赖冲突的问题。-L -l 这种在大型项目中非常不好用

@Issues-translate-bot
Copy link

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


target("test")
set_kind("binary")
add_files("src/*.cpp")
add_links("/usr/local/libtest.a")
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -o
build/macosx/x86_64/release/test build/.objs/test/macosx/x86_64/release/src/main.cpp.o -target x
86_64-apple-macos12.6-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platf
orm/Developer/SDKs/MacOSX13.0.sdk -stdlib=libc++ -Wl,-x -Wl,-dead_strip /usr/local/libtest.a -lz

Isn't there?

You explicitly add_links. In fact, I want to automatically add_deps add_packages library, and also link the full path

this does not take into account

Why, I think that cmake is also the full link path, this way can avoid the problem of dependency conflicts. -L -l This is very difficult to use in large projects

@ivanallen
Copy link
Author

如果开发的话难度大不大,我可以自己尝试一下

@Issues-translate-bot
Copy link

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


If it is not too difficult to develop, I can try it myself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants