Building Qt 4.8.1 from src on MacOS using gcc 4.5 - macos

I have a question about building Qt SDK 4.8.1 using gcc on Mac. I need to use gcc 4.5 or higher, so I installed mp-gcc45 package using macports (so tried with mp-gcc47), selected this version of gcc, so
gcc -v
Says me that gcc version 4.5.4 (MacPorts gcc45 4.5.4_6)
So I downloaded QtSDK src from official site, configure it and there is an error at first step:
cc1plus: error: unrecognized command line option "-fconstant-cfstrings"
Maybe its stupid solution, but I remove this flags from configure file, so I get a error after make call:
g++: unrecognized option '-Xarch_x86_64'
Can you give me an advice, how to build Qt using this version of gcc?

Non-Apple gcc will never work with Qt of any version. Only Apple gcc recognizes those Apple flavored compiler options.
You are stuck with gcc 4.2 on Mac. There's no way around it.

Related

Looking for a mingw-w64 build of gcc that includes mudflap

I'm trying to debug a segfault in some code built with mingw-w64's version of gcc. Since no Windows build of gcc includes the Address Sanitizer, I've been looking for a version prior to 4.9 that would allow me to use Mudflap instead.
(It has to be 4.8 or earlier, since Mudflap was removed from gcc in 4.9 - see https://gcc.gnu.org/wiki/Mudflap_Pointer_Debugging)
I've tried using downloads of 4.8.1 and 4.6.4 from https://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/ - but my builds all fail with cc1plus.exe: fatal error: mf-runtime.h: No such file or directory.
I have tried using the original MinGW as well, but 4.5 as downloaded from
https://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version4/gcc-4.5.0-1/
just fails silently with error code 1.
Is there any site that still hosts a mingw-w64 build of gcc old enough to include mudflap? Preferably with SEH threads instead of SJLJ. If not, is there anywhere I can download a mingw-w64-compatible set of libraries and headers to install mudflap to work with an existing build?

How do I change compiler on Xcode to gcc 7.3.0?

I currently have Xcode 6.2.
First is there a way to check if this version of Xcode comes with gcc 7.3.0? And if it does have gcc 7.3.0, how do I set up Xcode so that gcc 7.3.0 becomes the default compiler?
However if my Xcode does not have gcc 7.3.0 how do I get gcc 7.3 and set up Xcode so that gcc 7.3.0 becomes the default compiler?
Xcode uses the LLVM Clang compiler, not gcc. gcc can be installed, the easiest way would be using either Homebrew or MacPorts. I'm not sure if there's any way to make it the default compiler though, especially not to use from inside Xcode. Is there some specific feature/reason why you need gcc 7.3?

TensorFlow build fails with `GLIBCXX_3.4.20' not found

Building TensorFlow with gcc version 4.8.5 or 5.4.0 gives an error:
bazel-out/host/bin/external/protobuf/protoc: /lib64/libstdc++.so.6:
version `GLIBCXX_3.4.20' not found (required by
bazel-out/host/bin/external/protobuf/protoc)
Tried to add linker flags in CROSSTOOL.tpl file in Tensorflow, however it didn't help.
You built your app with version of GCC that's newer than your host GCC. So your app uses symbols which are not present in host libstdc++ which causes runtime linker to fail.
You can solve this by linking your app with -Wl,-rpath,path/to/new/libs or setting LD_LIBRARY_PATH appropriately.

omp.h not found, OS X Yosemite not using newest gcc version

I am trying to build GraphChi on OS X Yosemite but get the following error:
fatal error: 'omp.h' file not found
From this question - How to include omp.h in OS X? - I learned that Yosemite uses Clang instead of gcc, which does not include omp.h.
$ which gcc
/usr/bin/gcc
$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix
Next, I installed gcc via Homebrew
$ brew info gcc
gcc: stable 4.9.2 (bottled)
http://gcc.gnu.org
/usr/local/Cellar/gcc/4.9.2_1 (1092 files, 177M)
Built from source with: --without-multilib
and updated $PATH to include the path to the new gcc version
$ echo $PATH
/usr/local/Cellar/gcc/4.9.2_1:usr/local/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin
however, gcc -v and which gcc still point to the old version, and building GraphChi still doesn't work due to the missing omp.h file
Does anyone know what else I need to do?
Update
locate omp.h returned:
/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/lib/gcc/i686-apple-darwin11/4.2.1/include/omp.h
/usr/local/Cellar/gcc/4.9.2_1/lib/gcc/4.9/gcc/x86_64-apple-darwin14.1.0/4.9.2/include/omp.h
/usr/local/Cellar/gfortran/4.8.2/gfortran/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2/include/omp.h
my ~/.profile:
export PATH=/usr/local/Cellar/gcc/4.9.2_1/lib/gcc/4.9/gcc/x86_64-apple-darwin14.1.0/4.9.2/include:/usr/local/Cellar/gcc/4.9.2_1/bin:usr/local/bin:/opt/local/bin:/opt/local/sbin:$PATH
I solved this with installing gcc with homebrew:
brew install gcc --without-multilib
and then building the source code with
CC=gcc-5 CXX=g++-5 cmake ..
CC=gcc-5 CXX=g++-5 make -j7
Once you have installed gcc-4.9 with homebrew, it will automatically be in your path. To use OpenMP, you just need to make sure you are using the newly installed gcc-4.9, and it will be able to find omp.h.
In the case of GraphChi, you will have to go change line 3 of the Makefile to be gcc-4.9. From there, running make should just work. They describe this in their README, but at least the version they describe is out of date https://github.com/GraphChi/graphchi-cpp#problems-compiling-on-mac.
clang does not support OpenMP yet. Also gcc by default links to Apple's LLVM clang compiler (not the GCC installed from brew).
Instead gcc-4.9 would link to GCC. I think if -fopenmp is specified omp.h is included automatically.
It is possible to manually build a version of clang with OpenMP support, see http://clang-omp.github.io
You shouldn't add the include path to PATH; instead, specify it as CFLAGS, including the -I option. You can export the CFLAGS variable, or set it on the fly.
Depending on how you compile things, you could do
CFLAGS=-I/usr/local/Cellar/gcc/4.9.2_1/lib/gcc/4.9/gcc/x86_64-apple-darwin14.1.0/4.9.2/include/omp.h gcc <whatever>
Of course, in this case you can specify it directly on the gcc command (as -I/usr/local/....), but the CFLAGS variable also works with configure (as configure often won't have an option to specify where it should look for specific include files); probably with make, or even for those installing a Python package: CFLAGS=-I... pip install <some-package>.
Other flags to consider are
CXXFLAGS: C++ specific pre-processor flags
LDFLAGS: linker specific flags (e.g. LDFLAGS=-L/some/path/... for linking with dynamic libraries).
CC: specify the C compiler to use. This is an easy way to avoid the built-in gcc alias for clang on OS X. Just use CC=/usr/local/bin/gcc-4 make or similar.
CXX: specify the C++ compiler to use.

Error when building Qt 4.8 (beta) with gcc 4.6.1 on MacOSX Lion

I try to build the latest source of the Qt 4.8 beta with gcc 4.6.1 configure fails with the following:
cc1plus: error: unrecognized command line option ‘-fconstant-cfstrings’
It seems to be working with the g++ version (i686-apple-darwin11-llvm-g++-4.2) shipped with XCode 4.1
The reason for this combo of gcc and qt is that i want to try out the new C++11 features available in the latest version of Qt.
I have a same problem but with gcc 4.8.1
but i manually erase it in root project dir configure file and corelib/configure[released|debug]
for now i cant find where is generated.

Resources