问题描述
我正在 Meson Build 中构建一个简单的项目.
尽管在Meson Build文档中有充分的文档如何创建依赖项(使用UNIX/LINUX的隐含假设)系统),目前尚不清楚如何链接到不在路径库中的任意对象.
I'm building a simple project in Meson Build.
While it is well documented how to create a dependency in Meson Build Documentation (With implicit assumption of UNIX / LINUX system) it is not clear how to link against arbitrary not on path library.
让我在Windows上拥有以下项目:
Let's I have the following project on Windows:
- ProjectFolder
- SrcFiles
- SrcFile1.c
- SrcFile2.c
- Lib
- MyLib1.lib
- MyLib2.lib
我想基于SrcFile1.c
和SrcFile2.c
创建一个可执行文件,该文件与预先构建的 MyLib1.lib
和MyLib2.lib
链接.
I want to create an executable based on SrcFile1.c
and SrcFile2.c
which is linked against pre built MyLib1.lib
and MyLib2.lib
.
这样做的正确方法是什么?
What is the correct way to do so?
推荐答案
好,我在MesonBuild上找到了解决方案:如何定义对库的依赖关系pkg-config
无法找到的?在 Yasushi Shoji的答案中.
OK, I found solution on MesonBuild: How to define dependency to a library that cannot be found by pkg-config
? on Yasushi Shoji's answer.
dirs
属性的唯一问题需要绝对路径.
因此,这是可以完成的工作的草图:
The only issue the dirs
property requires Absolute Path.
Hence this is a sketch of what can be done:
# Constants
projectDir = meson.current_source_dir() # MESON_SOURCE_ROOT
buildDir = meson.current_build_dir() # MESON_BUILD_ROOT
lib1Path = join_paths(projectDir, 'Lib')
lib2Path = join_paths(projectDir, 'Lib')
objCCompiler = meson.get_compiler('c')
MyLib1 = objCCompiler.find_library('MyLib1', dirs : lib1Path)
MyLib2 = objCCompiler.find_library('MyLib1', dirs : lib1Pat2)
现在只需定义具有适当依赖性的目标构建即可.
Now just to define the target build with the proper dependencies.
这篇关于在Windows上的Meson Build中链接到现有`.lib`文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!