I'm new to cygwin but I am having a bit of a trouble.
I have Linux ELF compiled binary file, and is there a way to lunch it under cygwin a simple way, like windows binary for example .\a.exe
from https://www.cygwin.com/
Cygwin is not:
a way to run native Linux apps on Windows. You must rebuild your
application from source if you want it to run on Windows.
If you want to run a ELF binary you need a VM with Linux inside
Related
I got an executable file created with linux. I also have the files and libraries that created this exe linux file.
Two questions:
Is there a way to run this linux exe in windows or it has to be done with linux?
The files are from around 15 to 18 years ago. If can't run it from windows, would linux be able to run it even if the files are somewhat old?
Could someone advice? Thanks
You can use WSL available on Windows 10 and 11.
You can also setup a Linux virtual machine using Virtual Box, Hyper-V, VMware Workstation Player, or any other virtualization solution, copy your files to the VM and execute there.
Another option is to install and use Docker. With docker you could run a command like this: docker run -it --rm -v $PATH_TO_EXE_DIRECTORY:/app ubuntu:latest /app/name_of_your_exe from command line.
Will it actually run if it's old? Your mileage may vary. It depends if it's a statically linked executable or dynamically linked executable. Statically linked executable may run, or may complain about incompatible kernel version (I've seen it once). Dynamically linked executable may fail to run due to missing dependent libraries or incompatible versions.
To check if the file is dynamically linked you can use Linux file command file name_of_your_exe, it will print the information regarding the data in the file, including whether it's dynamically or statically linked. To investigate the dependencies you can use Linux command ldd name_of_your_exe which will print the list of libraries (.so extension per Linux convention) your executable is dependent upon.
Your best option to ensure that it will run is to try and figure out which Linux distribution and version it was intended for and find its VM image or installation media online (it should still be possible, IMO), setup a VM and try to run it there.
I have been wonder about why x86(windows) to arm(linux) cross compile is possible but x86(windows) to x86(linux) cross compile is impossible or difficult only can use cygwin
As below link there is some cross-compiler for windows to arm from personal pc(x86), but there is no cross-compiler x86 to x86.
http://gnutoolchains.com/beaglebone/
why window(x86) to Debian(ARM) is available without cygwin , but window to Debian(x86) is difficult or must use cygwin?
Is this issue caused by POSIX size problem? The library size of Debian in ARM is little bit smaller than x86 ones?
I confuse....
I want to anyone clear to me.
Thank you for reading.
I installed WSL and then Debian as an Windows-App
directly under my Windows10 Home Edition.
Now I can open a Linux command prompt in every directory I want.
Installed g++ with apt-get (changed to root with "sudo su").
Using Mingw64 command prompt from the Git-Bash I can even use the same shell script
to compile console apps as Linux and Windows executables!
I generate an executable file on macOS and now I want to run it on Linux.
I already have my Makefile and I use that to make the executable file on macOS(using gcc). But when I run it on Linux, I got an error message: "./executable: cannot execute binary file". Can anyone help me with solving this problem?
You will have to compile the executable again on Linux in order to create a binary that runs on Linux.
Unless you setup a cross-compile environment for Linux on MacOSX (using Linux in a Virtual Machine will be easier though), then you could compile for Linux there.
Either way you will end up with 2 different binaries. You can't create a single binary that will run on both Linux and MacOSX.
I am developing a software in C++ on windows 32-bit (using MSVC++), but since I want to be able to use my software on every platform, I have decided to use CMake as my build generator.
Therefore, I am still just a beginner in CMake. From the CMake tutorials, I understand that in order to cross compile codes, first a toolchain simulating the target platform should be installed on the host platform. Then using the appropriate target-platform C and C++ compilers provided by this toolchain, CMake would be able to generate makefiles etc.
Now, I want to build my code for Linux platform(GNU/Linux) on a Win32 platform. I tried doing the above procedure using CMake combined with Cygwin and using gcc and g++ as compilers. It built fine, created makefiles, and when I issued "make" in Cygwin terminal, the generated makefiles were "made". Now I have got an executable which I was hoping would run on Linux platform. But on Linux I get the error: bash cannot execute binary file.
Using command file executablename, I realized the executable which is made by the above procedure is of type PE32 which is only for Windows.
Now my question is: Is my understanding of cross-platform build procedure using cmake correct?Or should I just use another Linux toolchain under windows to get a Linux ELF executable? What toolchains come to your mind which would give me what I want?
Many thanks
Setareh
You will want to look here: cmake-toolchains(7) if you do cross compiling. However, I would suggest that you install a Linux VM like virtual box on your windows machine and build naively on Linux. It will compile much faster and you will not have to worry about cross compiling. You can mount the windows disk from the linux VM so you can share the same source tree. The linux VM will compile much faster than gcc running under windows.
Your understanding of CMake is correct... it will determine how to create the build system you request (or is default for the platform you are currently on) based on rules in your CMakeLists.txt file. However, this won't necessarily help you compile for linux on a windows machine if you don't have something installed that can target linux.
To compile targeting linux, you will need to use a linux compiler. The link posted by #stjin tells you how to install one on cygwin. Then, to set up your CMake build, do this in the terminal:
CC=gcc-linux CXX=g++-linux cmake . [options]
This will tell CMake to locate the special linux targeted compilers. Hopefuly, after compiling with these compilers you will be able to run on linux.
i have gcc installed on my linux machine and i have my xcode project on my linux machine.
now is there anyway i can generate a xcodebuild using gcc on linux machine?
Very unlikely - the project file is designed for the sole use of Xcode and its command line friends. You are better off creating a Makefile for use under Non-Mac systems; this will be much quicker that trying to determine how the Xcode project file is structured and how to use the information contained within it.