QT MSVC environment undefined Symbols and dllimport errors with self built libs

135 Views Asked by At

When building several 3rd party libraries from source I get undefined symbols build errors or dll import errors.

Im trying to work out why certain functions don't link/can't be linked.

I am using qt creator 7.0.0 qt.6.2.4 online installer linked to LLVM 14.0.0 (13.0.0 has a bug with /MANIFESTDEPENDENCY)

I have followed the below link to build libxml(build with multithreadeddll or MD runtime) https://forum.unified-automation.com/viewtopic.php?t=26 as well as followed a similar link to build libxslt.

I link to them in the .pro

INCLUDEPATH += ../../../Thirdparty/msvclibxml/include
INCLUDEPATH += ../../../Thirdparty/msvclibxml/include/libxml2
win32:DEPENDPATH += -L../../../Thirdparty/msvclibxml/lib -llibxml2
win32:LIBS += -L../../../Thirdparty/msvclibxml/lib -llibxml2

I have run into similar issues with building BMX when linking to self contained expat library in the code.

I don't experience any issue with my self built libraries, the AWS c++ sdk, FFmpeg so my general method isn't wrong.

Any help would be greatly appreciated.

Upon request here's the use case of lib xml that fails

in the header

     //extern "C"
{
#include <libxml/tree.h>
#include <libxml/xmlmemory.h>
#include <libxml/debugXML.h>
#include <libxml/HTMLtree.h>
#include <libxml/xmlIO.h>
#include <libxml/xinclude.h>
#include <libxml/catalog.h>
#include <libxml/parser.h>
#include <libxml/HTMLparser.h>
#include <libxslt/xslt.h>
#include <libxslt/xsltInternals.h>
#include <libxslt/transform.h>
#include <libxslt/xsltutils.h>
}

the called function.

int pdfWriter::generatePDFObject(QString stylesheetFileName, QString xmlFilePath, QString &pdfFileName, QTextDocument &document, QString &formattedString)
{
    QFile fileCheck(xmlFilePath);
    if (!fileCheck.open(QIODevice::ReadOnly))
    {
        qDebug() << "Xml file does not exist";
        return 2;
    }
    fileCheck.close();

    QFileInfo fileCheckInfo(xmlFilePath);
    if (fileCheckInfo.suffix().compare("xml", Qt::CaseInsensitive) != 0)
    {
        qDebug() << "File does not have xml extension";
        return 1;
    }

    //Put this in eFFData
    QString styleSheetFileName;
    QString styleSheetCustomerImage;
    QString path = "C:/Users/User/hardcodedpathexample";

    styleSheetFileName = path;
    styleSheetFileName.append("/");
    styleSheetFileName.append(stylesheetFileName);

    styleSheetCustomerImage = path;
    styleSheetCustomerImage.append("/");
    styleSheetCustomerImage.append("hardecodedimagesfilenameexample");

    // Code to create pdf file
    pdfFileName = xmlFilePath;
    pdfFileName.remove(".xml");
    pdfFileName.append(".pdf");

    xmlDocPtr doc, res;

    xmlOutputBufferPtr buf = xmlAllocOutputBuffer(NULL);

    doc = xmlParseFile(xmlFilePath.toUtf8());

    const char *params[1];
    params[0] = nullptr;

    xsltStylesheetPtr cur = NULL;
    xmlSubstituteEntitiesDefault(1);
    xmlLoadExtDtdDefaultValue = 1;
    cur = xsltParseStylesheetFile((const xmlChar *)styleSheetFileName.toLocal8Bit().data());

    res = xsltApplyStylesheet(cur, doc, params);
    xsltSaveResultTo(buf, res, cur);

    xsltFreeStylesheet(cur);
    xmlFreeDoc(res);
    xmlFreeDoc(doc);

    xsltCleanupGlobals();
    xmlCleanupParser();

    formattedString = QString::fromUtf8((char*)(xmlOutputBufferGetContent(buf)));
    xmlOutputBufferClose(buf);

    QPixmap pixmap;
    pixmap = QPixmap(":/logo/e-logo.png");

    document.addResource(QTextDocument::ImageResource, QUrl("image file name example"), pixmap.scaled(350, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation));

    QPixmap customerPixmap(styleSheetCustomerImage);
    document.addResource(QTextDocument::ImageResource, QUrl("image file name example"), customerPixmap.scaled(350, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation));

    return 0;
}

multiple function fail - mainly xmlAllocOutputBuffer(Null) undefined symbol

0

There are 0 best solutions below