这是使用graphviz作为库的正确方式吗?

  • 本文关键字:方式吗 graphviz c++ qt qmake
  • 更新时间 :
  • 英文 :


我想在我的Qt应用程序中使用Graphviz,但我以前没有使用过任何第三方库。我在YouTube上找到了以下视频,该视频展示了如何在Qt中使用第三方dll,我下载了Graphviz 2.38并将所有头文件复制到我的程序文件夹中,并复制所有dll以调试和发布构建,并将这些dll作为库添加到.pro文件中。但我仍然得到"未定义引用"。来自graphviz库的函数错误。那么视频中显示的方法在Qt6中仍然有效吗?还是我做错了什么?

。支持文件:

QT       += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
SOURCES += 
main.cpp 
mainwindow.cpp
HEADERS += 
arith.h 
cdt.h 
cgraph.h 
color.h 
geom.h 
graph.h 
gvc.h 
gvcext.h 
gvcjob.h 
gvcommon.h 
gvconfig.h 
gvplugin.h 
gvplugin_device.h 
gvplugin_layout.h 
gvplugin_loadimage.h 
gvplugin_render.h 
gvplugin_textlayout.h 
gvpr.h 
mainwindow.h 
pack.h 
pathgeom.h 
pathplan.h 
textpara.h 
textspan.h 
types.h 
usershape.h 
xdot.h
LIBS += "C:...build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-Debugdebugann.dll"
LIBS += "C:...build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-Debugdebugcdt.dll"
LIBS += "C:...build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-Debugdebugcgraph.dll"
LIBS += "C:...build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-Debugdebuggvc.dll"
LIBS += "C:...build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-Debugdebuggvplugin_core.dll"
LIBS += "C:...build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-Debugdebuggvplugin_dot_layout.dll"
LIBS += "C:...build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-Debugdebuggvplugin_gd.dll"
LIBS += "C:...build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-Debugdebuggvplugin_gdiplus.dll"
LIBS += "C:...build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-Debugdebuggvplugin_neato_layout.dll"
LIBS += "C:...build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-Debugdebuggvplugin_pango.dll"
LIBS += "C:...build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-DebugdebugPathplan.dll"
LIBS += "C:...build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-Debugdebugvmalloc.dll"
FORMS +=

main.cpp:

#include "mainwindow.h"
#include "gvc.h"
#include <QApplication>
int main(int argc, char *argv[])
{
//QApplication a(argc, argv);
MainWindow main_window;
main_window.setGeometry(100,100,1000,1300);
main_window.show();
GVC_t *gvc;
Agraph_t *g;
FILE *fp;
gvc = gvContext();
if (argc > 1)
fp = fopen(argv[1], "r");
else
fp = stdin;
g = agread(fp, 0);
gvLayout(gvc, g, "dot");
gvRender(gvc, g, "plain", stdout);
gvFreeLayout(gvc, g);
agclose(g);
return (gvFreeContext(gvc));
}

在'LIBS +='部分中,您必须设置的不是*.dll文件,而是。Lib (windows)或(Lib.a) (unix

)当你下载库时,你可能有这样的文件:

library.dll - file with compiled code used only by operating system
library.lib (win32) - file used by linker to connect you program with library

Dll根本不需要编译程序,它只在系统启动程序时使用。