简体   繁体   English

如何添加Qt私有模块的库?

[英]How to add Qt private module's libs?

I am trying to use a xmlpatterns-private . 我正在尝试使用xmlpatterns-private I could get the headers by adding qt += xmlpatterns-private . 我可以通过添加qt += xmlpatterns-private获得标题。 But when I compile it gives the error: 但是当我编译它会给出错误:

undefined reference to `QPatternist::XsdSchemaResolver::~XsdSchemaResolver()' 对`QPatternist :: XsdSchemaResolver ::〜XsdSchemaResolver()的未定义引用

So it supposes means that header was found but the lib didn't install my Qt environment. 因此,它意味着找到了标头,但lib没有安装我的Qt环境。 How to install or adding such a private module into Qt instead of compiling the whole Qt source? 如何在Qt中安装或添加这样的私有模块,而不是编译整个Qt源? 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. 我猜测我将提取xmlpatterns源并将其编译,然后将其放入某个文件夹中...换句话说,如何执行私有模块的安装。

What I tried: 我试过的

  1. Download Qt 5.13 source code 下载Qt 5.13源代码
  2. Open qtxmlpatterns.pro in QtCreator 打开qtxmlpatterns.pro在QtCreator
  3. Add CONFIG+=xml-schema in qtxmlpatterns.pro qtxmlpatterns.pro添加CONFIG+=xml-schema
  4. Build 建立
  5. Go to build folder and run mingw32-make install 转到构建文件夹并运行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 . 找不到函数是因为Qt没有使用Q_XMLPATTERNS_EXPORT导出它。

So I import the whole xmlpatterns source into my project instead of qt += xmlpatterns-private . 所以我将整个xmlpatterns源导入到我的项目中,而不是qt += xmlpatterns-private the cpp already part of the project why the function still cannot be found. cpp已经成为项目的一部分,为什么仍找不到该功能。

error: undefined reference to `_imp___ZN12QXmlNamePoolC1Ev' 错误:对`_imp___ZN12QXmlNamePoolC1Ev'的未定义引用

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

#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()' 对`QPatternist :: XsdSchemaResolver ::〜XsdSchemaResolver()的未定义引用

this is because of the XsdSchema... didn't __declspec(dllexport) . 这是因为XsdSchema...不是__declspec(dllexport) there are many private Qt classes is invisible API. Qt有很多私有类是不可见的API。 so cannot find the reference if I use as lib. 因此,如果我用作lib,则找不到引用。 If I modify all the necessary class with export keywords. 如果我用export关键字修改所有必需的类。 it supposes to solve the error. 它想解决错误。 (didn't confirm) (未确认)

instead of using the lib, I import the whole source code into the project. 我没有使用lib,而是将整个源代码导入到项目中。 it gives 它给

error: undefined reference to `_imp___ZN12QXmlNamePoolC1Ev' 错误:对`_imp___ZN12QXmlNamePoolC1Ev'的未定义引用

because of the class having __declspec(dllimport) it tells to find the reference in the lib which shall be imported. 因为该类具有__declspec(dllimport)所以它告诉在要导入的lib中找到引用。 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). 删除__declspec(dllimport)解决(确认,构建成功)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM