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,
Related
I installed Mingw64.
Then I set up Codeblocks by updating the toolchains executables fields in Settings/compiler.
I was able to run a "Hello world" program.
In the task Monitor the exe is marked "*32"
So it seems it's compiled in x32
(Inferred question: Using MinGW-64, expect to get 64-bit, got 32-bit)
It depends on what MingW-w64 toolchain you have.
You must either add -m64 to the commandline if you have a multilib toolchain, or you need to download a different one which says "targetting Win64" in its name. That is, anything that is found in here. You need to choose what threading and exceptions and such you want. Or, just use the installer.
There are about a dozen different combinations that you can download from the MinGW-w64 site. You need "hosted on Windows, targets Windows", and then either the 64-bit flavor if that is all you want, or the "multi" one, but in this case you need the extra commandline switch.
X32 does not exist under Windows, it's either Win-32 or Win-64.
The solution is to install Mingw64 from Msys2 then just change the compiler settings of Codeblocks so that it points to the Mingw64 folder.
Just copy and paste Mingw64 releases doesn't work in most of the time.
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 ..
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.
I have cygwin on windows through which I run gcc. But after creating .exe files, if I run them on other computers which dont have cygwin, it says cygwin1.dll not found. Is there a way to compile them so that they run on any system?
You need to compile for MinGW (Minimal GNU Win32) mode. You do that by either installing mingw instead of (or in addition to) cygwin, or by passing the --mno-cygwin compiler option to the cygwin gcc.
In your case, try to copy cygwin1.dll as well (but it could depend on other DLLs as well) (of course you must comply with Cygwin's license with regards to distributing cygwin1.dll)
In cygwin, you can always check the needed modules using:
objdump -p a.exe | grep 'DLL Name'
OR
cygcheck ./a.exe
or for windows in general, use something like this tool: Dependency Walker
You can try compiling with the command line option -mno-cygwin.
See the Cygwin FAQ.
From http://cygwin.com/faq/faq.html#faq.programming.win32-no-cygwin
How do I compile a Win32 executable that doesn't use Cygwin?
The compilers provided by the mingw-gcc, mingw64-i686-gcc, and mingw64-x86_64-gcc packages link against standard Microsoft DLLs instead of Cygwin. This is desirable for native Windows programs that don't need a UNIX emulation layer.
This is not to be confused with 'MinGW' (Minimalist GNU for Windows), which is a completely separate effort.
I've installed cygwin environment on Windows.
There is gcc 4.3. How to install gcc 4.4 in this environment?
The alternative is to build one yourself, but it will be extremely slow on cygwin. If you are a Linux user, you can build a native compiler (which runs in cmd.exe on windows, and produces native win32 binaries) on Linux. It is much faster (order of magnitude faster in my experience).
Otherwise, mingw is a good solution, although in my experience, the binary from equation.com work better for gcc 4.4 (there is no official gcc 4.4 from MinGW yet)
If you don't need the cygwin environment for special reasons, I'd go for Mingw with the gcc 4.4. You can find builds on: http://www.tdragon.net/recentgcc/.
Reading the MinGW FAQ, reveals that its possible to pass requests to use the MinGW binaries instead of the ones shipped with Cygwin.
For those who would like to use the Cygwin environment for development, yet generate non-Cygwin-dependant executables, a much easier option to "-mno-cygwin" does exist. Simply install Cygwin and the MinGW distribution in separate directories (i.e. "C:\CYGWIN" and "C:\MINGW"), and make sure that the "/bin" subdirectory beneath your MinGW installation comes before Cygwin's "/bin" subdirectory in your PATH environment variable (i.e. "PATH=%PATH%;C:\MINGW\BIN;C:\CYGWIN\BIN"). This will allow you access to all the UNIX tools you want, while ensuring that the instance of GCC used is the MinGW version. %%%
Bear in mind that within the "/etc/profile" file, Cygwin by default places "/usr/local/bin", "/usr/bin", and "/bin" ahead of your system-level PATH. Therefore, it is not enough to have the MinGW's "/bin" ahead of Cygwin in your Windows path... it must also be set to come first within the Cygwin environment (either by modifying "/etc/profile" or setting it manually).