Reputation: 5992
I am writing an application in C++, and I am making the build script with autotools. The end user will then be able to run ./configure && make && make install
in the source directory. My question is : can the same command be used on windows ? If not, how can i achieve a similar process with autotools ? Or is autotools incapable of producing a build script for windows ? If so, which build tool could be used for windows ? Thanks in advance !
Upvotes: 3
Views: 4753
Reputation: 157
I don't think you understand the actual problem, nor do all those people, who suggest using MSYS, Cygwin or WSL. What's the difference between running a bash configure script inside WSL vs. running it inside a real Hyper-V linux VM? There's none. WSL and its friends are providing a LINUX environment, so does a real VM. There's an OS check inside the configure script or the subsequent makefile-s? VM will say, "I'm linux!" So will WSL. There's a check for a symbol, which exists on linux, but not on Windows? WSL will say, "by all means! symbol exists!" There's a check for "size_t"? Yep, it's there! Except, it's NOT, because msvc only knows "SIZE_T" (capitals).
So I run configure + make on linux. Fine, I got all the necessary .config.h files created, I got the make SHELL="/usr/bin/bash -x" verbose output. Except all variables are wrong, 'cause everything was checked against linux + clang! So I have to re-run all checks manually, fixing the config files
#define HAVE_STRTOK_R
no, wait, damn it, no strtok_r on windows!
#define HAVE_DIRENT_H
Noooo, no dirent.h in MSVC!
#define HAVE_LONG_LONG
Should be there... right?
#define SIZEOF_WHATEVER x
just a sec... let me check...
Then I have to convert all that makefile meson whatever stuff into a cmake file, then finally I can build using MSVC. And what about all those *.am and *.m4 files? Cryptic stuff, I have no idea what they are. cmake works across all systems, yet 90% of all code on the net uses configure scripts + make, no cmakelists.txt for you, no *.vcxproj files, no nmake files, nothing for Windows!
Cross-compiling? Not a solution. Architecture of a linux VM can be the same as the one of the host windows system, amd64 etc., the problem is, the linux build system checks against clang on linux, but what I need are checks against MSVC. So, the linux script checks for visibility attribute, clang says yes, MSVC says no.
All these fixes cost an immense amount of time. So the question remains. How to adjust a linux build system for MSVC effectively, without wasting time and learning 20 languages used for build systems? And no, I am not going to use other compilers to build for Windows. What do they know about Windows, MS doesn't tell them anything.
Upvotes: 1
Reputation: 180538
can the same command be used on windows ?
Autoconf produces configure
as a portable (POSIX) shell script. Windows does not come standard with a POSIX shell, nor with any of the standard tools on which Autotools configuration scripts and makefiles rely. Windows also does not come standard with a make
implementation suitable for use with Autotools-built makefiles, and to the best of my knowledge, Visual Studio does not provide one either.
You could pretty easily build and run your project inside a WSL container on Windows, but that does not get you a native Windows executable.
If you want to use an Autotools build system on Windows to produce Windows executables then your best bet is probably to rely on msys2 and mingw-w64. These, together, can provide a standard-ish POSIX environment running natively in Windows, able to build Windows libraries and executables via the usual commands. But note well that this approach means that anyone who wants to build your project on Windows has to install these or comparable components first.
If not, how can i achieve a similar process with autotools ? Or is autotools incapable of producing a build script for windows ?
The Autotools produce build systems targeting Unix-like operating systems, including (but not limited to) Linux and MacOS. Such build systems are not appropriate for Windows machines except with the addition of a fairly large suite of third-party components, such as msys2 and mingw-x64 can provide.
If so, which build tool could be used for windows ?
CMake is a more typical choice if you're after build compatibility with both Windows and Unix. That would ordinarily be instead of the Autotools, not in addition to them, because who wants to maintain multiple independent build systems for the same project?
Upvotes: 5