我们在Windows 10上使用Visual 2019、Qt5.12.3和qwt-6.1.2 (Qwt是Qt应用程序框架的图形扩展)。我们的解决方案传统上是一个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位库,但我找不到任何文档(我已经搜索了几天),这些文档专门涉及在Windows上编译64位版本的qwt-6.1.2 (或任何相关的qwt版本)。
任何关于查找64位源的指导,或关于如何为64位编译的说明都将不胜感激。
发布于 2021-12-21 14:34:57
根据@SebDieBln的建议,我能够构建64位版本。不过,还需要采取一项额外步骤。
尽管我们可以运行"nmake“来清理MS构建数据,但是没有"qmake”来清理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;=%
https://stackoverflow.com/questions/70426230
复制相似问题