1

I am trying to use a xmlpatterns-private. I could get the headers by adding qt += xmlpatterns-private. But when I compile it gives the error:

undefined reference to `QPatternist::XsdSchemaResolver::~XsdSchemaResolver()'

So it supposes means that header was found but the lib didn't install my Qt environment. How to install or adding such a private module into Qt instead of compiling the whole Qt source? I'm guessing that I shall pull the xmlpatterns source and compile it, put it into some folder... In other words how to perform the installation of the private module.

What I tried:

  1. Download Qt 5.13 source code
  2. Open qtxmlpatterns.pro in QtCreator
  3. Add CONFIG+=xml-schema in qtxmlpatterns.pro
  4. Build
  5. Go to build folder and run mingw32-make install
  6. Rebuild my project, but gives the same error...

Update:

the function cannot be found is because Qt didn't export it using Q_XMLPATTERNS_EXPORT.

So I import the whole xmlpatterns source into my project instead of qt += xmlpatterns-private. the cpp already part of the project why the function still cannot be found.

error: undefined reference to `_imp___ZN12QXmlNamePoolC1Ev'

The whole project: https://drive.google.com/drive/folders/1B2YEz1iUHdbZ-F3ukBRpjZ9eP012Jkez?usp=sharing

JustWe
  • 4,250
  • 3
  • 39
  • 90

1 Answers1

0
#ifndef Q_XMLPATTERNS_EXPORT
#  ifndef QT_STATIC
#    if defined(QT_BUILD_XMLPATTERNS_LIB)
#      define Q_XMLPATTERNS_EXPORT Q_DECL_EXPORT
#    else
#      define Q_XMLPATTERNS_EXPORT Q_DECL_IMPORT
#    endif
#  else
#    define Q_XMLPATTERNS_EXPORT
#  endif
#endif
...
#  ifdef Q_OS_WIN
#    define Q_DECL_EXPORT     __declspec(dllexport)
#    define Q_DECL_IMPORT     __declspec(dllimport)
...

undefined reference to `QPatternist::XsdSchemaResolver::~XsdSchemaResolver()'

this is because of the XsdSchema... didn't __declspec(dllexport). there are many private Qt classes is invisible API. so cannot find the reference if I use as lib. If I modify all the necessary class with export keywords. it supposes to solve the error. (didn't confirm)

instead of using the lib, I import the whole source code into the project. it gives

error: undefined reference to `_imp___ZN12QXmlNamePoolC1Ev'

because of the class having __declspec(dllimport) it tells to find the reference in the lib which shall be imported. But now the private classes actually is part of source code(of course, it's undefined I didn't import it). Remove the __declspec(dllimport) solves it(confirmed, build successed).

JustWe
  • 4,250
  • 3
  • 39
  • 90