[smartmontools-support] Compiling smartctl on Windows

Christian Franke Christian.Franke at t-online.de
Fri Apr 22 13:45:08 CEST 2022


Eaton Zveare wrote:
> Hi, after spending some time getting smartctl compilable on my Windows 
> 11 machine, I have run into problems and must ask for some assistance 
> in getting a proper build environment set up.

Which compatibility problems did you find under Win11 ?


>
> I have read the "Guidelines for Windows" section in the INSTALL file. 
> I installed MSYS2, did their 2-step package update commands, and 
> installed mingw-w64-x86_64-toolchain. In other words, everything under 
> the Installation section here: https://www.msys2.org/
>
> I then installed these additional packages via this command: /pacman 
> -S make autoconf autogen automake/

If you plan to use Linux-like tools more often, I would recommend to use 
Cygwin.


> /
> /
> I then copied the latest smartmontools source (the SVN copy) to here: 
> /C:\msys64\home\Eaton/
> Start the "MSYS2 MinGW x64" shell and run these commands:
>
>  1. /./autogen.sh/
>  2. /./configure/
>  3. /make/
>
> That gets me a smartctl.exe, but it's 6.4 MB, more than 6x larger than 
> the official build. I suspect it was compiled in debug mode, but it's 
> not clear how to specify release/production mode.

The configure default is CXXFLAGS='-g -O2', so code is optimized for 
release but debug information is still included.


> This leads to my questions:
>
>  1. How do I compile in release/production mode?
>

This removes the debug info:
strip -s *.exe
x86_64-mingw32-strip -s *.exe


>  1. How do I compile the "smartctl-nc" version of the exe?
>

make smartctl-nc.exe

Both are included in:
make instdir-win32


>  1. I also tried getting this working in Visual Studio, but running
>     the /config-vc14/ (or vc16) command does not work. It says /No
>     rule to make target/.
>

Yes, this info is outdated, sorry. Added to my TODO list.

The make commands for VC16 (VS2019) are now:
make config-vc
make clean-vc
make distclean-vc
make maintainer-clean-vc

Add "vc=15" to switch to VC15 (VS2017).

Note that VC is never used for release and CI 
(https://builds.smartmontools.org/) binaries for Windows. These are 
always cross-compiled using a Docker image with Linux and Mingw-w64.

Thanks,
Christian



More information about the Smartmontools-support mailing list