In Cygwin a search for g++ shows:
gcc-g++
mingw-gcc-g++
mingw64-x86_64-gcc-g++
What are the differences between these?
Binaries built with Cygwin's gcc-g++ link against cygwin1.dll which is an implementation of the POSIX API for Windows.
mingw64-x86_64-gcc-g++ is instead part of the Mingw-w64 toolchain which builds native Windows applications that do not depend on Cygwin. The mingw-gcc-g++ on your system is probably either a symlink to this, or is the version that produces 32-bit binaries.
You can verify this difference by inspecting the import tables of a "hello world" program built with each using objdump -x hello.exe.
Related
I have a Fortran program(.f) that I have written in Ubuntu Linux. I compiled the written Fortran program in Linux by using the below command and it it successfully executed.
gfortran -o program program.f
Now I want to execute the same Fortran program in Windows 10 Can it be executed in window system? If so please suggest me a way to do it.
I tried gfortran -o program program.f in Windows command window,but it fails.
To compile Fortran code for Windows you need a Fortran compiler for Windows. Microsoft neither provides a built-in one nor offers one for sale. Third-party compilers are available, including gfortran, but you'll need to install one yourself. If you want to use gfortran in particular, or if you like it simply because you don't have to spend money to get it, then I would recommend obtaining it as part of mingw-w64. Alternatives are available from multiple vendors, some free of charge, but most for sale.
Note also that Windows expects executables to be named with an .exe extenstion, so you would want to use a variation on gfortran your compilation command:
gfortran -o program.exe program.f
If you want to use gfortran on Windows, I suggest you install MSYS2, which has a bash terminal, and a package manager that can install gcc and gfortran, as well as lapack and many other libraries.
There is also a separate distribution of mingw-w64 that can be installed without MSYS2, but I don't recommend it, as the last files there have gcc-8.1.0, from 2018 (apart from a recent build by Ray Linn that includes the Ada, but not the Fortran compiler).
Another compiler that is now free is Intel Fortran : you have to install Microsoft Visual Studio Community, Intel oneAPI Base Toolkit and Intel oneAPI HPC Toolkit. More information here. Available on Linux, macOS and Windows (of course, Visual Studio is needed only on Windows). Intel oneAPI is at least partly open source, not sure about the Fortran compiler.
MSYS2 is a much smaller package (in terms of disk pace needed), and is used by several other free projects: R (Rtools), Octave and Strawberry Perl all include parts of it, including the gcc compilers.
It's possible to use code (and libraries) compiled with VisualC++ (so with .lib extension) in a project that will use GCC as compiler (and vice versa)? Or I have to rebuild them?
I'm trying to use SOCI 3.1 libraries that I have compiled with VisualC++ in a project that has GCC as compiler, but I'm getting some errors, and I don't know why..
You have to produce binaries for GCC using MinGW tools: reimp and dlltool. Here is MinGW wiki with complete explanation of the procedures: MSVC and MinGW DLLs
Short example:
reimp -d libmysql.lib
dlltool -k --input-def libmysql.def --dllname libmysql.dll --output-lib libmysql.a
reimp libmysql.lib
By the way, here is related thread on SOCI users mailing list which: MySQL Build fails. Look for useful links given in the thread.
How can I install gcc on a system that have not any c compiler?
this system is a linux base firewall and have not any c compiler.
I guess you a have an appliance running Linux and shell-access, but neither a package manager nor a compiler is installed.
So, you need to cross-compile gcc and the whole toolchain (at least binutils) - this is quite simple, because the ./configure scripts of gcc, binutils, gdb etc. support cross-compiling with the --target= option. So all you have to do is to find out the target architecure (uname helps) and then download, unpack the gcc sources on a linux-host and run ./configure --target=$YOUR_TARGET.
With this, you now can build a cross-compiler gcc - this still runs on your host, but produces binaries for your target (firewall appliances).
This may already be sufficient for you, a typical desktop PC is much faster than a typical appliance, so it may make sense to compile everything you need on the Desktop PC with the cross-compiler and cross-binutils.
But if you really wish to do so, you can now also use your cross-compiler to compile a gcc running on your target (set this as --host= option) and compiling for your target (set this as --target option).
You can find details about allowed host/targets and examples in the gcc documentation: http://gcc.gnu.org/install/specific.html.
It depends on the distribution, if it's based on debian or some other of the big ones you can install gcc through apt-get or similar tool.
If it's a more basic system you need to compile gcc yourself on another computer and copy it over. It will be easiest if you have another computer with the same architecture (i386, arm or x86_64 for example).
I think that you might want to compile it statically also, so that you don't have dependencies on external libraries.
How do you plan to get all the source code needed for GCC loaded onto your machine? Could you mount the ISO image onto this machine and install from there?
Since you are using Endian Firewall, see "Building a development box" at the following link:
http://alumnus.caltech.edu/~igormt/endian/tips.html
If it's a debian based distribution, you can use
sudo apt-get install gcc
Note: maybe you must change "gcc" by a specific version of the debian package.
I have Cygwin and MinGW (TDM) installed. To build certain projects from source, you have to run a ./configure script, which requires a bash shell and certain unix utilities. For this, the MinGW project distributes MSYS, which is basically an old, stripped-down version Cygwin. I already have Cygwin installed, so I'd rather just use that. What packages would I need to install for Cygwin and how would I need to invoke ./configure so that it knows that I'm trying to use MinGW to build native Windows binaries?
You are aware that Cygwin comes with a MinGW-compiler and library built in? By using the -mno-cygwin switch you turn the Cygwin gcc into a MinGW gcc. How you'd tweek ./configure to use this is beyond me, but I suppose it would depend on the ./configure script.
What I do is usually to tweek the generated Makefiles by adding the -mno-cygwin switch to the compiler and linker flags.
What is the difference between
MinGW cross compiler and
GCC Cross compiler.
Which one used in which operating system?
I need to create an EXE file in the Linux operating system using Qt, hence which is the cross compiler to be used?
MinGW is a GCC cross compiler for Windows environments. (There are multiple GCC cross compilers for various different targets.)
To compile Windows executables on your Linux box, you want a MinGW install for your distribution of Linux.
If you're running
Debian, you want http://packages.debian.org/lenny/mingw32 (apt-get install mingw32)
Ubuntu, you want http://packages.ubuntu.com/jaunty/mingw32 (apt-get install mingw32)
Red Hat Linux or CentOS, you want several of the MinGW packages from http://download.fedora.redhat.com/pub/epel/5/i386/repoview/M.group.html (see EPEL how-to then yum install mingw32-binutils and mingw32-gcc-g++ at minimum)
Gentoo, see http://www.gentoo-wiki.info/MinGW
openSUSE, then you can find builds at http://download.opensuse.org/repositories/CrossToolchain:/mingw/
MingW32 is a port of GCC with "win32 target".
There are two architecture in a cross-compiler: host and target. The host is the platform the compiler run on; the target is what the result code will run.
Assume you are using Ubuntu, you can see the package here.
MinGW is basically a port of GCC and related tools, allowing them to run natively on Windows machines.
Cross compiling is the act of using a compiler on one operating system/architecture to generate a binary/EXE/DLL/object that is compatible with another operating system/architecture. Basically, you ask the compiler to generate assembly and startup routines for something other than the host OS's default.
If you were on a Linux machine, you'd use GCC to compile it for the Linux machine... If you were on a Windows machine, you'd use MinGW, but with flags to tell it to compile for the Linux machine's specifications.
GCC is usually used in Linux.. MinGW is just a Windows port of GCC to compile source to EXE files.