Skip to content

Commit

Permalink
Fix Linux build
Browse files Browse the repository at this point in the history
  • Loading branch information
kovzol committed Jan 1, 2025
1 parent 9e96c9d commit 51d66ad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ set_target_properties(bibref-qt PROPERTIES
MACOSX_BUNDLE TRUE
)

if(MINGW)
SET(EXTRA_LIBS -lgvplugin_dot_layout -lgvplugin_rsvg -lgvplugin_core -lgvplugin_pango)
endif(MINGW)

target_link_libraries(bibref-qt PRIVATE
Qt6::Core
Qt6::Gui
Expand All @@ -95,7 +99,7 @@ target_link_libraries(bibref-qt PRIVATE
Qt6::SvgWidgets
${sword_LIBRARIES} ${Boost_LIBRARIES} ${readline_LIBRARIES}
${ICU_LIBRARIES} ${LIBLZMA_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES}
${gvc_LIBRARIES} -lgvplugin_dot_layout -lgvplugin_rsvg -lgvplugin_core -lgvplugin_pango
${gvc_LIBRARIES} ${EXTRA_LIBS}
)

# If not set, XDG_DATA_HOME is set to $HOME:
Expand Down
9 changes: 7 additions & 2 deletions qt/visualizewindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ VisualizeWindow::VisualizeWindow(QWidget *parent, string input)
setCentralWidget(tile);

GVC_t *gvc= gvContext();
/* This seems to be required, at least on Windows.
#ifdef __MINGW32__
/* This seems to be required on Windows, otherwise the
* executable will not know anything about the dot format,
* the svg export, and so on.
* Also, in CMake's library settings these 4 dynamic libraries
* must be included.
* must be included. There seems to be no official way to
* do this elegantly.
*/
extern gvplugin_library_t gvplugin_dot_layout_LTX_library;
extern gvplugin_library_t gvplugin_rsvg_LTX_library;
Expand All @@ -33,6 +37,7 @@ VisualizeWindow::VisualizeWindow(QWidget *parent, string input)
gvAddLibrary(gvc, &gvplugin_rsvg_LTX_library);
gvAddLibrary(gvc, &gvplugin_core_LTX_library);
gvAddLibrary(gvc, &gvplugin_pango_LTX_library);
#endif

Agraph_t *g = agmemread((char*)input.c_str());
gvLayout(gvc, g, "dot");
Expand Down

0 comments on commit 51d66ad

Please sign in to comment.