简体   繁体   中英

How to properly link Graphviz in a c++ application on Ubuntu

I am having problems compiling simple example code taken from the official website here https://graphviz.gitlab.io/_pages/dot.demo/demo.c .The problem is undefined reference to Graphviz functions. I know there is a related question asked here Qt Creator cannot resolve gvContext on Ubuntu , but it didn't help.

I have included libgvc libcgraph libcdt in my CMakeLists.txt and that did't help. I have made sure that these packages are present on my machine.

Here is my CMakeLists.txt

cmake_minimum_required(VERSION 3.13)
project(name)

set(CMAKE_CXX_STANDARD 14)

add_executable(name main.cpp)

INCLUDE(FindPkgConfig)
PKG_SEARCH_MODULE(gvc REQUIRED libgvc libcgraph libcdt)
LINK_DIRECTORIES(${gvc_LIBRARY_DIRS})
INCLUDE_DIRECTORIES(${gvc_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${gvc_LIBRARIES})

Please if someone linked the library or knows how to link correctly, let me know.

Did you install the libgraphviz-dev package? That contains the libgvc pkg-config file your CMakeLists.txt needs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM