Cross compiling on mac for windows - macos

Can I compile on mac so it will produce a windows binary? bind with windows dlls? (I have a windows machine to copy them from) How can I do so? clang and gcc are the compilers I can use.

These instructions will work on both MacOS and Linux, but I will provide them from a Mac perspective.
Download Docker
Add a Windows dockcross
If you don't know how to use docker then just download Kitematic (Links to an external site.).
From Kitematic you can simply click the "+New" button and get the dockcross image from the docker hub.
After the image downloads in Kitematic, click the "Docker CLI" button in the bottom left. This will open a new terminal window setup for the docker environment.
From that terminal window:
cd to the directory with the project you want to build then save a shellscript that will run the docker container and build the project:
docker run --rm dockcross/windows-x86 > ./dockcross
chmod +x ./dockcross
./dockcross make (assuming your project uses a makefile)
See the dockcross documentation for more examples and further guidance.
dockcross uses MXE, so you can pretty easily build most projects, but you may need to install additional MXE packages

The MinGW's toolchain can be built on OSX or most other unix/unix-like operating systems.
Here's a link to the precompiled binaries: http://crossgcc.rts-software.org/doku.php?id=mingw-older-releases
It works fine on my PowerMac G5 and as keith.layne says there is also a solution for Intel Macs.

Related

Docker Desktop installation on windows 7 is not working

I've downloaded docker desktop from the website but was unable to open the installer.
My operating system is windows 7.
What are the steps required to install docker desktop on windows 7?
Docker Desktop is not supported on windows 7, you can use Docker toolbox instead.
Do following steps:
Install hyper-v
Install Docker Toolbox and try to follow link instructions
Run Docker Quickstart as admin.
After following above steps, you may not be able to run Docker Quickstart Terminal properly. If so, follow below steps:
Go to window's Start.
type: Environment
click: Edit the system environment variables
Make sure you have VBOX_INSTALL_PATH (should point to VirtualBox installation folder. i.e. C:\Program Files\Oracle\VirtualBox)
Make sure you have VBOX_MSI_INSTALL_PATH (should point to VirtualBox installation folder. i.e. *C:\Program Files\Oracle\VirtualBox*)
Make sure you have VBOX_USER_HOME (e.g. C:\Users\Sara.VirtualBox)
Make sure you have DOCKER_TOOLBOX_INSTALL_PATH in your User variables (i.e. C:\Program Files\Docker Toolbox)
Restart your computer.
Try Running Kitematic. If its not working and you are receiving an error about "default" already existing or config.json missing, do the following:
close Docker Quickstart Terminal if open.
open task manager -> processes.
End process VBoxHeadless.exe
add an empty config.json file manually in %userprofile%.docker\machine\machines\default if config.json is missing.
Run in CMD: docker-machine rm -f default
Run in CMD: docker-machine create -d virtualbox --virtualbox-memory 2048 default
If the above CMD commands failed:
delete folder %userprofile%.docker\machine\machines\default manually
restart computer
run Docker Quickstart Terminal as admin
folder %userprofile%.docker\machine\machines\default should have been created properly at this point.
open kitematic. UI should be presented properly
Problem with "default" project
Failure on "default"
As far as I know, Docker desktop require Windows 10.
https://docs.docker.com/docker-for-windows/install/
System Requirements
Windows 10 64-bit: Pro, Enterprise, or Education (Build 15063 or later).
You will need Win10 pro to install Docker on PC, but otherwise you can still install Docker on PC by downloading Docker Toolbox for Win7,8,10. Link to download Docker Toolbox at:
https://www.softpedia.com /get/Programming/Other-Programming-Files/Docker-Toolbox.shtml

Prometheus pre build binary for Mac OS X

I am trying out Prometheus on Mac OS X. I looked up the downloads and not having a direct indication of which version is for Mac. I tried docker to run the Prometheus on Mac. Just want to run it directly on Mac without docker. Does any one know which version to pick.
There were few BSDs there for pick. I know Mac is also BSD. Not sure which one matches or doesn't matter as long as it is bsd?.
Other than those binaries, I think brew install should do the work
The downloads page has a build for Darwin on amd64.
To quote the wikipedia page:
Darwin forms the core set of components upon which macOS (previously
OS X and Mac OS X), iOS, watchOS, and tvOS are based.
This is the official binary for OSX. Other methods (such as brew install prometheus are also available).
Install and download Docker from this link - https://docs.docker.com/v17.12/docker-for-mac/install/#download-docker-for-mac.
You can launch the your terminal.
You can launch a Prometheus container for trying it out with
$ docker run --name prometheus -d -p 127.0.0.1:9090:9090 prom/prometheus
Prometheus will now be reachable at http://localhost:9090/.

How to run eclipse on bash on Ubuntu on Windows?

