如何使用命令行在 Windows 上为 qwt-6.1.2 编译 64 位库

How to compile 64-bit libraries for qwt-6.1.2 on Windows with command line

我们在 Windows10 上使用 Visual Studio2019、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.12.3\msvc2017\bin;

REM Create qwt make files
REM 1. Set up x86 environment
"C:\Program Files (x86)\Microsoft Visual Studio19\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.12.3\msvc2017_64\bin

REM Create qwt make files
REM 1. Set up x64 environment
"C:\Program Files (x86)\Microsoft Visual Studio19\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 Studio19\Professional\VC\Tools\MSVC.29.30133\lib\x64\msvcprt.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'
C:\Program Files (x86)\Microsoft Visual Studio19\Professional\VC\Tools\MSVC.29.30133\lib\x64\MSVCRT.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'
C:\Program Files (x86)\Windows Kits\lib.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 Studio19\Professional\VC\Tools\MSVC.29.30133\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.

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

-6.1.2(或任何相关的 qwt 版本)

如能提供有关查找 64 位源代码的任何指导,或有关如何针对 64 位进行编译的说明,我们将不胜感激。

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

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

即使我们可以 运行 "nmake clean" 清理 MS Build 数据,也没有 "qmake clean"[=23] =] 清理 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.12.3\msvc2017\bin;

REM 1. Set up x86 environment
"C:\Program Files (x86)\Microsoft Visual Studio19\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.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.12.3\msvc2017_64\bin

REM 1. Set up x64 environment
"C:\Program Files (x86)\Microsoft Visual Studio19\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.12.3\msvc2017_64\bin;=%