Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed to build example #1223

Closed
Crazyokd opened this issue Aug 2, 2024 · 4 comments
Closed

failed to build example #1223

Crazyokd opened this issue Aug 2, 2024 · 4 comments
Labels

Comments

@Crazyokd
Copy link

Crazyokd commented Aug 2, 2024

I use meson and setup with below option:

meson setup build \
    -DPISTACHE_USE_RAPIDJSON=true   \
    -DPISTACHE_BUILD_EXAMPLES=true  \
    -DPISTACHE_BUILD_DOCS=true          \
    -DPISTACHE_USE_CONTENT_ENCODING_DEFLATE=true  \
    --prefix=`pwd`/install

but after I execute meson compile -C build. I got:

[20/42] Compiling C++ object examples/runrest_description.p/rest_description.cc.o
FAILED: examples/runrest_description.p/rest_description.cc.o 
c++ -Iexamples/runrest_description.p -Iexamples -I../examples -Iinclude -I../include -fdiagnostics-color=always -DNDEBUG -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Wpedantic -std=c++17 -O3 -Wconversion -Wno-sign-conversion -Wno-missing-field-initializers -pthread -DPISTACHE_USE_CONTENT_ENCODING_DEFLATE -MD -MQ examples/runrest_description.p/rest_description.cc.o -MF examples/runrest_description.p/rest_description.cc.o.d -o examples/runrest_description.p/rest_description.cc.o -c ../examples/rest_description.cc
In file included from ../examples/rest_description.cc:17:
../include/pistache/serializer/rapidjson.h:15:10: fatal error: rapidjson/prettywriter.h: No such file or directory
   15 | #include <rapidjson/prettywriter.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
[33/42] Compiling C++ object src/libpistache.so.0.3.1.p/server_router.cc.o
ninja: build stopped: subcommand failed.

From compile command, I can't find corresponding -I option. but I checked meson configure and do not find any problem.

@kiplingw
Copy link
Member

kiplingw commented Aug 2, 2024

@Crazyokd, you're missing the headers for rapidjson.

$ sudo apt install rapidjson-dev

@Crazyokd
Copy link
Author

Crazyokd commented Aug 3, 2024

But isn't rapidjson in subprojects?

in subprojects/rapidjson-1.1.0/meson.build, we have

rapidjson_inc = include_directories('include')
rapidjson_dep = declare_dependency(include_directories: rapidjson_inc)

in meson.build, we add it to deps_libpistache.

if get_option('PISTACHE_USE_RAPIDJSON')
	deps_libpistache += dependency('RapidJSON', fallback: ['rapidjson', 'rapidjson_dep'])
endif

int src/meson.build, we add it to pistache_dep.

libpistache = library(
	'pistache',
	sources: pistache_common_src + pistache_server_src + pistache_client_src,
	cpp_args: public_args,
	include_directories: incl_pistache,
	dependencies: deps_libpistache,
	install: get_option('PISTACHE_INSTALL'),
	version: version_str,
	pic: get_option('b_staticpic')
)

pistache_dep = declare_dependency(
	compile_args: public_args,
	include_directories: incl_pistache,
	link_with: libpistache
)

in examples/meson.build, we use pistache_dep.

foreach example_name : pistache_example_files
	executable('run'+example_name, example_name+'.cc', dependencies: [pistache_dep, threads_dep])
endforeach

@Crazyokd
Copy link
Author

Crazyokd commented Aug 3, 2024

And if I use rapidjson_dep in examples/meson directly. like below:

foreach example_name : pistache_example_files
	executable('run'+example_name, example_name+'.cc', dependencies: [pistache_dep, threads_dep, dependency('RapidJSON', fallback: ['rapidjson', 'rapidjson_dep'])])
endforeach

I can compile it!

@Crazyokd
Copy link
Author

Crazyokd commented Aug 3, 2024

I guess the libpistache do not really use rapidjson. so in libpistache the corresponding information was lost(optimized?).
We can fix it by adding dependency in examples/meson.build directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants