Cygwin: How to actually use gcc-mingw - gcc

Since "gcc -mno-cygwin" does not work anymore, I was looking for a way to get a MinGW-targeted GCC running within my Cygwin environment. (Running a MSYS environment is not an option at this point.)
The Cygwin installer offers a package "gcc-mingw", which installs, among others:
lib/gcc/i686-pc-mingw32/3.4.4/cc1.exe
lib/gcc/i686-pc-mingw32/3.4.4/collect2.exe
lib/gcc/i686-pc-mingw32/3.4.4/crtbegin.o
lib/gcc/i686-pc-mingw32/3.4.4/crtend.o
What is absent is the "gcc" frontend. So, how do I actually invoke this compiler? I hopefully don't have to go through "cc1" manually, have I?
I googled, but couldn't find anything relevant on the subject...

As you already found, you can use gcc-3 with -mno-cygwin. The other possibility is to install the 32-bit and/or 64-bit toolchains from the MinGW-w64 project, which have been packaged for Cygwin very recently and hence are available through setup.exe now. Don't be put off by the rather confusing executable names: i686-w64-mingw32-gcc is the 32-bit compiler and x86_64-w64-mingw32-gcc is the 64-bit one.

Further searches revealed that the MinGW-targeted cross-compiler is not ready yet, and that one has to either use GCC v3 with -mno-cygwin, or install a cross-compiler manually (see link above)...

After installing the MingW g++ package for Cygwin (mingw64-x86_64-gcc-g++), I also struggled to figure out how to invoke it.
Thanks to this wiki, I found out the command was x86_64-w64-mingw32-g++. Then I did alias g++='x86_64-w64-mingw32-g++' and g++ started working as expected.

Cygwin homepage says that "Individual packages like bash, gcc, less, etc. are released independently of the DLL.".
Here you can find how to install gcc under cygwin, so you should also select gcc package during install not only gcc-mingw.

Related

CLion Installation: Cmake compilers not found, GDB not found

I'm switching from VS to CLion and they said I needed to install Cygwin and CMake. I then installed both of them. I tried use bundled, but CLion still gives me these errors make: not found C Compiler: not found C++ Compiler: not found GDB: not found.
I have installed CMake under the path C:\Users\Gaga\Downloads\cmake-3.4.1 but I don't see a cmake.exe, the closest thing is cmake.cxx.
Without these I'm not able to compile anything, please help
In the "Use specified" field I put C:\cygwin64\bin\cmake.exe your path may be different. Just ensure you have CMake, Make, gdb and gcc installed already in Cygwin (using the Cygwin setup.exe not via the CMake website) but I believe Clion checks if you have them installed after inputting the path.
The workaround would be to use MinGW. If you download it from the website it should come with cmake, and take care of the errors.
http://mingw.org/
When extract it and go to the installer you should check something like gcc and then from the top left corner something like 'install packages'
Be sure not to accidentally download the source, which I did, which would lead you toward this error: CLion: CMake Errors Source directory does not exist
Edit: So over a year later, I've learned a little more about Cygwin and mingw beyond what the internet says. CLion needs a "Unix-like" environment. If you use CLion on MacOS or a Linux it's already Unix based. Anything that is "POSIX" compliant will work. CygWin is a terminal emulator for windows where Unix commands like mkdir work. MinGW is something similar but not posix. Comes with GCC tho. I'm still a noob.
I had the same problem.
While installing cygwin, need to select the packages of cmake, gcc, gdb
Got the answer from the below link.
Select Packages while installing cygwin
After the installation go to the configuration page and select the cygwin directory. CLion will identify the configuration and you are done...

Compiling Ghostscript 9.10 using mingw

I am using msys2 Mingw (gcc 4.8.2 for i686 32-bit) for building Ghostscript 9.10. After running make, gs.exe was created successfully. Followed by that I ran "make so" for creating libgs library. Libgs.so, Libgs.so.9.10 were created which are of the same file size. But I found both of them to be PE executables. After renaming extension to .exe, they produced the same output as done by gs.exe. What I require is libgs.dll, libgs.a to be created, but instead "make so" creates libgs.so which is in fact a PE executable. I also tried using patch found on site:https://github.com/Alexpux/MINGW-packages/blob/master/mingw-w64-ghostscript/mingw-build.patch, but still the output remains the same. Has anyone been successful in this? Kindly help me.
I presume if you follow the steps taken in the build script connected to the patch you linked, everything will work out fine. I think most of it is just to make it use the "system"'s 3rd party libraries instead of those in the GS source. I'd guess running the configure command would do.
Alternatively, you could just download the MSYS2 base system from here, and do a pacman -Syu mingw-w64-i686-ghostscript. It should download and install the binary package without you having to build it yourself.
If you really want to build it yourself, download the PKGBUILD and patch, and run makepkg from the aforementioned MSYS2 shell and have that build it for you.
Have just completed testing of gs 9.15 built executables using the a patch
MINGW-packages-master.zip from https://github.com/Alexpux/MINGW-packages
Without implementing the zlib patch and PKGBUILD and using a MINGW 4.7.3 32/64
without by ghostscript used libs installed.
They did not work as is while using msys1 pathe'd up ahead of Windoze.
I simply edited the the MINGW Build and 32/64 bit type in makefile in
and set them to =1 there. and as i built without GTK defined in ./configure
SOC_LOADER_PLAIN manually to gs.c
Check the makefile after ./configure ahead of make or make so though , , .
All went well except for the COMPILE_INITS
mkromfs build that failed so I had to set that to =0 and build without that
feature. For me personally preferred as one can patch the gs fonts and libs
much easier.
The builds run as charm with full cpu optimisers implemented
only disabling gcse and guess-branch-probability, easily outperforming
the binaries provided by http://www.ghostscript.com/ by all means.
HPC !

How can I setup linux to compile FORTRAN code into windows binaries?

I'm working on a FORTRAN project and I would like to build all of the binaries that I want to maintain on a linux machine that is dedicated for automated builds. I have successfully used mingw to build 32-bit and 64-bit binaries from C source for windows machines on the linux machine with the following packages on Ubuntu.
apt-get install mingw32
apt-get install mingw-w64
Then I run the following commands to actually compile:
gcc -b amd64-mingw32msvc -V 4.4.4 -o <...other options>
However, the mingw packages that I've obtained via apt-get do not include FORTRAN compilers.
Anybody got any ideas on what I can do?
if you got mingw32 and the Gnu C cross compiler is working for you ... when why not just get the Gnu Fortran cross compiler, too?
http://www.nber.org/sys-admin/mingw32-fortran-fedora.html
EXAMPLE apt-get install mingw32-gcc-fortran
I know this is an old thread but a few things seem to have changed and people might still be interested in the topic.
Problem: I want to use my linux machine to compile some code and create a .exe that I can send to people using Windows.
Solution: Essentially here: http ://mxe.cc/
What I did:
Check to see if your system has all the software you need here
run
git clone -b stable https://github.com/mxe/mxe.git
It will download a few small things and create the directory "mxe" (probably in your home folder)
cd into that mxe directory and run "make". HOWEVER: this would take hours and take up a few GB on your hard drive so instead run something like
make mpfr eigen opencsg cgal qt
For more ideas on how to shorten that all see this or the mxe tutorial or somewhere else ;)
The easiest way to compile stuff then seems to be something like:
~/mxe/usr/bin/i686-pc-mingw32-gfortran -c main.f95
~/mxe/usr/bin/i686-pc-mingw32-gfortran main.o -o outfile.exe
Of course you can chose something other than fortran, just consult the mxe/usr/bin to see what its called.
You can always download and install a prebuilt compiler from the MinGW(-w64) project itself:
Windows 64-bit: http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/rubenvb/4.6.2-1/
Windows 32-bit: http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/4.6.2-1/
Just unpack somewhere and add the cross*/bin directory to PATH.
I include (obj)c(++) and fortran.
On Ubuntu 18.04 I use
apt install gfortran-mingw-w64
Then use the compiler x86_64-w64-mingw32-gfortran in place of gfortran. If you're using cmake, you can configure the compiler from the build directory like so:
FC=x86_64-w64-mingw32-gfortran cmake ..

how to install cygwin and mingw under windows 7?

I want to use gcc ( and g++ ) under windows 7.
I download cygwin ( setup file: setup.exe )...
So, what is packages really needed?! It suggests to setup very many packages, but i think that for developing in C++ not all of these is really needed..
gcc4-g++ for Cygwin programs
mingw64-i686-gcc-g++ for 32-bit MinGW programs
mingw64-x86_64-gcc-g++ for 64-bit MinGW programs
Setup.exe will select their dependencies such as gcc-core or binutils for you.
You'll probably also want make, and don't forget to pick an editor. Other packages in my minimum install: cygutils, diffutils, util-linux, inetutils, openssh, mintty.
If you would like to use only gcc and g++, I'd receomend you MinGW Distro designed by Stephan T. Lavavej.
Here is a direct link: http://nuwen.net/mingw.html to the Distro's main page. It contains currently the most up to date gcc and boost (4.7.2 and 1.52.0 respectively in version 9.5). It also contains make, git and couple more of useful tools.
Installation is really simple, you need only to extract zip-archive.
So, if you need Cygwin only to use GCC, I'd recomment you this MinGW Distro instead of Cygwin.
Greetings,

LLVM MinGW installation on Vista?

From llvm.org I've downloaded llvm-2.6-x86-mingw32.tar.bz2 into c:\llvm and llvm-gcc-4.2-2.6-x86-mingw32-tar.bz2 into c:\llvm-gcc as well as setup a desktop shortcut the following batch file in c:\llvm-gcc which attempts to setup an environment for compiling via the llvm-gcc command line too:
#echo off
color 0E
echo Configuring LLVM environment...
set LLVM_LIB_SEARCH_PATH=%~dp0lib
set PATH=c:\llvm;%~dp0bin;%PATH%
Unfortunately, this setup gives the following error when trying to compile a simple hello world program:
C:\CDev\sandbox>llvm-gcc -o hello.exe hello.c
llvm-gcc: CreateProcess: No such file or directory
I've briefly looked through the LLVM binaries and it appears that the MinGW-based Win32 API and runtime files are already included. I also tried adding the MinGW DLL to c:\llvm-gcc\bin to no avail.
What have I missed in setting up the binary LLVM environment and GCC-based front end on Vista?
Thanks, Jon
Because the GNU/MinGW assembler 'as' was required by 'llvm-gcc' to generate the obj file. The problem can be solved by using:
Install GNU/MinGW binutils, extract the as.exe into c:\llvm-gcc\bin
Install a full MinGW package, add %MinGW%\bin your %PATH%
#rwallace is correct that one needs to also install MinGW's binutils along with the LLVM binary download. I've updated the LLVM documentation appropriately at
http://llvm.org/docs/GettingStarted.html#installcf
As far as I can tell, the answer is that the MinGW distribution supplied by LLVM is not complete, in particular, it doesn't come with the 'binutils' programs.
The recommended solution seems to be to download and install MinGW yourself. However, the MinGW download page seems to be saying this requires 10 different packages to be downloaded and installed separately.
The solution I tried today was to use the MinGW that comes with Qt, which does come in a single package; thus far, that appears to work.
It seems like it is looking for the base MinGW installation in C:\MinGW. I just had this error today using gcc.exe in msys. To solve it, I created a symbolic link from c:\msys to c:\MinGW and everything worked.

Resources