I cannot create a simple exactable using meson build system on windows. The project I am working on uses an external library, for which I create a dependency. First of all I notices that using / as a concatenation operator for paths does not work properly (see the comments below). And secondarily, the library path is passed into the linker with slashes ‘/’ in the path, which is wrong, as the path is treated as a set of options.
I would like to use the same ‘meson.build’ file both on linux and windows, but for the moment windows version does not work as expected. Any ideas what could be wrong?
# File: meson.build
project('NegTest', ['c','cpp'] )
cpp = meson.get_compiler('cpp')
NAGDIR = get_option('NAGDIR')
message('==>> NAGDIR',NAGDIR)
# NAGDIR C:UsersTAH5905AppDataLocalnagNL28nlw32286el
message('==>> LIB-1',NAGDIR / 'lib')
# LIB-1 C:/Users/TAH5905/AppData/Local/nag/NL28/nlw32286el/lib
message('==>> LIB-2',NAGDIR+'\lib')
# LIB-2 C:UsersTAH5905AppDataLocalnagNL28nlw32286ellib
nag = declare_dependency(
include_directories : NAGDIR / 'include',
dependencies : cpp.find_library('nag_mkl_MD',dirs:NAGDIR+'\lib')
)
executable(
'a00adce',
'1/a00adce.c',
dependencies: [nag],
)
The log from meson compile -C build
Activating VS 17.9.7
INFO: automatically activated MSVC compiler environment
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: "C:Program FilesMicrosoft Visual Studio2022EnterpriseCommon7IDECommonExtensionsMicrosoftCMakeNinjaninja.EXE" -C C:/Users/TAH5905/Projects/NAG/NagTest-meson/build
ninja: Entering directory `C:/Users/TAH5905/Projects/NAG/NagTest-meson/build'
[2/2] Linking target a00adce.exe
FAILED: a00adce.exe a00adce.pdb
"link" /MACHINE:x64 /OUT:a00adce.exe a00adce.exe.p/1_a00adce.c.obj "/release" "/nologo" "/DEBUG" "/PDB:a00adce.pdb" "C:/Users/TAH5905/AppData/Local/nag/NL28/nlw32286el/lib/nag_mkl_MD.lib" "/SUBSYSTEM:CONSOLE" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "comdlg32.lib" "advapi32.lib"
1_a00adce.c.obj : error LNK2019: unresolved external symbol a00adc referenced in function main
1_a00adce.c.obj : error LNK2019: unresolved external symbol x04bdc referenced in function main
1_a00adce.c.obj : error LNK2019: unresolved external symbol x04bjc referenced in function main
C:UsersTAH5905AppDataLocalnagNL28nlw32286ellibnag_mkl_MD.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
a00adce.exe : fatal error LNK1120: 3 unresolved externals
ninja: build stopped: subcommand failed.
Windows 11 Enterprise; Python 3.12.0; meson 1.4.0