I would like to create a slicing app based on libslic3r from Slic3r in Qt 6.5 with C++ and qmake, using Bootstrap 1.84. After including libslic3r and building the project, linking errors occur when calling specific libslic3r classes like "Polygon", "MultiPoint" or "ConfigBase". When including e.g. the classes "Point" or "Line", the project is build properly. Linking errors: LNK2001, LNK2001, LNK1120
Config:
- Qt6.5
- C++17
- boost1.84
- msvc14.3
- windows10 (x64) - libslic3r: https://github.com/slic3r/Slic3r/tree/master/xs/src
mainwindow.h:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "Point.hpp"
#include "Config.hpp"
#include "Model.hpp"
#include "TriangleMesh.hpp"
class MainWindow : Public QMainWindow
{
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private:
SLic3r::Point p(1,2); //when including "Point.hpp" from libslic3r/Point.hpp, the project will build
Slic3r::Model model; //this will throw linking errors (LNK2001, LNK2001, LNK1120)
[...]
}
Project.pro:
QT += core gui
CONFIG += c++17
DEFINES += NO_PERL
DEPENDPATH += .../boost_1_84_0_prebuild_msvc_143
INCLUDEPATH += .../boost_1_84_0_prebuild_msvc_143
DEPENDPATH += .../boost_1_84_0_prebuild_msvc_143/boost
INCLUDEPATH += .../boost_1_84_0_prebuild_msvc_143/boost
INCLUDEPATH += xs/src/
INCLUDEPATH += xs/src/libslic3r
LIBS += -L.../boost_1_84_0_prebuild_msvc_143/lib64-msvc-14.3
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += mainwindow.h
The following attempts were designed according to the Slic3r test cases (https://github.com/slic3r/Slic3r/tree/master/xs/t). Calling the classes (e.g. the Model class) in the header (see above) as a private class member of MainWindow as well as creating the Model class object in a function (see below) lead to the same linking errors:
MainWindow.h:
#include "Point.hpp"
#include "Config.hpp"
#include "Model.hpp"
#include "TriangleMesh.hpp"
class MainWindow : Public QMainWindow
{
public:
void run();
[...]
}
MainWindow.cpp:
#include "mainwindow.h"
[...]
void MainWindow::run()
{
Slic3r::Model model;
}
I also first tried to include the headers into the qmake -sources. This did not help either. In the Polygon as well as ExPolygon classes, there was a linker error, which I resolved by changing "Polygon" to Slic3r::Polygon. The multiple Polygon definition of Polygon came from the Polygon-class defined in WindowsKits/wingdi.h. Afterwards, this linking error was gone, but the new ones, described in this post, appeared.
Does anyone know how to resolve these or general linking errors in 3rd party libraries?