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.
Related
I needed to work with postgreSQL and C++ so the most common library out there for this is libpqxx. I cloned the repo and switched to latest branch available right now (branch 7.6) and then used CMake to build the visual studio solution file.
But I cannot build this with latest preview features language standard OR even C++20 language standard. After searching for a bit I discovered that the error related to the header file ciso646 has something to do with C++20 removing != operator. This is very annoying as now I cannot make my project's language standard as C++20 either because of this. Here is a screenshot of the build errors:
So I reduced the language standard to C++17 and then tried to build and it still gave me a LOT of warnings before getting built successfully. The warnings were something of the sort:
warning C5051: attribute 'likely' requires at least '/std:c++20'; ignored
Even though now it is built and I got my include and lib files I am not sure if these warnings can cause any problems for me in the future.
Anyhow my question is can something be done to be able to build this library using c++20 or am I stuck working with c++17 because of this?
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 downloaded Clang 3.6.2 from this website and am trying to set it up with Code::Blocks under Windows. Unfortunately, it fails to compile a simple "hello world" program on the grounds that it doesn't know where iostream is.
Looking through the install folder, it does not appear to include a standard library with it. Why? And how do I get it?
The standard library is NOT part of the compiler itself. It is part of the runtime environment on a particular platform. Sure, some organisations put together a "kit" with all the necessary parts to build an application - there may even be someone that packages a Clang compiler with a suitable runtime.
In general, you should be able to download the Windows SDK and get the relevant header files there - and if you use clang-cl, it should be largely compatible with the MSVC compiler [or provide clang or clang++ with the correct -fms-compatibility or whatever it is called].
Or as suggested in the other answer, use libcxx, but it's not 100% complete for Windows.
They do have a c++ standard library: libcxx.llvm.org. But it's not fully supported on the windows platform.
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.
I have installed clang and llvm from source, and am trying to compile some C++ code using features of the new standard.
I have found that while for example the use of for ranges e.g. for (i : vector) works fine, I am having trouble (cannot find header file) when I need to import a header e.g. <unordered_set> or <tuple>.
Do I need to use the new libc++ to use these headers, or is there just a simple build change I need to make? At the moment I have just built clang and llvm into a folder in my home directory, and am calling clang++ from there.
See http://clang.llvm.org/get_started.html.
If you intend to work on Clang C++ support, you may need to tell it how to find your C++ standard library headers. If Clang cannot find your system libstdc++ headers, please follow these instructions:
gcc -v -x c++ /dev/null -fsyntax-only to get the path.
Look for the comment "FIXME: temporary hack: hard-coded paths" in clang/lib/Frontend/InitHeaderSearch.cpp and change the lines below to include that path.
While the standard library comes with distributions of your compiler, when you're building it yourself, you still need to build the standard library itself. Some of its components may be header-only, but not all of them are.
So you do need to at least download the library, if not build it. Clang can use GCC's libstdc++, but they also have their libc++ project.