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.
Let's I have the following project on Windows:
- ProjectFolder
- SrcFiles
- SrcFile1.c
- SrcFile2.c
- Lib
- 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?
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.
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.
来源:https://stackoverflow.com/questions/55779249/link-against-existing-lib-file-in-meson-build-on-windows