libconfig 1.4.9 compile for Windows - c++

I have a little trouble here. I know how to compile libconfig for linux with ./configure file and make, but i have no idea how to do the same for the windows. INSTALL file doesn't say anything about compiling it on windows or cross compiling it to windows from linux. Official site (http://www.hyperrealm.com/libconfig/) says that I can do that with Visual Studio 2008 (hell no) or gcc. But I don't know how. Can someone help me?

I've cross compiled the api from Linux for Windows using
./configure --build x86_64-unknown-linux-gnu --host x86_64-w64-mingw32 --prefix=$PWD/bin.
That configures the make files to use the 64 bit version of mingw to build.
The --prefix=$PWD/bin makes it so that when you type make install it will install to the root folder of the build under /bin. I did that so it wouldn't mix windows libraries in with my linux libraries.
I made the mistake of using i686 as the platform for mingw. Don't do that. It won't link to your project if you do.

Related

conan packages vs mingwin conflicts how to fix?

I use conan as a dependency manager for a large C++ project. The project was built for Linux and I am porting it to Windows.
Due to this I am compiling with mingwin since that development environment is closer to mine.
However, conan knows it's running on windows and so it downloads windows binaries.
I am finding that although compilation works, linking fails because mingwin binaries and MSVC binaries are incompatible.
I am not sure if I need to try to instruct meson (my build system) to use cl as the compiler, or trick conan to download Linux libraries instead of windows.

I am trying to install MinGW but it's always failing to install

I am trying to install MinGW but it's always failing to install.
on windows 7
link of the program:
https://sourceforge.net/projects/mingw/files/latest/download
Tar zips are not generally for windows users the downlink should be a windows installer mingw-get-setup.EXE thus (not a GnuZip)
Also if your trying to unpack 32bit collections the question is which architecture do you need, certainly 32.exe will run on 64, but 64.exe will NOT work on 32.
Current build is 32bit "Although (currently) offering only a 32-bit compiler suite, all of MinGW's software will execute on the 64bit Windows platforms."
get it from official https://osdn.net/projects/mingw/releases/
latest link I got was
https://osdn.net/frs/redir.php?m=liquid&f=mingw%2F68260%2Fmingw-get-0.6.3-mingw32-pre-20170905-1-bin.zip
once you have a valid windows .zip file, right click to "extract" then the exe should be in the bin folder.
Then it's just you on your own, and the myriad of instructions from google.
MinGW is a compiler generating files for the Windows platform, but MinGW itself can also be run on other platforms (like Linux for example).
What you need is are Windows binaries of MinGW.
But MinGW is a bit outdated and only supports 32-bit Windows.
I would really recommend using MinGW-w64.
Standalone build of MinGW-w64 for Windows (both 32-bit and 64-bit) are available at https://winlibs.com/ just download the archive and extract it. Then all the tools you need will be in the mingw32/bin or mingw64/bin folder.
If you're not very familiar with command line tools you should really use an IDE. There are some instructions on https://winlibs.com/ on how to use MinGW-w64 with Code::Blocks.
If on the other hand you are very familiar with command line or the Linux shell you should take a look at MSYS2 which also allows installing MinGW-w64 with it's pacman tool.

"Cannot execute binary file" when running compiled c++ programs with Eclipse on Ubuntu for Windows platform

