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

Cannot build the chatroom example (the headers are not installed in one place) #484

Open
ybesh opened this issue Mar 4, 2022 · 0 comments

Comments

@ybesh
Copy link

ybesh commented Mar 4, 2022

Hello,
I tried to build the chatroom example in C++ on M1 MacOS and got into a problem with resolving include paths.

How I built fbthrift

Following the top-level README, I built fbthrift with a custom --scratch-path.

./build/fbcode_builder/getdeps.py install-system-deps --recursive fbthrift
./build/fbcode_builder/getdeps.py --allow-system-packages build --scratch-path=/my/custom/path

What I tried to build

I created CMakeLists.txt based off the one in the repo (some changes made to fix minor errors which probably should be discussed in a separate issue), and still it won't build because of unresolved include paths.

# Changes I made are marked with <<<.

include(ThriftLibrary.cmake) # <<< ThriftLibrary.cmake copied to the same dir

set(EXAMPLE_IF_HOME ${CMAKE_CURRENT_SOURCE_DIR}) 

# Example to test linking
thrift_library(
  "chatroom" #file_name
  "ChatRoomService;Echo" #services
  "cpp2" #language
  "" #options
  "${EXAMPLE_IF_HOME}" #file_path
  "${CMAKE_CURRENT_BINARY_DIR}" #output_path # <<<
  ".." #include_prefix # <<<
)

Invoking cmake with the above file, I got an error complaining:

In file included from /path/to/fbthrift/thrift/example/build/if/gen-cpp2/chatroom_data.cpp:8:
/path/to/fbthrift/thrift/example/build/if/gen-cpp2/../gen-cpp2/chatroom_data.h:9:10: fatal error: 'thrift/lib/cpp2/gen/module_data_h.h' file not found
#include <thrift/lib/cpp2/gen/module_data_h.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [if/CMakeFiles/chatroom-cpp2-obj.dir/gen-cpp2/chatroom_data.o] Error 1
make[1]: *** [if/CMakeFiles/chatroom-cpp2-obj.dir/all] Error 2
make: *** [all] Error 2

This could be resolved by adding lines of include_directories(), but this is a significant amount of manual work (which I have not tried), because the include/ directories in /my/custom/path/installed/ are installed like:

installed/fbthrift/include/
installed/folly/include/
installed/another_dep/include/
...

rather than

installed/include/fbthrift/
installed/include/folly/
installed/include/another_dep/
...

which I was expecting (in which case only one include_directories() is needed).

Have I done anything wrong in the build process?

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

No branches or pull requests

1 participant