Link Against Existing `.lib` File in Meson Build on Windows

☆樱花仙子☆ 提交于 2019-12-08 07:51:57

问题


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?


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!