I would like to move from Visual Studio on Windows platform to Eclipse on Ubuntu for c++ development, since I develop almost all my programs on Java, with Eclipse, and I just use a Windows virtual machine in order to develop C++ programs for Win OS. So if I would be happy being able to not use Windows VM at all. However, I've managed to configure MinGW and Eclipse successfully enough to compile programs, but not to execute them.
Steps I've gone through so far:
I've installed mingw32 package and dependencies:
$ sudo apt-get install mingw32
I've installed Eclipse Mars for C/C++ development (manually, to keep this installation isolated from other Eclipses I have) and created a new project in this way:
- New C++ project.
- [...]
- Cross-prefix: i586-mingw32msvc-
- Cross path: /usr/bin/
With this configuration I'm able to correctly build a .exe which I can successfully execute on Windows, but when trying to debug it or execute it under Eclipse I get this error: "cannot execute binary file".
Googleing I've seen some posts suggesting to use wine in order to execute the .exe, but I thought mingw32 would be able to execute it. Am I wrong and this is not possible or just doing something wrong?
Mingw32 is a windows compiler, and will compile source to a Windows executable file. Additionally, the compiler cannot execute files (as worded in the question), it just compiles the source code to an executable form, in this case the windows executable (*.exe). So yes, in order to run the .exe in Ubuntu you would need something like Wine which emulates a Windows environment
mingw is a set of GNU tools for building native Windows executables.
It does not execute anything.
If you really want to cross-compile for Windows, you need Windows or an emulator for the execution.
To build for Ubuntu you can just use the native compilers.
sudo apt-get install gcc

How to tell make to use mingw32 instead of gcc

I'm trying to build wkhtmltopdf for Windows on an Ubuntu box. I haven't done much with cross-compiling in the past, but I have installed the Mingw32 compiler and am having trouble figuring out how to build qt to target Windows instead of Linux. Right now I am not sure how to tell ./configure to use Mingw32 to build a windows version of Qt when I run make. Can anybody shed some light on how to do this?
I have tried building wkhtmltopdf on Windows in the past, but got stuck at the step where you need to run qmake after building Qt, which is why I am trying to build on a native linux environment instead.

Manual for cross-compiling a C++ application from Linux to Windows?

Is there a manual for cross-compiling a C++ application from Linux to Windows?
Just that. I would like some information (links, reference, examples...) to guide me to do that.
I don't even know if it's possible.
My objective is to compile a program in Linux and get a .exe file that I can run under Windows.
The basics are not too difficult:
sudo apt-get install mingw32
cat > main.c <<EOF
int main()
{
printf("Hello, World!");
}
EOF
i586-mingw32msvc-cc main.c -o hello.exe
Replace apt-get with yum, or whatever your Linux distro uses. That will generate a hello.exe for Windows.
Once you get your head around that, you could use autotools, and set CC=i586-mingw32msvc-cc
CC=i586-mingw32msvc-cc ./configure && make
Or use CMake and a toolchain file to manage the build. More difficult still is adding native cross libraries. Usually they are stored in /usr/cross/i586-mingw32msvc/{include,lib} and you would need to add those paths in separately in the configure step of the build process.
It depends on what you mean (I couldn't really say).
If you mean that you want to use an existing Linux application on Windows, then you could try compiling it using Cygwin on Windows. This however does not give you a Windows executable free from all dependencies towards Cygwin (your executable still depends on the cygwin.dll file) - and it still may need some porting before it will work. See http://www.cygwin.com.
If you mean that you want to be able to perform the actual compilation of a Windows application on Linux and produce a .exe file that is executable on Windows - thus using your Linux box for development and/or compilation then you should look into MinGW for Linux which is a tool for crosscompiling for Windows on Linux. See http://www.mingw.org/wiki/LinuxCrossMinGW.
Best regards!
I suggest you give the following, GUB (Grand Unified Builder) a try as it cross-compiles several packages with their dependencies and assembles them into a single installation package for currently 11 architectures. You can download a prebuilt iso for installation in a VM from here and follow the source here. It can currently be used to cross-compile GNU LilyPond/ GNU Denemo / Inkscape and OpenOffice.org.
The target architectures are:
darwin-ppc - tar.bz2 file for Darwin 7 (MacOS 10.3)/PowerPC
darwin-x86 - tar.bz2 file for Darwin 8 (MacOS 10.4)/x86
mingw - mingw executable for Windows32
linux-x86 - shar archive for Linux/x86
linux-64 - shar archive for Linux/x86_64
linux-ppc - shar archive for Linux/PowerPC
freebsd-x86 - shar archive for FreeBSD 4/x86
freebsd-64 - shar archive for FreeBSD 6/x86_64
cygwin - .tar.bz2 packages for Cygwin/Windows32
arm - shar archive for Linux/ARM (largely untested)
debian - shar archive for Debian (largely untested)