target mingw with cygwin - c++

I've tried building the gtest 1.5 library for MinGW
Using MSys to configure and then make results in a lot of errors, most about Win32API
On their website it says mingw is not supported but in the FAQ it is specified that a user managed to build it for mingw from cygwin configuring like this:
./configure CC="gcc -mno-cygwin" CXX="g++ -mno-cygwin"
This configure fails for me when running a sanity check for the C++ preprocessor ... something about "/lib/cpp".
I've tried a cygwin install with only mingw-gcc4 (4.3.4) and a cygwin install with mingw-gcc4 (4.3.4) and cygwin's own gcc (~3.4.4).

Generally, the library could be smoothly configured and built with cygwin gcc (3.4.4) using the flags you have specified above. You should only validate that gcc-mingw, gcc-mingw-core & gcc-mingw-g++ packages are installed in cygwin. There is no need in mingw-gcc4

Related

How to setup CLion with portable Clang on ubuntu?

I want to test Clang with CLion in ubuntu. By default Clion detects my gcc installation, but I want to use clang instead of gcc. Moreover, I don't want to install clang via apt-get. I have downloaded llvm, clang (3.6.2) binary from llvm website. I want to use that portable clang binaries.
Here is my system setup:
Ubuntu - 14.04
gcc - 4.8.4
llvm clang - 3.6.2 (portable)
CLion - 1.0.4
So how to set up CLion with llvm-clang here?
I got the answer from CLion blog and it works and here it goes.
To provide CMake compiler paths, go to Settings | Build, Execution, Deployment | CMake and pass as CMake options:
-D CMAKE_C_COMPILER=
-D CMAKE_CXX_COMPILER=
In case CMake fails to find some path to clang libs, etc. you can also set there environment variables:
CC=/usr/bin/clang
CXX=/usr/bin/clang++
The FAQ states the following:
At present CLion supports GCC and Clang compilers and is guided by these two to get the libraries and headers paths. In the next releases we are planning to extend the list of compilers available in CLion.
To change the compiler, go to the Cache tab in CMake tool window and set the compiler’s path to the CMAKE_CXX_COMPILER variable. Then press Enter and click the Apply Changes and Reload button

mingw without g++ compiler

i am new to linux and I have the following question:
I am trying to install MINGW in Ubuntu.
I ran the command:
sudo apt-get install mingw-w64
It was installed, and if i put the command gcc it runs ok. The problem is g++ command does not work. I guess it is because i don't have the c++ compiler (as I read in similar questions in stackoverflow).
I read too that you can use the next command:
mingw-get install g++
but i don't have the executable program for this command.
My question is, how can I install that executable? or is there another way to update my mingw so I can use the g++ compiler?
Hope I have explained myself correctly. Thank you for any help I receive.
mingw-get is a windows specific package manager, it is not needed when you use a native linux package manager such as APT.
Installing package mingw-w64 depends on package g++-mingw-w64, which depends on g++-mingw-w64-i686 and g++-mingw-w64-x86-64.
These packages install the mingw cross compilers as
/usr/bin/x86_64-w64-mingw32-g++-posix
/usr/bin/x86_64-w64-mingw32-g++-win32
/usr/bin/i686-w64-mingw32-g++-posix
/usr/bin/i686-w64-mingw32-g++-win32
Older versions of mingw cross compiler shipped /usr/bin/i586-mingw32msvc-c++, which is replaced by i686-w64-mingw32-c++-win32
You can usually use this toolchain in a project by running ./configure CXX=i686-w64-mingw32-c++-win32 or make CXX=i686-w64-mingw32-c++-win32
Note: the above description is correct for the most recent toolchain in Debian unstable. It may need some minor tweaking for older systems.

Qt 5.1.1 compiler setup on Ubuntu

First of all, I should point out that I've never used linux before.
I have a clean install of 64bit ubuntu, I downloaded Qt 5.1.1 for linux 64 bit from http://qt-project.org/downloads, ran the .run file, installed it and gcc which is included in that download, opened Qt Creator, made a new project and tried to compile it. It wont compile and I keep getting this error message
:-1: error: Qt Creator needs a compiler set up to build. Configure a compiler in the kit options.
I added a gcc compiler, but what do I need to put for the compiler path, platform codegen flags, platform linker flags and ABI?
You don't have to input the path of your compiler because gcc and g++ paths are available in the $PATH enovironment variable. So just use "gcc" and "g++" and that should work. Just make sure you restart Qt Creator after the installation of g++.
One more thing. You need a compiled version of Qt installed on your computer. So also install Qt libraries with
sudo apt-get install qt4-dev-tools
If you want to use the new version of the library you have to add it to $PATH. You can do this in the terminal with
export PATH=/path/to/Qt/qtbase:$PATH
And then run Qt Creator from the same terminal, in which you did the last command.
Good luck!
You will have to install the dependencies as well. I got it working when I followed the steps in the following link.
Try this:
http://wiki.qt.io/Building_Qt_5_from_Git

Error compiling a c++ with Python bindings using mingw and msys

My environment: Windows 7 64 pro, mingw32 (installed with 2012-04-26.exe installer), msys 1.0, Python 2.7.3 installed using the Win64 installer from python.org
I'm trying to compile a c++ program that has python bindings, using mingw and msys. When I run config from the msys shell, I get the errors
Could not link test program to Python.
Maybe the main Python library has been installed in some non-standard library path.
If so, pass it to configure, via the LDFLAGS environment variable.
Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"
============================================================================
ERROR!
You probably have to install the development version of the Python package
for your distribution. The exact name of this package varies among them.
============================================================================
I've tried to run configure with each of:
./configure LDFLAGS="-L/c/Python27/libs"
./configure LDFLAGS="-L/c/Python27/Lib"
./configure LDFLAGS="-Lc:/Python27/libs"
./configure LDFLAGS="-Lc:/Python27/libs"
and all give me the same final error. I've posted the entire config.log file at http://pastebin.com/fZVjTeub. Any help?
The problem was ultimately that I was using a 32-bit compiler and trying to link it to 64-bit Python.
In my case I've had to pass LDFLAGS="-L/c/Python27/libs" to ./configure

How to compile for Windows on Linux with gcc/g++?

I have written some effects in C++ (g++) using freeglut on Linux, and I compile them with
g++ -Wall -lglut part8.cpp -o part8
So I was wondering if it is possible to have g++ make static compiled Windows executables that contains everything needed?
I don't have Windows, so it would be really cool, if I could do that on Linux :)
mingw32 exists as a package for Linux. You can cross-compile and -link Windows applications with it. There's a tutorial here at the Code::Blocks forum. Mind that the command changes to x86_64-w64-mingw32-gcc-win32, for example.
Ubuntu, for example, has MinGW in its repositories:
$ apt-cache search mingw
[...]
g++-mingw-w64 - GNU C++ compiler for MinGW-w64
gcc-mingw-w64 - GNU C compiler for MinGW-w64
mingw-w64 - Development environment targeting 32- and 64-bit Windows
[...]
Suggested method gave me error on Ubuntu 16.04: E: Unable to locate package mingw32
===========================================================================
To install this package on Ubuntu please use following:
sudo apt-get install mingw-w64
After install you can use it:
x86_64-w64-mingw32-g++
Please note!
For 64-bit use: x86_64-w64-mingw32-g++
For 32-bit use: i686-w64-mingw32-g++
One option of compiling for Windows in Linux is via mingw. I found a very helpful tutorial here.
To install mingw32 on Debian based systems, run the following command:
sudo apt-get install mingw32
To compile your code, you can use something like:
i586-mingw32msvc-g++ -o myApp.exe myApp.cpp
You'll sometimes want to test the new Windows application directly in Linux. You can use wine for that, although you should always keep in mind that wine could have bugs. This means that you might not be sure that a bug is in wine, your program, or both, so only use wine for general testing.
To install wine, run:
sudo apt-get install wine
Install a cross compiler, like mingw64 from your package manager.
Then compile in the following way: instead of simply calling gcc call i686-w64-mingw32-gcc for 32-bit Windows or x86_64-w64-mingw32-gcc" for 64-bit Windows. I would also use the --static option, as the target system may not have all the libraries.
If you want to compile other language, like Fortran, replace -gcc with -gfortran in the previous commands.
I've used mingw on Linux to make Windows executables in C, I suspect C++ would work as well.
I have a project, ELLCC, that packages clang and other things as a cross compiler tool chain. I use it to compile clang (C++), binutils, and GDB for Windows. Follow the download link at ellcc.org for pre-compiled binaries for several Linux hosts.
From: https://fedoraproject.org/wiki/MinGW/Tutorial
As of Fedora 17 it is possible to easily build (cross-compile) binaries for the win32 and win64 targets. This is realized using the mingw-w64 toolchain: http://mingw-w64.sf.net/. Using this toolchain allows you to build binaries for the following programming languages: C, C++, Objective-C, Objective-C++ and Fortran.
"Tips and tricks for using the Windows cross-compiler": https://fedoraproject.org/wiki/MinGW/Tips
For Fedora:
# Fedora 18 or greater
sudo dnf group install "MinGW cross-compiler"
# Or (not recommended, because of its deprecation)
sudo yum groupinstall -y "MinGW cross-compiler"