Skip to content

Unable to use cppgraphqlgen #170

Description

@kriegljan

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(VERSION3.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)
# learnschemaset(LEARN_SCHEMA_PATHS "")
file(STRINGS${CMAKE_CURRENT_SOURCE_DIR}/generated/learn_schema_filesLEARN_SCHEMA_FILES)
foreach(CPP_FILE INLISTS LEARN_SCHEMA_FILES)
list(APPEND LEARN_SCHEMA_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/generated/${CPP_FILE}")
endforeach(CPP_FILE)
add_library(learnschemaSTATIC${LEARN_SCHEMA_PATHS})
# target_link_libraries(learnschema PUBLIC graphqlintrospection) # build failstarget_link_libraries(learnschemaPUBLICgraphqlintrospectiongraphqljsongraphqlresponsegraphqlservicegraphqlpeggraphqlclientpthreadstdc++fs)
target_include_directories(learnschemaPUBLIC# ${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_warsadd_library(star_warsSTATICsrc/DroidData.cppsrc/HumanData.cppsrc/QueryData.cppsrc/ReviewData.cppsrc/MutationData.cppsrc/StarWarsData.cpp)
target_link_libraries(star_warsPUBLIClearnschema)
target_include_directories(star_warsPUBLICstar_wars)
# learn_star_warsadd_executable(learn_star_warssrc/sample.cpp)
target_link_libraries(learn_star_warsPRIVATEstar_warsgraphqljson)
target_include_directories(learn_star_warsPRIVATE# ${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

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions