-
Notifications
You must be signed in to change notification settings - Fork 48
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
I try to use the cppgrahqlgen library in my own project. Therefore, I created the project in a new directory using (for a starting point) the files from the star wars sample.
generated/
DroidObject.cpp
DroidObject.h
HumanObject.cpp
HumanObject.h
learn_schema_files
MutationObject.h
MutationObject.cpp
QueryObject.h
QueryObject.cpp
ReviewObject.h
ReviewObject.cpp
StarWarsObjects.h
StarWarsSchema.h
StarWarsSchema.cpp
src/
DroidData.cpp
DroidData.h
HeroData.h
HumanData.cpp
HumanData.h
MutationData.cpp
MutationData.h
QueryData.cpp
QueryData.h
ReviewData.cpp
ReviewData.h
sample.cpp
StarWarsData.cpp
StarWarsData.h
CMakelists.txt (see below)
I tried to adapt the CMakelists.txt
from the samples, but I had to use link_directories
to link to graphqlintrospection
lib and so on.
cmake_minimum_required(VERSION 3.8.2)
project(graphql_example)
set (CMAKE_CXX_STANDARD 17)
include_directories(/home/jsk/third_party_libs/vcpkg/installed/x64-linux/include)
link_directories(/home/jsk/third_party_libs/vcpkg/installed/x64-linux/lib)
# learnschema
set(LEARN_SCHEMA_PATHS "")
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/generated/learn_schema_files LEARN_SCHEMA_FILES)
foreach(CPP_FILE IN LISTS LEARN_SCHEMA_FILES)
list(APPEND LEARN_SCHEMA_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/generated/${CPP_FILE}")
endforeach(CPP_FILE)
add_library(learnschema STATIC ${LEARN_SCHEMA_PATHS})
# target_link_libraries(learnschema PUBLIC graphqlintrospection) # build fails
target_link_libraries(learnschema PUBLIC graphqlintrospection graphqljson graphqlresponse graphqlservice graphqlpeg graphqlclient pthread stdc++fs)
target_include_directories(learnschema PUBLIC
# ${CMAKE_CURRENT_SOURCE_DIR}/../include
# ${CMAKE_CURRENT_SOURCE_DIR}/../PEGTL/include
/home/jsk/third_party_libs/cppgraphqlgen/PEGTL/include
${CMAKE_CURRENT_SOURCE_DIR}/generated)
# star_wars
add_library(star_wars STATIC
src/DroidData.cpp
src/HumanData.cpp
src/QueryData.cpp
src/ReviewData.cpp
src/MutationData.cpp
src/StarWarsData.cpp)
target_link_libraries(star_wars PUBLIC learnschema)
target_include_directories(star_wars PUBLIC star_wars)
# learn_star_wars
add_executable(learn_star_wars src/sample.cpp)
target_link_libraries(learn_star_wars PRIVATE
star_wars
graphqljson)
target_include_directories(learn_star_wars PRIVATE
# ${CMAKE_CURRENT_SOURCE_DIR}/../include
/home/jsk/third_party_libs/vcpkg/installed/x64-linux/include
# ${CMAKE_CURRENT_SOURCE_DIR}/../PEGTL/include
/home/jsk/third_party_libs/cppgraphqlgen/PEGTL/include
)
I installed cppgraphqlgen using vcpgk in /home/jsk/third_party_libs/vcpkg. I also have the source in /home/danneboom/third_party_libs/cppgraphqlgen.
The commands I use to build the project:
cd build
cmake .. -DCMAKE_C_COMPILER=gcc-9 -DCMAKE_CXX_COMPILER=g++-9
cmake --build .
This way I am able to build. But something is wrong, since when I execute learn_star_wars
, I get a segmentation fault:
Starting program: /home/jsk/graphql_example/build/learn_star_wars
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
0x000055555565f54e in graphql::schema::Field::Make(std::basic_string_view<char, std::char_traits<char> >, std::basic_string_view<char, std::char_traits<char> >, std::optional<std::basic_string_view<char, std::char_traits<char> > >, std::weak_ptr<graphql::schema::BaseType const>, std::vector<std::shared_ptr<graphql::schema::InputValue const>, std::allocator<std::shared_ptr<graphql::schema::InputValue const> > >&&) ()
What is the correct way to use cppgraphqlgen
in a custom project?
I'm running Ubuntu 18.4 using GNU 9.4.0 and cmake 3.10.2
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested