Unable to compile program using boost on Mac - c++

I recently installed boost 1.48 on my MacOSX 10.7 using MacPorts. While I am able to compiler some examples given in boost documentation, I am failing in this one (http://www.boost.org/doc/libs/1_48_0/libs/bimap/example/step_by_step.cpp). Here is the error message:
g++ -Wall -I/opt/local/include -L/opt/local/lib step_by_step.cpp -o step_by_step
In file included from /usr/include/machine/_types.h:32,
from /usr/include/sys/_types.h:33,
from /usr/include/_types.h:27,
from /usr/include/unistd.h:71,
from /usr/include/c++/4.2.1/bits/os_defines.h:61,
from /usr/include/c++/4.2.1/bits/c++config.h:41,
from /usr/include/c++/4.2.1/cstddef:50,
from /opt/local/include/boost/config/select_stdlib_config.hpp:18,
from /opt/local/include/boost/config.hpp:40,
from step_by_step.cpp:7:
/usr/include/i386/_types.h:37: error: expected constructor, destructor, or type conversion before ‘typedef’
make: *** [step_by_step] Error 1
Here are the details about the compiler
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.1~22/src/configure --disable-checking --enable-werror --prefix=/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.1~22/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
Please help me compile it.
Thanks

Not meant to be a solution, but I just tried this with the Boost release branch (what will be 1.49 soon), and it worked just fine.
And with the 1.47 release. (I don't have 1.48 installed)
Same compiler.

Related

i want to use g++ but my mac uses clang

I want to compile my program which uses OpenMp on mac os Sierra. I have Xcode8. I do it via terminal: g++ -fopenmp -o train train.cpp. The next errors occur:
clang: error: unsupported option '-fopenmp'
clang: error: unsupported option '-fopenmp'
Tell me please how can I solve this problem.
clang --version
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
g++ --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Clang version confusion (OSX and Cmake)

I'm attempting to lock down the compiler version I use (for a number of reasons I won't go into). To do this, I'd like to check the version of the compiler on build using CMAKE_CXX_COMPILER_VERSION and CMAKE_CXX_COMPILER_VERSION.
On OSX CMake reports:
CMAKE_CXX_COMPILER_VERSION 7.0.2.7000181
CMAKE_CXX_COMPILER_ID Clang
CMAKE_CXX_COMPILER /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
However, the version reported via terminal is:
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
This is true of:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ --version
clang --version
gcc --version
g++ --version
Why the discrepancy in version numbers as reported by CMake and the command line (for the same executable)?
And for the purposes of restricting to a particular compiler version, is CMAKE_CXX_COMPILER_VERSION reliable?
Turns out CMake sets the compiler version in CMakeFiles/3.5.0/CmakeCXXCompiler.cmake (for version 3.5.0). Only by deleting this file and re-building is the correct compiler version reported (assuming you had a different one installed at some point).

Not able to use C++14 features( bind,lambdas,etc and getting C++11extension warning) after installing gcc49?

It shows that gcc49 is active:
$ port select --list gcc
Available versions for gcc:
mp-gcc49 (active)
none
but version is still 4.2.1,
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
How do i fix this?

GCC 4.9.2 cross-compiler build for ARM

I am trying to build a cross-compiler for ARM. When I add c++ to my "enable-languages" list in the configure (see) below, the gmake errors out with:
checking for exception model to use...
configure: error: unable to detect exception model
gmake[1]: *** [configure-target-libstdc++-v3]
but when I take c++ out of the "enable-languages", as in my configure script below, the GCC cross-compiler builds just fine.
../gcc-4.9.2/configure --prefix=/home/me/ANDROID21 --target=arm-linux-androideabi
--with-gmp=/home/me/ANDROID21 --with-mpfr=/home/me/ANDROID21
--with-mpc=/home/me/ANDROID21
--with-gnu-as--with-gnu-ld --enable-languages=c,fortran --disable-nls
--disable-tls
--disable-bootstrap --disable-libgomp --disable-shared --disable-libssp
-disable-libquadmath --enable-threads --enable-target-optspace --disable-libatomic
--with-sysroot=/home/me/android-ndk-r10c/platforms/android-21/arch-arm
For reference, here is my machine info:
$ uname -a
Linux (system name) 2.6.32-504.el6.x86_64 #1 SMP Tue Sep 16 01:56:35 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux
And the GCC I'm building off of:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/me/GCC4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/me/gcc-4.9.2/configure --prefix=/home/me/GCC4.9.2 --disable-multilib
--enable-libgomp --enable-languages=c,c++,objc,obj-c++,java,fortran
Thread model: posix
gcc version 4.9.2 (GCC)
Any ideas on possible causes?
Haven't found anything definitive in the archives yet. Would really like to get the c++ portion to cross-compile too.
TIA,
Steve

gcov error: Multiple sources for a single basic block

When I invoke gcov as follows it returns the following error message:
gcov -a -p dynamic-maps.gcda
Multiple sources for a single basic block: <path-to-file>/dynamic-maps.cpp != (in _ZN16AnalysisPipeline16AnalysisServices22calculate_dynamic_mapsERKNSt3__110shared_ptrINS_6Common16AnalysisRegistryEEERKN9Utilities6ImagesERKNS3_10TimeSeriesERKNS3_14T1ParameterFitE).
Invalid .gcno File!
Please can someone explain what the cause of this might be.
gcov -version returns:
LLVM (http://llvm.org/):
LLVM version 3.4svn
Optimized build.
Default target: x86_64-apple-darwin13.4.0
Host CPU: core-avx-i
The file was compiled using Xcode 5.1 on OS X Mavericks with the following version of clang:
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
Updating Xcode to version 6.1.1 has resolved the issue.