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

Time:12-22

We are using Visual Studio 2019, Qt5.12.3 and qwt-6.1.2 (Qwt is a graphics extension to the Qt GUI application framework) on Windows 10. Our solution has traditionally been a 32-bit only application, but we've received a request to deliver it in both 32-bit and 64-bit.

My question is specifically related to 64-bit qwt-6.1.2.

The 32-bit version of qwt-6.1.2 is compiled without problems with the following script that runs in a batch file (no, we cannot use power shell because power shell scripts are disabled on our network).

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

When trying to compile the same source in 64-bit using the script below I receive hundreds of linker errors

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)

etc. etc... ending with

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.

It appears that somewhere, something is referencing some 32-bit libraries, but I can't find any documentation (I've been searching for a few days) that specifically deal with compiling a 64-bit version of qwt-6.1.2 (or any of the related qwt versions) on Windows.

Any guidance in finding the 64-bit sources, or instructions on how to compile for 64-bit would be greatly appreciated.

CodePudding user response:

You are missing a call to nmake clean and so there are (even after a fresh qmake) leftovers from the 32bit-build breaking your 64bit-build.

CodePudding user response:

Based on the suggestion from @SebDieBln I was able to build the 64-bit version. There is an additional step required however.

Even though we can run "nmake clean" to clean the MS Build data, there is no "qmake clean" to clean the qmake build data. This is a manual step.

Below is the complete script to build both 32-bit and 64-bit binaries for qwt-6.1.2 including the cleaning process in between.

NOTE: This process does not install qwt-6.1.2, it only compiles 32-bit and 64-bit binaries.

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;=%
  • Related