Cross-compile from (open)Solaris to Windows? - c++

Is there any way I can cross-compile C/C++ code for Windows (XP, Vista, Win7), ideally in 64-bit as well as 32-bit (for Vista and Win7), from a Solaris or OpenSolaris setup? My codebase is already cross-platform, I would like to cross-compile it (generate windows DLLs and EXEs) from Solaris or Linux as part of an automated process.
I would like to use the GCC suite, and would rather not need to use the Cygwin DLLs, if possible.
If it is possible, which tools would I need in my Solaris environment? How would I go about compiling/linking an entire project?
If this is not possible in Solaris, how should I proceed from Linux, considering I would like 32- and 64-bit binaries for all of the versions of Windows I have mentioned?
Thanks in advance for any help!

I'm not sure if you want cross-compilation (creation of Windows EXE files on the the Solaris box) or cross-platform (code that compile on Solaris or Windows). The latter is easier, and to do it you should start by installing the MinGW version of the GCC compiler on your Windows box.

howto: Creating a cross Win32 and Win64 compiler

There is no 64-bit cross-compiler for Windows, you have to compile it using MSVC compiler :(

Er, why not just automate your build process by performing a remote build process? It's what we do - we have CruiseControl.NET on a Windows box which performs remote builds on Linux and Solaris via sshexec. I'm sure it would be possible the other way round.

Related

Is it possible to compile from Windows to Linux with gcc/g++?

Apologies for the beginner question.
In short I'm trying to compile a very simple C++ program for Linux from Windows 10. A few answers say "install cygwin" but I'm not sure it's the optimal solution. Would it be simpler to just install Linux and build for Linux from Linux and for Windows from Windows, or do cross-compilers already exist that could take care of the work for me?
Thank you
Edit: maybe my question wasn't clear. Essentially, I'm using VSCode on Windows. I have C++ code that I'd like to compile for Linux from Windows. I installed MinGW and it lets me compile Windows executables without issue. However I have no idea on how to compile executables for Linux.
You have several choices:
WSL.
WSL(Windows Subsystem for Linux) its linux termanal in windows, so you can compile linux code in windows. This solution is the simpliest and I would recommend to use it.
Visual studio.
Visual studio has a package that allows you to compile programs for Linux. More details here
The Linux and Windows libraries have some implementation differences. And also have different executables. Windows project may not work on Linux. But you can use the Visual Studio IDE with the Linux Developer Extension. Or can use WSL (Linux terminal for Windows) with Visual Studio Code (just install correct extension).
Compiling a very simple C++ program for Linux from Windows 10 can be done on a vanilla Windows 10 system by installing an Arm-provided, mingw32, toolchain:
Aarch32/Arm 32 bit:
gcc-arm-10.3-2021.07-mingw-w64-i686-arm-none-linux-gnueabihf
Aarch64/Arm 64 bit:
gcc-arm-10.3-2021.07-mingw-w64-i686-aarch64-none-linux-gnu
I'm sorry, I didn't quite understand the question. But when I start linux and try to make a C++ program. I started by trying to install the compiler through the terminal, then made a simple C++ program, and it worked. To begin with I visited this site :
https://linuxconfig.org/how-to-install-g-the-c-compiler-on-ubuntu-18-04-bionic-beaver-linux
Hopefully can help

Convert Unix Executable to Windows Executable

I compiled and ran a C++ program using Eclipse on my MacBook Pro. I now need to convert the Unix executable to a windows executable. How do I go about this? Specifally, how do I get this code to run on a Windows machine from the command prompt?
The only way you can get the unix executable to run on a Windows system is using a virtual machine (Something like VMWare or VirtualBox). This isn't REALLY running it on Windows, of course, it's setting up a UNIX system on Windows and running it on that UNIX system.
The executables (and the needed runtime environment) are vastly different between the two systems, you can't just run executables from one on the other.
Your only other option is to setup Eclipse on your Windows system and compile the application there.
You cannot "convert" an executable, you need to recompile for your target system. If you are using a GCC toolchain that is set up for Eclipse and there is no Mac specific code, it should be as easy as moving the project over, setting it up in Eclipse, and recompiling it. If that is too much of a hassle, you can consider setting up a Makefile and using MingW or Cygwin, or even Visual Studio if you'd like. If there is Mac specific code, then you need to look up the appropriate Windows documentation, or use something cross-platform like GTK+ or Qt.

C++ MinGW how to compile for Linx from Windows

I currently have MinGW for Windows and would like to develop for Linux(I have read that I need Headers), where would I get Linux headers and set up to compile both Windows and Linux programs with MinGW code::blocks.
Note: I have researched but could not find anything from Windows to Linux only Linux to Windows.
I do not exactly see what you mean by "develop", but if you want to work in an environment that produces binaries for some Linux system, you can not really "develop" because you cannot really run / debug them on Windows (when using cross-compilation).
On the other hand, if you want to develop code that compiles on Linux, you are already there. Since you are developing using MinGW, you are pretty much guaranteed that your code will compile under Linux with corresponding version of GCC. To produce a binary for the Linux distribution of choice, you can use VM, speed should not matter since you are not probably going to do it often.

How to compile C++ application for Unix/Linux in Windows

I have an application written in C++ using wxWidgets. How can I compile it for Linux and Unix os like Debian, FreeBSD, CentOS, in Windows?
Thanks!
Not entirely sure if I understood the question, but I think you are asking if you can compile an application for linux using a compiler in the windows environment.
My short answer: No, but.
The but: You may be able to use Cygwin in windows, however I think there is an easier way. If you are uncomfortable with setting up your computer to have multiple partitions and installing linux on at least one of these partitions, you can use VirtualBox, VMWare, or similar virtualization software to "install" linux on your windows machine. From there you can set up build environments and such. As for how, I would leave your windows build as is, but then in create a Makefile for Linux (or use CMake to replace both your windows-specific builder (the vsproj if using visual studio, etc) and linux-specific builder (make)) so that your source will compile both on windows and linux without having to modify the actual code or project.
i would recommend to use CMake as build system

Compiling for Mac/Linux on Windows

Obviously you can't really run Mac or Linux apps on Windows, but can you compile binaries for those platforms using MSVC++ for example (plugging in additional compilers and tools obviously)? For a serious build system, you don't want one build server per platform so having an automated build server which compiles for all target platforms seems quite a reasonable aim.
Crosstool-NG seems like your best option for Linux apps; they show that as one of the standard configurations. I do not know about Mac OS X; this question suggests that it will probably be difficult.
I would like to believe (notice my careful words) that GCC can be built to run on windows (any relevant form of the triplet --mingw*) and target another triplet.
A proof-of-concept for the non-believers is provided here, where you can find Win64 hosted compilers that build native linux binaries. I assume the same can be done for mac if the necessary libraries (like the CRT and necessary Mac framework libraries) can be built/used by that compiler.
if you want to build applications using C++, why not use Qt from Nokia. it's cross platform. http://qt.nokia.com/