【问题标题】:How to compile 64-bit libraries for qwt-6.1.2 on Windows with command line如何在 Windows 上使用命令行为 qwt-6.1.2 编译 64 位库
【发布时间】:2022-01-22 07:56:21
【问题描述】:

我们在 Windows 10 上使用 Visual Studio 2019、Qt5.12.3 和 qwt-6.1.2(Qwt 是 Qt GUI 应用程序框架的图形扩展)。我们的解决方案传统上是仅 32 位的应用程序,但我们'已收到以 32 位和 64 位交付它的请求。

我的问题具体与 64 位 qwt-6.1.2 有关。

qwt-6.1.2 的 32 位版本在批处理文件中运行的以下脚本没有问题(不,我们不能使用 power shell,因为我们的网络上禁用了 power shell 脚本)。

cd\resources
tar -xf qwt-6.1.2.zip
rem del qwt-6.1.2.zip
cd\resources\qwt-6.1.2

REM Add the x86 path to compile qwt-6.1.2
SET PATH=%PATH%;C:\Qt\Qt5.12.3\5.12.3\msvc2017\bin;

REM Create qwt make files
REM 1. Set up x86 environment
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars32.bat"
REM 2. Create x86 make files
qmake qwt.pro
REM 3. Compile the binaries for x86 version of qwt-6.1.2
nmake

当尝试使用下面的脚本以 64 位编译相同的源代码时,我收到数百个链接器错误

REM Add the x64 path to compile qwt-6.1.2
SET PATH=%PATH%;C:\Qt\Qt5.12.3\5.12.3\msvc2017_64\bin

REM Create qwt make files
REM 1. Set up x64 environment
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat"
REM 2. Clean up the old qmake data for rebuild to x64
del c:\resources\qwt-6.1.2\.qmake.stash
del c:\resources\qwt-6.1.2\Makefile
REM 3. Create x86 make files
qmake qwt.pro
REM 4. Compile the binaries for x86 version of qwt-6.1.2
nmake
linking ..\lib\qwt.dll
   Creating library ..\lib\qwt.lib and object ..\lib\qwt.exp
qwt_dial.obj : error LNK2001: unresolved external symbol "void __stdcall `eh vector copy constructor iterator'(void *,void *,unsigned int,unsigned int,void (__thiscall*)(void *,void *),void (__thiscall*)(void *))" (??__C@YGXPAX0IIP6EX00@ZP6EX0@Z@Z)
qwt_knob.obj : error LNK2001: unresolved external symbol "void __stdcall `eh vector copy constructor iterator'(void *,void *,unsigned int,unsigned int,void (__thiscall*)(void *,void *),void (__thiscall*)(void *))" (??__C@YGXPAX0IIP6EX00@ZP6EX0@Z@Z)
qwt_slider.obj : error LNK2001: unresolved external symbol "void __stdcall `eh vector copy constructor iterator'(void *,void *,unsigned int,unsigned int,void (__thiscall*)(void *,void *),void (__thiscall*)(void *))" (??__C@YGXPAX0IIP6EX00@ZP6EX0@Z@Z)
qwt_thermo.obj : error LNK2001: unresolved external symbol "void __stdcall `eh vector copy constructor iterator'(void *,void *,unsigned int,unsigned int,void (__thiscall*)(void *,void *),void (__thiscall*)(void *))" (??__C@YGXPAX0IIP6EX00@ZP6EX0@Z@Z)
qwt_abstract_slider.obj : error LNK2001: unresolved external symbol "void __stdcall `eh vector copy constructor iterator'(void *,void *,unsigned int,unsigned int,void (__thiscall*)(void *,void *),void (__thiscall*)(void *))" (??__C@YGXPAX0IIP6EX00@ZP6EX0@Z@Z)
qwt_abstract_scale.obj : error LNK2001: unresolved external symbol "void __stdcall `eh vector copy constructor iterator'(void *,void *,unsigned int,unsigned int,void (__thiscall*)(void *,void *),void (__thiscall*)(void *))" (??__C@YGXPAX0IIP6EX00@ZP6EX0@Z@Z)
qwt_analog_clock.obj : error LNK2001: unresolved external symbol "void __stdcall `eh vector copy constructor iterator'(void *,void *,unsigned int,unsigned int,void (__thiscall*)(void *,void *),void (__thiscall*)(void *))" (??__C@YGXPAX0IIP6EX00@ZP6EX0@Z@Z)
qwt_compass.obj : error LNK2001: unresolved external symbol "void __stdcall `eh vector copy constructor iterator'(void *,void *,unsigned int,unsigned int,void (__thiscall*)(void *,void *),void (__thiscall*)(void *))" (??__C@YGXPAX0IIP6EX00@ZP6EX0@Z@Z)

等等。等等...以

结尾
LINK : error LNK2001: unresolved external symbol __DllMainCRTStartup@12
LINK : error LNK2001: unresolved external symbol __load_config_used
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\lib\x64\msvcprt.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\lib\x64\MSVCRT.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'
C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\uuid.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'
..\lib\qwt.dll : fatal error LNK1120: 47 unresolved externals
NMAKE : fatal error U1077: 'echo' : return code '0x460'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.

似乎某处引用了一些 32 位库,但我找不到任何专门处理编译 64 位版本的 qwt-6.1 的文档(我已经搜索了几天) .2(或任何相关的 qwt 版本)在 Windows 上。

