[英]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. 我在编写从官方网站上获取的简单示例代码时遇到问题https://graphviz.gitlab.io/_pages/dot.demo/demo.c 。问题是未定义的Graphviz函数参考。 I know there is a related question asked here Qt Creator cannot resolve gvContext on Ubuntu , but it didn't help.
我知道这里有一个相关的问题Qt Creator无法在Ubuntu上解析gvContext ,但它没有帮助。
I have included libgvc libcgraph libcdt in my CMakeLists.txt and that did't help. 我在我的CMakeLists.txt中包含了libgvc libcgraph libcdt,但没有用。 I have made sure that these packages are present on my machine.
我确保我的机器上有这些包装。
Here is my CMakeLists.txt 这是我的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? 你安装了
libgraphviz-dev
包吗? That contains the libgvc
pkg-config file your CMakeLists.txt needs. 它包含您的CMakeLists.txt需要的
libgvc
pkg-config文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.