user28898939
user28898939

Reputation: 1

Struggling with "pkg-config not found" errors using Meson when trying to use the SFML library (Windows)

I'm trying to run Meson with SFML as a dependency and I keep getting the message "Did not find pkg-config by name 'pkg-config'" and the error "Dependency lookup for openal with method 'pkgconfig' failed: Pkg-config for machine host machine not found. Giving up."

My meson.build code:

project('meson_test', 'cpp',
        version : '1.0.0',
        default_options : ['warning_level=3', 'cpp_std=c++17'])

pkg_config_path = 'C:\Program Files\pkg-config'
sfml_dep = dependency('sfml', 'pkg-config')
imgui_dep = dependency('imgui-sfml')
pkg = import('pkgconfig')
lib = library('sfml', dependencies : [sfml])
pkg.generate(lib)

executable('meson_test', 'main.cpp',
           install : true,
           win_subsystem : 'windows',
           dependencies : [sfml_dep, imgui_dep])

The full response:

The Meson build system
Version: 1.6.1
Source dir: C:\Users\username\CLionProjects\meson_test
Build dir: C:\Users\username\CLionProjects\meson_test\buildDir
Build type: native build
Project name: meson_test
Project version: 1.0.0
C++ compiler for the host machine: c++ (gcc 6.3.0 "c++ (MinGW.org GCC-6.3.0-1) 6.3.0")
C++ linker for the host machine: c++ ld.bfd 2.28
Host machine cpu family: x86
Host machine cpu: x86
Did not find pkg-config by name 'pkg-config'
Found pkg-config: NO
Found CMake: C:\Program Files\CMake\bin\cmake.EXE (3.30.0)
Run-time dependency sfml found: NO (tried pkgconfig and cmake)
Run-time dependency pkg-config found: NO (tried pkgconfig and cmake)
Looking for a fallback subproject for the dependency sfml

Executing subproject sfml

sfml| Project name: sfml
sfml| Project version: 2.6.2
sfml| C++ compiler for the host machine: c++ (gcc 6.3.0 "c++ (MinGW.org GCC-6.3.0-1) 6.3.0")
sfml| C++ linker for the host machine: c++ ld.bfd 2.28
sfml| Run-time dependency openal found: NO (tried cmake)

subprojects\SFML-2.6.2\meson.build:14:13: ERROR: Dependency lookup for openal with method 'pkgconfig' failed: Pkg-config for machine host machine not found. Giving up.

(Also if it's relevant, I'm using MinGW as my compiler and my IDE is CLion).

I've tried various ways of downloading pkg-config to my Windows machine, I've added pkg-config to PATH and even made a specific env variable called "pkg-config" that links to it, and I still can't get Meson to find it. I can't find any fixes for this problem or anyone else with this exact issue. Honestly considering just switching back to CMAKE at this point, figuring this out in Meson doesn't seem worth the trouble since I'm not having the same issues using SFML with CMAKE. I want to try to make it work in Meson though so if anyone has any insight, I would greatly appreciate the help.

Also tried this alternate solution:

project('meson_test', 'cpp',
        version : '1.0.0',
        default_options : ['warning_level=3', 'cpp_std=c++17'])

cpp = meson.get_compiler('cpp')
sfml_lib = cpp.find_library('sfml')
pkg_config_path = 'C:\Program Files\pkg-config'
sfml_dep = dependency('sfml', 'pkg-config')
imgui_dep = dependency('imgui-sfml')
pkg = import('pkgconfig')
lib = library('sfml', dependencies : [sfml])
pkg.generate(lib)

executable('meson_test', 'main.cpp',
           install : true,
           win_subsystem : 'windows',
           link_with: sfml_lib,
           include_directories : 'C:\Program Files',
           dependencies : [sfml_dep, imgui_dep])

Response (different error but still doesn't work):

The Meson build system
Version: 1.6.1
Source dir: C:\Users\username\CLionProjects\meson_test
Build dir: C:\Users\username\CLionProjects\meson_test\buildDir
Build type: native build
Project name: meson_test
Project version: 1.0.0
C++ compiler for the host machine: c++ (gcc 6.3.0 "c++ (MinGW.org GCC-6.3.0-1) 6.3.0")
C++ linker for the host machine: c++ ld.bfd 2.28
Host machine cpu family: x86
Host machine cpu: x86

meson.build:6:15: ERROR: C++ prefer_static library 'sfml' not found

(Also I'm still relatively new to CS so if possible try to dumb things down a bit for me please because I might not immediately know what you're referencing).

Upvotes: 0

Views: 138

Answers (0)

Related Questions