How do I specify a directory to a library for compilation and execution in C++ with Meson?

80 Views Asked by At

My C++ project uses SDL2 and I am using Meson to make my project. Meson does not seem to recognize that I want to specify the path to the SDL2 library.

Here is what I have so far:

project('Default','cpp')

SDL2_dir = 'SDL2' 
SDL2_Ldir = '/Library/SoftwareDevelopment/cpp/lib' 
SDL2_Idir = '/Library/SoftwareDevelopment/cpp/include'

deps = [declare_dependency(link_args:['-L'+SDL2_Ldir,'-l'+SDL2_dir],include_directories:include_directories(SDL2_Idir))]

executable('Executable', 'main.cpp', build_rpath:SDL2_Ldir, install_rpath:'@executable_path/../libs', dependencies:deps)

I am using build_rpath to specify the library path when the executable is being built, and I am using install_rpath to specify the library path that the executable will search through.

When I run meson compile, it fails with a warning:

warning: ignoring file '/usr/local/lib/libSDL2-2.0.0.dylib': found architecture 'arm64', required architecture 'x86_64'

This warning states that Meson is looking through '/usr/local/lib/' instead of '/Library/SoftwareDevelopment/cpp/lib', seemingly ignoring build_rpath.

edit: A simple thing that compiles fine but does not execute without an error:

project('Default','cpp')
SDL2_Ldir = '/Library/SoftwareDevelopment/cpp/lib'
executable('Executable', 'main.cpp', link_args:[SDL2_Ldir+'/libSDL2-x64.dylib'], build_rpath:SDL2_Ldir, install_rpath:'@executable_path/../libs')

The error from the executable simply states that it cannot find a proper SDL2 library to work with. It will search everywhere except for the install_rpath that I specify.

0

There are 0 best solutions below