DirectX-Headers
DirectX-Headers copied to clipboard
Cam't build tests with meson in Linux
When trying to build the tests with meson, I get a problem with d3d12 not found and the tests do NOT build. I'm sure that this is NOT a linux issue because when I build with cmake in Linux, I am able to build and run the tests. Looking at the meson scripts, I have to wonder why we are looking for "d3d12" because I thought we were supposed to create it but I might be missing something.
I'm using Archlinux with wsl2. Here's the build log from my process.
The Meson build system
Version: 1.1.1
Source dir: /home/jpmugaas/arch/directx-headers-git/src/DirectX-Headers
Build dir: /home/jpmugaas/arch/directx-headers-git/src/build
Build type: native build
Project name: DirectX-Headers
Project version: 1.610.0
C++ compiler for the host machine: c++ (gcc 13.1.1 "c++ (GCC) 13.1.1 20230429")
C++ linker for the host machine: c++ ld.bfd 2.40.0
Host machine cpu family: x86_64
Host machine cpu: x86_64
Library d3d12 found: NO
Library dxcore found: NO
Library gtest found: YES
Library gtest_main found: YES
Build targets in project: 5
DirectX-Headers 1.610.0
User defined options
auto_features: enabled
buildtype : plain
libexecdir : lib
prefix : /usr
sbindir : bin
wrap_mode : nodownload
b_lto : false
b_pie : true
build-test : true
Found ninja-1.11.1 at /usr/sbin/ninja
Core properties:
Source dir /home/jpmugaas/arch/directx-headers-git/src/DirectX-Headers
Build dir /home/jpmugaas/arch/directx-headers-git/src/build
Main project options:
Core options Current Value Possible Values Description
-------------- ------------- --------------- -----------
auto_features enabled [enabled, disabled, auto] Override value of all 'auto' features
backend ninja [ninja, vs, vs2010, vs2012, Backend to use
vs2013, vs2015, vs2017, vs2019,
vs2022, xcode, none]
buildtype plain [plain, debug, debugoptimized, Build type to use
release, minsize, custom]
cmake_prefix_path [] [] List of additional prefixes for cmake to search
debug false [true, false] Enable debug symbols and other information
default_library shared [shared, static, both] Default library type
force_fallback_for [] [] Force fallback for those subprojects
install_umask 0022 [preserve, 0000-0777] Default umask to apply on permissions of installed files
layout mirror [mirror, flat] Build directory layout
optimization plain [plain, 0, g, 1, 2, 3, s] Optimization level
pkg_config_path [] [] List of additional paths for pkg-config to search
prefer_static false [true, false] Whether to try static linking before shared linking
strip false [true, false] Strip targets on install
unity off [on, off, subprojects] Unity build
unity_size 4 >=2 Unity block size
vsenv false [true, false] Activate Visual Studio environment
warning_level 1 [0, 1, 2, 3, everything] Compiler warning level to use
werror false [true, false] Treat warnings as errors
wrap_mode nodownload [default, nofallback, Wrap mode
nodownload, forcefallback,
nopromote]
Backend options Current Value Possible Values Description
----------------- ------------- --------------- -----------
backend_max_links 0 >=0 Maximum number of linker processes to run or 0 for no limit
Base options Current Value Possible Values Description
-------------- ------------- --------------- -----------
b_asneeded true [true, false] Use -Wl,--as-needed when linking
b_colorout always [auto, always, never] Use colored output
b_coverage false [true, false] Enable coverage tracking.
b_lto false [true, false] Use link time optimization
b_lto_threads 0 Use multiple threads for Link Time Optimization
b_lundef true [true, false] Use -Wl,--no-undefined when linking
b_ndebug false [true, false, if-release] Disable asserts
b_pch true [true, false] Use precompiled headers
b_pgo off [off, generate, use] Use profile guided optimization
b_pie true [true, false] Build executables as position independent
b_sanitize none [none, address, thread, Code sanitizer to use
undefined, memory, leak,
address,undefined]
b_staticpic true [true, false] Build static libraries as position independent
Compiler options Current Value Possible Values Description
------------------ ------------- --------------- -----------
cpp_args [-march=x86-64, -mtune=generic, [] Extra arguments passed to the cpp compiler
-O2, -pipe, -fno-plt,
-fexceptions,
-Wp,-D_FORTIFY_SOURCE=2,
-Wformat, -Werror=format-
security, -fstack-clash-
protection, -fcf-protection,
-Wp,-D_GLIBCXX_ASSERTIONS]
cpp_debugstl false [true, false] STL debug mode
cpp_eh default [none, default, a, s, sc] C++ exception handling type.
cpp_link_args [-Wl,-O1,--sort-common,--as- [] Extra arguments passed to the cpp linker
needed,-z,relro,-z,now,
-march=x86-64, -mtune=generic,
-O2, -pipe, -fno-plt,
-fexceptions,
-Wp,-D_FORTIFY_SOURCE=2,
-Wformat, -Werror=format-
security, -fstack-clash-
protection, -fcf-protection,
-Wp,-D_GLIBCXX_ASSERTIONS]
cpp_rtti true [true, false] Enable RTTI
cpp_std c++14 [none, c++98, c++03, c++11, C++ language standard to use
c++14, c++17, c++1z, c++2a,
c++20, gnu++03, gnu++11,
gnu++14, gnu++17, gnu++1z,
gnu++2a, gnu++20, c++23,
gnu++23]
pkgconfig module options Current Value Possible Values Description
-------------------------- ------------- --------------- -----------
pkgconfig.relocatable false [true, false] Generate pkgconfig files as relocatable
Directories Current Value Possible Values Description
------------- ------------- --------------- -----------
bindir bin Executable directory
datadir share Data file directory
includedir include Header file directory
infodir share/info Info page directory
libdir lib Library directory
libexecdir lib Library executable directory
licensedir Licenses directory
localedir share/locale Locale data directory
localstatedir /var Localstate data directory
mandir share/man Manual page directory
prefix /usr Installation prefix
sbindir bin System executable directory
sharedstatedir /var/lib Architecture-independent data directory
sysconfdir /etc Sysconf data directory
Testing options Current Value Possible Values Description
----------------- ------------- --------------- -----------
errorlogs true [true, false] Whether to print the logs from failing tests
stdsplit true [true, false] Split stdout and stderr in test logs
Project options Current Value Possible Values Description
----------------- ------------- --------------- -----------
build-test true [true, false] Build the test
==> Starting check()...
[1/11] Compiling C++ object libDirectX-Guids.a.p/src_dxguids.cpp.o
[2/11] Linking static target libDirectX-Guids.a
[3/11] Compiling C++ object libd3dx12-format-properties.a.p/src_d3dx12_property_format_table.cpp.o
[4/11] Linking static target libd3dx12-format-properties.a
[5/11] Compiling C++ object test/DirectX-Headers-Test.p/test.cpp.o
[6/11] Linking target test/DirectX-Headers-Test
FAILED: test/DirectX-Headers-Test
c++ -o test/DirectX-Headers-Test test/DirectX-Headers-Test.p/test.cpp.o -Wl,--as-needed -Wl,--no-undefined -pie -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -Wp,-D_GLIBCXX_ASSERTIONS -Wl,--start-group libd3dx12-format-properties.a libDirectX-Guids.a -Wl,--end-group
/usr/sbin/ld: test/DirectX-Headers-Test.p/test.cpp.o: in function `main':
test.cpp:(.text.startup+0x41): undefined reference to `DXCoreCreateAdapterFactory'
/usr/sbin/ld: test.cpp:(.text.startup+0xae): undefined reference to `D3D12CreateDevice'
collect2: error: ld returned 1 exit status
[7/11] Compiling C++ object test/DirectX-Headers-Check-Feature-Support-Test.p/feature_check_test.cpp.o
[8/11] Compiling C++ object googletest/Feature-Support-Test.p/feature_support_test.cpp.o
ninja: build stopped: subcommand failed.
#110 will at least fix the build failures by causing the tests to be skipped. I forgot that this isn't the default behavior for a not-found library.
In WSL, these libraries are made available in /usr/lib/wsl/lib, which is added to LD_LIBRARY_PATH automatically (unless disabled), which allows the runtime linker to find them out-of-the-box, but the static linker can't find them without additional configuration. You can add that path to the LIBRARY_PATH environment variable (according to the comment at the top of this docs page) to get meson to actually find those libraries.
I tried #110 but that did not work when doing something like "ninja test".
==> Starting check()...
[6/11] Linking target test/DirectX-Headers-Test
FAILED: test/DirectX-Headers-Test
c++ -o test/DirectX-Headers-Test test/DirectX-Headers-Test.p/test.cpp.o -Wl,--as-needed -Wl,--no-undefined -pie -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -Wp,-D_GLIBCXX_ASSERTIONS -Wl,--start-group libd3dx12-format-properties.a libDirectX-Guids.a -Wl,--end-group
/usr/sbin/ld: test/DirectX-Headers-Test.p/test.cpp.o: in function `main':
test.cpp:(.text.startup+0x41): undefined reference to `DXCoreCreateAdapterFactory'
/usr/sbin/ld: test.cpp:(.text.startup+0xae): undefined reference to `D3D12CreateDevice'
collect2: error: ld returned 1 exit status
My impression is that it's not able to locate the static libraries, libd3dx12-format-properties.a and libDirectX-Guids.a.