任何有关查找 64 位源的指导,或有关如何为 64 位编译的说明将不胜感激。

【问题讨论】:

  • 看起来qmake qwt.pro 命令中的某些东西正在创建一个专门生成x86 文件的makefile。
  • 您是否尝试过 32 位版本之前构建您的64 位版本?如果 32 位版本有类似的抱怨,您知道这是清理问题,可能是缺少对 nmake clean 的调用?我们在 MSVC 上使用 64 位 QWT 很长时间了,从来没有出现过问题。但我们只使用 64 位。
  • @SebDieBln 是的,就是这样......我试图调用 qmake clean(这不起作用)但没有考虑 nmake clean。感谢您的帮助。
  • @BenjaminKleynhans 很高兴我能提供帮助。我现在将其作为实际答案发布,因此,如果您愿意,请继续接受。

标签: c++ qt command-line qwt


【解决方案1】:

根据@SebDieBln 的建议,我能够构建 64 位版本。但是,还需要一个额外的步骤。

尽管我们可以运行 "nmake clean" 来清理 MS Build 数据,但没有 "qmake clean" 来清理 qmake 构建数据。这是一个手动步骤。

以下是为 qwt-6.1.2 构建 32 位和 64 位二进制文​​件的完整脚本,包括中间的清理过程。

注意: 此进程不安装 qwt-6.1.2,它只编译 32 位和 64 位二进制文​​件。

REM Create resources directory and extract qwt in said directory
cd\resources
tar -xf qwt-6.1.2.zip
REM Delete the zip file since it it no longer required
del qwt-6.1.2.zip
cd\resources\qwt-6.1.2

REM Add the x86 path to compile 32-bit qwt-6.1.2 binaries
SET PATH=%PATH%;C:\Qt\Qt5.12.3\5.12.3\msvc2017\bin;

REM 1. Set up x86 environment
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars32.bat"
REM 2. Create x86 make files
qmake qwt.pro
REM 3. Compile the binaries for x86 version of qwt-6.1.2
nmake

REM Make a lib\lib32 directory
mkdir c:\resources\qwt-6.1.2\lib\lib32
REM Move the compiled files to the lib\lib32 directory
move c:\resources\qwt-6.1.2\lib\*.* c:\resources\qwt-6.1.2\lib\lib32\

REM Clean up the x86 make code
nmake clean

REM Clean up the old qmake data for rebuild to x64
del c:\resources\qwt-6.1.2\.qmake.stash
del c:\resources\qwt-6.1.2\Makefile*
del c:\resources\qwt-6.1.2\designer\Makefile*
rd /S /Q c:\resources\qwt-6.1.2\designer\moc
rd /S /Q c:\resources\qwt-6.1.2\designer\plugins
rd /S /Q c:\resources\qwt-6.1.2\designer\resources
del c:\resources\qwt-6.1.2\doc\Makefile*
del c:\resources\qwt-6.1.2\src\Makefile*
del c:\resources\qwt-6.1.2\textengines\Makefile*

REM Remove the x86 path variables to MSVC2017
SET PATH=%PATH:C:\Qt\Qt5.12.3\5.12.3\msvc2017\bin;=%
REM Add the x64 path to compile 64-bit qwt-6.1.2 binaries
SET PATH=%PATH%;C:\Qt\Qt5.12.3\5.12.3\msvc2017_64\bin

REM 1. Set up x64 environment
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat"
REM 2. Create x86 make files
qmake qwt.pro
REM 3. Compile the binaries for x86 version of qwt-6.1.2
nmake

REM Make a lib\lib64 directory
mkdir c:\resources\qwt-6.1.2\lib\lib64
REM Move the compiled files to the lib\lib64 directory
move c:\resources\qwt-6.1.2\lib\*.* c:\resources\qwt-6.1.2\lib\lib64

REM Clean up the x64 make code
nmake clean

REM Clean up the x64 qmake data
del c:\resources\qwt-6.1.2\.qmake.stash
del c:\resources\qwt-6.1.2\Makefile*
del c:\resources\qwt-6.1.2\designer\Makefile*
rd /S /Q c:\resources\qwt-6.1.2\designer\moc
rd /S /Q c:\resources\qwt-6.1.2\designer\plugins
rd /S /Q c:\resources\qwt-6.1.2\designer\resources
del c:\resources\qwt-6.1.2\doc\Makefile*
del c:\resources\qwt-6.1.2\src\Makefile*
del c:\resources\qwt-6.1.2\textengines\Makefile*

REM Remove the x64 path variables to MSVC2017_64
SET PATH=%PATH:C:\Qt\Qt5.12.3\5.12.3\msvc2017_64\bin;=%

【讨论】:

    【解决方案2】:

    您错过了对 nmake clean 的调用,因此(即使在新的 qmake 之后)32 位构建的剩余部分会破坏您的 64 位构建。

    【讨论】:

    • 要添加的额外内容...由于没有有效的“qmake clean”,因此还必须删除所有目录中的“Makefile”,因为 qmake 仅生成 32 位“Makefile” .我在下面的帖子中添加了构建/清理脚本来构建 32 位和 64 位版本。
    猜你喜欢
    • 2010-11-03
    • 2011-03-25
    • 2011-11-29
    • 1970-01-01
    • 1970-01-01
    • 2012-06-14
    • 1970-01-01
    • 2011-04-24
    • 2018-02-26
    相关资源
    最近更新 更多