Issue linking test to static library #10054
-
Hey everyone, New to Meson, running into something that seems like it should be obvious but isn't. Trying to compile a very simple base64 encoder/decoder: Top level meson.build:
src/ level meson.build:
test/ level meson.build:
Ninja builds the library just fine, but the test executable fails to find the #include <base64/base64.h> header. I've tried: Passing the executable the same include_directories() object that I used when compiling the library, install: true when making the library, passing the header as a source to the executable, and a few other things I can't remember because I've been looking at this for too long. The test file is just a simple main.cpp with a main() function, no gtest or anything else. It seems like I'm missing something something. What is it? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Since you mention
And base64.cpp is doing But the test program includes the public interface, which is I think you need Consider adding a declare_dependency() for your library. You may also need a declare_dependency if you intend to use libbase64 as a subproject within another project. |
Beta Was this translation helpful? Give feedback.
Since you mention
inc = include_directories('base64')
in the src/ directory, I assume your layout looks like this:And base64.cpp is doing
#include "base64.h"
and the static library compiles okay.But the test program includes the public interface, which is
<base64/base64.h>
, which means the include directory you need to add is different from the internal one.I think you need
public_inc = include_directories('.')
as well.Consider adding a declare_dependency() for your library.
libbase64_dep
would link to libbase…