I want to use Graphviz in my Qt application, but I haven't used any third-party libraries before. I've found the following video on YouTube which shows how to use third-party DLLs in Qt. I've downloaded Graphviz 2.38 and copied all headers to my program folder as in the video, and copied all dlls to debug and release builds, and added these dlls as libraries in .pro file. But I still get "undefined reference" errors to functions from graphviz libraries. So does the method shown in the video still work in Qt6 ? Or did I do something wrong ?
.pro file:
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-Debug\debug\ann.dll"
LIBS += "C:\...\build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-Debug\debug\cdt.dll"
LIBS += "C:\...\build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-Debug\debug\cgraph.dll"
LIBS += "C:\...\build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-Debug\debug\gvc.dll"
LIBS += "C:\...\build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-Debug\debug\gvplugin_core.dll"
LIBS += "C:\...\build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-Debug\debug\gvplugin_dot_layout.dll"
LIBS += "C:\...\build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-Debug\debug\gvplugin_gd.dll"
LIBS += "C:\...\build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-Debug\debug\gvplugin_gdiplus.dll"
LIBS += "C:\...\build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-Debug\debug\gvplugin_neato_layout.dll"
LIBS += "C:\...\build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-Debug\debug\gvplugin_pango.dll"
LIBS += "C:\...\build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-Debug\debug\Pathplan.dll"
LIBS += "C:\...\build-BSP_Emulator_alpha-Desktop_Qt_6_2_0_MinGW_64_bit-Debug\debug\vmalloc.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));
}