I have eclipse installed on my windows machine, but I can't seem to use it with bash so I installed eclipse on the bash terminal by using "sudo apt-get install eclipse". It installed fine, but I can't figure out how to launch the eclipse GUI from the linux subsystem so I can use it like the windows version. I tried using Xming and exporting DISPLAY, but that didn't work. Any ideas?
from what i understood from the link below, you require to update .bashrc to direct the GUI display to a X Server process. I installed xMing to run X Server from Windows 10. i also had to install gtk components that allowed me to run sublime text GUI from within WSL.
https://medium.com/#pck/how-to-use-sublime-text-3-from-command-line-with-ubuntu-bash-terminal-in-windows-10-subsystems-for-aa2ad59d088c
hope this helps
IMHO you should not install eclipse by apt but simply get your desired eclipse product from from https://www.eclipse.org/downloads/packages , download and unzip it to your wanted location and just start eclipse.
Reasons:
I do not know any Linux distribution containing a newer eclipse bundled, so you are always having older versions being slower and having less features
You can update your eclipse installation directly inside eclipse Check for updates
You can have multiple installations at same time
If you want to get rid of a eclipse installation just remove the folder and you are done.
But of course you can also use bash directly in Windows with Eclipse.
Please look at
https://stackoverflow.com/a/62724163/2590615 or take a glimpse at You Tube Video about Bash Debugging with Bash Editor eclipse plugin on a Windows 10 machine
PS: I am the maintainer of the mentioned eclipse plugin

How to initialize and run Docker on windows?

I have Docker installed on Windows 7 platform. However when I try to run boot2docker start, the console gives me:
Failed to get machine 'boot2docker-vm': machine does not exist.
Ok, so I try to initialize the machine: boot2docker init. What now happens is even though I have the ISO image on the same path as docker, it tries to download a new image (and then fails to do so).
I uninstalled both OracleVM and GIT before installing them with boot2docker bundle as advised on Docker forums, but now I don't know how to proceed.
I had the same problem on a Windows 7 64 bit system when I installed the entire boot2docker package. It seems that running the solely 64-bit based boot2docker image from a 32-bit OS image (e.g. created by Virtualbox) does not work.
The solution for me was
to activate Intel Virtualisation Technolologies in my BIOS
(Lenovo X61 for me). Note that the settings can be found either
under CPU or Security.
choose a 64 bit OS version in VirtualBox and boot in with the
image obtained by boot2docker.
In case you're trying to do this now
For Windows 10 64-bit: Pro, Enterprise, or Education (Build 15063 or later), follow the instructions to install Docker Desktop here https://docs.docker.com/docker-for-windows/install/.
If you have Windows systems that do not meet the requirements of Docker Desktop for Windows(in my case Microsoft Windows 10 Home Single Language), you can install Docker Toolbox by following the instructions here https://docs.docker.com/toolbox/toolbox_install_windows/.
boot2docker does not support sharing directories on Windows IIRC. The way I run Docker on windows is:
install VirtualBox
install Vagrant
create a directory (let's say c:\vm\docker)
download this Vagrantfile and save it under c:\vm\docker\Vagrantfile
open a DOS command prompt
go to the directory cd c:\vm\docker
start the VM vagrant up and wait for it to install, start up and get provisionned
connect to the VM vagrant ssh
play with docker docker images, etc
Also you might want a real console instead of using the DOS command prompt:
install Git Bash for Windows
install Console
setup Console to use Git Bash (see this guide)
use Console to run the vagrant up and vagrant ssh commands

How to cross compile from Mac OS X to Linux x86?

I'm running Mac OS X 10.5.8 and want to compile for target CentOS 5.3 with GCC 4.1.2. How could I:
Compile GCC 4.1.2 toolchain and related tools?
Use that tool to cross compile for target CentOS 5.3?
Any help is greatly appreciated!
Your simplest solution is to just run CentOS 5.3 in a VM (e.g. Sun VirtualBox). This requires minimal setup, has quite reasonable overhead (assuming an Intel Mac), and you'll be able to actually test and debug what you are building.
If you really insist on cross-compiling, you must build a cross-compiler. Instructions are here and here, but beware: it will likely take you several days to get it right, and then you'll still need a VM to test the result, so I don't see any point in doing it that way.
Nowadays you can probably do it with Docker for Mac, I didn't test it because I have no mac. Docker basically creates a Linux VM and provides some nice-to-have functions.
Install docker and prepare your build image.
install docker
start a new container with docker run -ti centos5.3 /bin/bash (search the official Docker Hub for your desired target)
install your desired gcc version (something like sudo yum group install "Development Tools")
exit your container
run docker ps -a to obtain your container id
backup your container as base build image docker commit [id] centos:build
Make a build
Now you can use your created build environment for CentOS builds.
to start your build environment while mounting the working directory inside it you can use something like docker run -it --mount type=bind,source=$(pwd),target=/mnt centos:build /bin/sh -c "cd /mnt && bash"
then run gcc ... or ./configure or make or ninja or whatever to do your build
you can also run automated tests here if you wrote some
Docker vs VM
With docker you can use your beloved terminal with your familiar theme and keymap. Furthermore it most probably will consume less resources for startup and while running.
If your app is graphical and you test it by using interaction with its GUI I guess a VM is still a better option (see #employed-russian's solution).
Use Cocotron to cross-compile directly from Xcode. There's a good getting-started guide here: http://blog.tlensing.org/tag/cocotron/
I struggled to get crosstool-ng to build on OSX 10.9 for x86_64 Linux. I used the very helpful post on how to build a gcc cross-compiler by Jeff Preshing and his script here as the basis for a script that worked for me. His script in the link doesn't work when compiling glibc on my version of OSX (which seems to be a very common complaint for those cross-compiling from OSX to Linux).
My script is here: https://github.com/johnlondon/Cross-compile-toolchain-for-linux-on-OSX
You can use crosstool-ng, or if you don't want to spend too much time to configure it, you can download a pre-configured cross-compiler, as Linaro.
Here's the guide for installing it in Mac OS X.

Resources