-
Notifications
You must be signed in to change notification settings - Fork 17
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
c++ usage as a library #485
Comments
Thanks for your interest! You can use |
If you run into any issues with my suggestion, could you please post your |
Dear @hmusta, thank you very much for the reply. Unfortunately I got an error: Here is my CMakeLists.txt using ExternalProject_Add command:
Thanks for the help again, |
Additional point: seems like my configuration is missing the external libraries that are provided by metagraph. My setup in general might be faulty. |
Hi @feeka! It seems that you're missing installation of sdsl-lite step, which is currently not implemented in metagraph's CMakeLists.txt and should be done separately. Please let us know if this helps. |
Hello @adamant-pwn , yes I have already executed this step as well. But, I think it is not only this(sdsl) library that causes trouble but other libraries as well. I checked it by exchanging the lines with |
I tried reproducing it on my side. Here's what I did: mkdir external_test
cd external_test
mkdir src
nano src/main.cpp # just write int main() {} there
nano CMakeLists.txt # Use your CMakeLists.txt
mkdir build
cmake ..
make -j This resulted into /usr/bin/ld: cannot find -lsdsl: No such file or directory
collect2: error: ld returned 1 exit status After that, I did cd metagraph-src
pushd metagraph/external-libraries/sdsl-lite
./install.sh $PWD
popd
cd ..
make -j This resulted into [100%] Linking CXX executable MyExecutable
/usr/bin/ld: cannot find -lmetagraph-core: No such file or directory Which is because you didn't specify link path in CMakeLists.txt. I've added Could you try following the same steps? You may want to integrate sdsl-lite installation in your CMakeLists.txt though, if you want to later ship this as a standalone software. If you still experience some difficulties, please provide some more context on what you're doing exactly and what kind of errors you get. |
UPD: Okay, I managed to reproduce your error by adding |
I will look into what's the proper way to handle it, for now maybe you can try adding things from metagraph/metagraph/CMakeLists.txt Lines 260 to 273 in 82f35fc
ExternalProject_Add , I will update with further details when I figure it out.
|
@hmusta is it really the intended way to install headers? metagraph/metagraph/CMakeLists.txt Lines 496 to 504 in 82f35fc
I feel like a proper way would be to do something like install(DIRECTORY ${CMAKE_SOURCE_DIR}/src/
DESTINATION include
FILES_MATCHING PATTERN "*.hpp") And maybe also do the same with the stuff in external-libraries? So that the header directory structure (and also headers that are more than 3 levels deep) is not lost and one can use |
@adamant-pwn thank you very much for the suggestions. I am going to try it and report it as well. |
@feeka you can try using #489 with the following CMakeLists.txt: cmake_minimum_required(VERSION 3.19)
project(MyExecutable)
include(ExternalProject)
ExternalProject_Add(metagraph
GIT_REPOSITORY https://github.com/ratschlab/metagraph.git
GIT_TAG include_dirs
SOURCE_DIR "${CMAKE_BINARY_DIR}/metagraph-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/metagraph-build"
CONFIGURE_COMMAND
${CMAKE_COMMAND} -G ${CMAKE_GENERATOR} <SOURCE_DIR>/metagraph
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/metagraph-install
COMMAND ${CMAKE_COMMAND} -E chdir <SOURCE_DIR>/metagraph/external-libraries/sdsl-lite bash ./install.sh .
STEP_TARGETS build
)
add_executable(MyExecutable src/main.cpp)
add_dependencies(MyExecutable metagraph)
target_include_directories(MyExecutable PRIVATE "${CMAKE_BINARY_DIR}/metagraph-install/include")
target_link_directories(MyExecutable PRIVATE "${CMAKE_BINARY_DIR}/metagraph-install/lib")
target_link_libraries(MyExecutable PRIVATE metagraph-core) You might want to provide For some reason you might need to call |
Dear @adamant-pwn |
Hi @feeka, thanks for the update! Could you please provide some details on what exactly you're doing and what kind of errors you get? |
Hello @adamant-pwn, sorry for late reply. So, I have replicated CMakeLists.txt as you suggested. However even during the compilation I got following: make[5]: *** [external-libraries/googletest/googletest/CMakeFiles/gtest.dir/build.make:76: external-libraries/googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o] Error 1 I think something with gtest. It seems like metagraph itself compiled but the tests that are later on introduced are not. I am not sure though. EDIT: I have commented out the part from #UNIT TEST to the end and it compiled. But right now, there is another error: /usr/bin/ld: CMakeFiles/moon.dir/src/main.cpp.o: in function Not sure why... |
Dear metagraph community,
I was trying to use the succinct de Bruijn graph of the project for graph construction, traversals and etc. After multiple trials of including the library(built statically, included the cmake file, tried to modify, almost every way possible) I simply gave up. It would be great to have some kind of a tutorial or manual on how to configure the library for external c++ project.
Best regards.
The text was updated successfully, but these errors were encountered: