I'm getting the error Parse error at "BOOST_JOIN" while trying to compile a code with Qt4 and CGAL. I'm not using Boost directly and I've already searched and tried a bunch of options like -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDEDand -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION. The versions I'm working with are CGAL 4.1.0, Qt 4.8.4_6 and Boost 1.53.0_1, and using CMake to generate the Makefile, in a machine Mac OS 10.8.2. Any ideas of what could be causing that error?
This problem happens in Boost 1.56.0 with QT 4.7.4 (which is quite old now),
Regardless, another quick workaround is to edit the problematic boost header files,
and
add to the top:
#ifndef Q_MOC_RUN
add to the bottom:
#endif
This will at least let MOC run without dying.
When you compile a piece of code that defines Qt objects, the build system needs to call the Qt Meta Object Compiler, aka "moc". In Qt versions before 5.0, the "moc" compiler (actually a precompiler) does not parse correctly all C++ code. In particular, it does not fully expand preprocessor macros. In recent Boost versions, some macros (like that BOOST_JOIN) are sometimes used to define a namespace name. For example:
namespace BOOST_JOIN(BOOST_TT_TRAIT_NAME,_impl) {
in boost/type_traits/detail/has_binary_operator.hpp of Boost version 1.53.
A Qt bug has being filled at Qt-Project.org and is said to be fixed in Qt-5.0.
In CGAL-4.2, I have tried to suppress those build errors by separating more the use of Qt and Boost in different compilation units. You should retry with a recent version of Boost, and CGAL-4.2-beta1 (or later versions if they are released when you read that answer). Let me know if you encounter similar problems with CGAL-4.2-beta1 or later.
As for Qt-5.0, I hope CGAL-4.3 will support it. We will have to work on the CMake scripts to support it. It will be added to the planning of the next CGAL developers meeting.
I downgraded to Boost 1.52, and now it's compiling.
Related
I have a MacOS project that needs to compile on Windows. I've been using win32-clang-msvc compiler which seems to be the only included compiler that supports objective-c compilation. However, my files have #import statements that that compiler does not support and are using some MacOS libraries/frameworks (like foundation).
I've installed GNUstep msys, core and devel components, but I have no idea what is all the data I need to enter into Qt add compiler menu to have it actually work. Do I use c++.exe or cpp.exe? Do I use gcc.exe? Where is the make path? How to write a mkspec for it?
Is there any documentation on that for GNUstep?
You can add custom compilers in Qt using the QMAKE_EXTRA_COMPILERS variable.
We’ve used this method to support building Objective-C sources on Android using GNUstep. You can check out the example project, which contains an objc-gnustep.pri file with the compiler definition for Objective-C sources. This should similarly work on Windows as well.
That being said I am not sure your setup using Clang and GNUstep MSYS packages will work as-is, as the GNUstep MSYS packages/libraries are probably built with GCC using MinGW libraries, whereas you would be using Clang with the MSVC runtime libraries. GCC comes with an Objective-C runtime, but using Objective-C with Clang requires the external libobjc2 runtime, which currently doesn’t seem to be compatible with MinGW as recently discussed on the mailing list. That being said I’d love to know if you can get it to work.
For the time being, instead of using Clang your best option might be using GCC from MinGW with the GNUstep packages, but note that this doesn’t support Automatic Reference Counting (ARC) and some other features only supported by Clang/libobjc2.
I am currently working on a masters project and I am desperately trying to compile some C++ code on my mac (macOS High Sierra 10.13.3 using Xcode) so I can develop the program at home. The Program is a set of files used for performing integrals on a bunch of different data... it uses headers from the boost library and also alglib. This all works fine on Windows machines running visual studios.
The issue I have is that when I include boost (which was installed via homebrew to usr/local/) into the search paths in the project build settings I get all sorts of semantic and linker issues.
I have searched this for a while and tried to implement a few potential fixes. I have tried:
Compiling with different C++ dialects and and standard libraries (libc++ and libstdc++).
Uninstalling/reinstalling boost.
Removing suggested header files and libraries from 'usr/local' suggested by brew doctor.
and implementing all sorts of other random permutations of settings that I felt could be issued.
The number of errors and warnings may change using different build settings however semantic issues persist and I am running out of ideas for how to proceed. It is really important I get this working and any insight would be appreciated.
From my reading about and attempting to troubleshoot I get the idea that it is some kind of linking issue between the boost library and the standard c++ libraries, but I have little experience with semantic issues as in the past I have been lucky enough that things just worked! Perhaps my MacBook may just have too much going on and needs some housecleaning to stop confusing the compiler, but regardless if anyone can help me fix this issue I would be eternally grateful!
I understand I haven't provided much detail here but if any information would be useful I'm happy to send screenshots.
link to errors image
In C++03 ifstream did not have a constructor that accepts std::string.
Such a constructor was added in C++11. The same holds for std::stod: it exists since C++11.
So you have to compile with -std=c++11 option.
I recently downloaded mingw from http://www.mingw.org/ and installed its c++ compiler and dependencies, which include installing standard library headers. I have also successfully compiled a hello world program, compilation is fine, and common old headers are there and work fine (such as string.h).
However, when I attempted to #include <any>, it threw an error that any.h does not exist. And sure enough, when I look in mingw\include\, there is no any.h (and I see other things missing, such as variant.h).
I've looked through the mingw package manager, and I have the standard library stuff installed, and there's nothing else relevant to install. Does minGW support C++17? If so, how can I get these newer header files? It seems like this should be something really obvious.
You need mingw-w64, which provides more recent GCC versions:
http://mingw-w64.org
You can find a 7.2.0 download here:
http://mingw-w64.org/doku.php/download/mingw-builds
The any feature requires C++17 support, so if your compiler implementation actually does support it, you probably want to specify it on the command line like this:
g++ -std=c++17 a.cpp
Of course, this requires a modern C++ compiler, like that you can get from nuwen.net.
I am setting up a new C++ project (in Xcode 4.6) and I would very much like to use the features of the new C++11 standard (lambda expressions, auto, etc.). I am trying to (statically) link the Gnu Scientific Library (GSL) into this project, using Darson's answer to this previous question. However, his answer suggests to change the compiler to LLVM GCC 4.2, which does not support the new C++11 features.
When I change to the default Apple LLVM compiler 4.2, build fails and I get a long list of errors that Xcode traces back to semantic issues (undeclared identifiers, unknown type names, etc.) in the headers of the new "libc++" STL.
So my question is: Did anyone find a way to use GSL in the new C++11 standard? It doesn't necessarily have to be in Xcode, I am comfortable using any (UNIX) IDE or build environment.
I've been able to solve my own question, and I thought I'd share it with those who might be struggling with this as well.
Like I suspected, the problem occurred because my GSL install (from macports) was build against the "old" STL (libstdc++). Hence, my solution was to recompile GSL against the "new" STL (libc++). This is easily done by unpacking the sources and running
./configure CC=clang CFLAGS="-stdlib=libc++" LDFLAGS="-stdlib=libc++"
I also added --disable-shared to build the static library only, and --prefix=... to set the build path. Then all what's left is to run make and make install.
I'm using android NDK r8d, and eclipse Juno. I'm trying to compile C++ code which uses C++11 stuff like mutex, lock_guard, shared_ptr, etc. in a native android project in eclipse.
I get errors like:
"error: 'shared_ptr' is not a member of 'std'"
"fatal error: mutex: No such file or directory"
I came across a similar question here. It seems to work for them, but the explanation there is not complete so I can't get it to work for me.
I added "NDK_TOOLCHAIN_VERSION=4.7" to the Application.mk and "LOCAL_CFLAGS += -std=c++11" to Android.mk file. Still, it doesn't compile.
In the link above it says:
"Be sure that the standard library include path (like
/android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/4.7/include) is in the
target settings."
How and where do I insert it?
I also get errors in eclipse IDE (on the source, before compiling). I know I should define "__GXX_EXPERIMENTAL_CXX0X__" to resolve them but I just don't know where to put it.
So, if someone could post an answer with a full explanation of how to compile and make eclipse work with C++11 it would be great.
Regarding your first question:
Go to Project > Properties > C/C++ General / Paths and Symbols
In the "Includes" tab, add the proper directory, e.g.
/android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/4.7/include
Regarding your second question, I'm also looking for an answer. It is absolutely not clear how to define the GXX_EXPERIMENTAL_CXX0X macro in Eclipse.
Some say that it should be "added as a predefined macro to the indexer", but it looks like we both could not find a way to implement that...
I have read elsewhere that it should be added to "C/C++ General / Paths and Symbols / Symbols / GNU C++" but I can't find the "Symbols / GNU C++" part in my version of Indigo.
I find export an environment variable NDK_TOOLCHAIN_VERSION=4.8 before i start eclipse can solve this problem.
Eclipse use ndk's default toolchain version 4.6, if NDK_TOOLCHAIN_VERSION is not define, and gcc witch this version does not support all c++11's future like multithread and so on.