Currently I have the following project structure, where the libs
directory purpose is to store external C libraries that I download from github because they are not available on my OS's repos:
├── cli
│ └── cli.c
├── libs
│ ├── meson.build
│ └── pqueue
│ ├── pqueue.c
│ └── pqueue.h
├── modules
│ ├── algorithms
│ │ ├── a_star.c
│ │ └── a_star.h
│ ├── meson.build
├── meson.build
Where libs/meson.build
is:
libpqueue_sources = [
'pqueue/pqueue.c',
]
pqueue_lib = shared_library('pqueue', libpqueue_sources)
pqueue_dep = declare_dependency(link_with: pqueue_lib)
modules/meson.build
is:
algs_sources = [
'algorithms/a_star.c',
]
algs_lib = static_library('algorithms',
sources: algs_sources,
include_directories: libs_include_dirs,
dependencies: pqueue_dep)
and meson.build
is:
project('graph-search', 'c')
graph_search_include_dirs = include_directories('modules')
libs_include_dirs = include_directories('libs')
subdir('libs')
subdir('modules')
cli_sources = [
'cli/cli.c'
]
executable('cli',
sources: cli_sources,
include_directories : graph_search_include_dirs,
link_with: [algs_lib])
My problem arises when I try to make an #include "pqueue/pqueue.h"
inside a_star.h
, it says /modules/algorithms/a_star.h:5:10: fatal error: pqueue/pqueue.h: No such file or directory
, but when I move the include to a_star.c
the error disappears. Sadly I need to include it on the header file because I need to export a struct that uses a type of pqueue.h
Is there a way to include pqueue.h inside a_star.h without using paths like ../../libs/pqueue/pqueue.h
?