Error in building opencv with ffmpeg - c++

I installed ffmpeg according to this article. ffmpeg installation was ok.
Now I build opencv with ffmpeg support and I have some errors.
The errors are
/home/coie/Softwares/Libraries/opencv-2.4.13.3/modules/highgui/src/cap_ffmpeg_impl.hpp:1484:21: error: ‘CODEC_FLAG_GLOBAL_HEADER’ was not declared in this scope
c->flags |= CODEC_FLAG_GLOBAL_HEADER;
^
/home/coie/Softwares/Libraries/opencv-2.4.13.3/modules/highgui/src/cap_ffmpeg_impl.hpp: In function ‘int icv_av_write_frame_FFMPEG(AVFormatContext*, AVStream*, uint8_t*, uint32_t, AVFrame*)’:
/home/coie/Softwares/Libraries/opencv-2.4.13.3/modules/highgui/src/cap_ffmpeg_impl.hpp:1512:30: error: ‘AVFMT_RAWPICTURE’ was not declared in this scope
if (oc->oformat->flags & AVFMT_RAWPICTURE) {
^
/home/coie/Softwares/Libraries/opencv-2.4.13.3/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function ‘void CvVideoWriter_FFMPEG::close()’:
/home/coie/Softwares/Libraries/opencv-2.4.13.3/modules/highgui/src/cap_ffmpeg_impl.hpp:1686:35: error: ‘AVFMT_RAWPICTURE’ was not declared in this scope
if( (oc->oformat->flags & AVFMT_RAWPICTURE) == 0 )
^
/home/coie/Softwares/Libraries/opencv-2.4.13.3/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function ‘bool CvVideoWriter_FFMPEG::open(const char*, int, double, int, int, bool)’:
/home/coie/Softwares/Libraries/opencv-2.4.13.3/modules/highgui/src/cap_ffmpeg_impl.hpp:1920:32: error: ‘AVFMT_RAWPICTURE’ was not declared in this scope
if (!(oc->oformat->flags & AVFMT_RAWPICTURE)) {
^
In file included from /home/coie/Softwares/Libraries/opencv-2.4.13.3/modules/highgui/src/cap_ffmpeg.cpp:45:0:
/home/coie/Softwares/Libraries/opencv-2.4.13.3/modules/highgui/src/cap_ffmpeg_impl.hpp: In static member function ‘static AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext*, AVCodecID, int, int, int, double, AVPixelFormat)’:
/home/coie/Softwares/Libraries/opencv-2.4.13.3/modules/highgui/src/cap_ffmpeg_impl.hpp:2214:25: error: ‘CODEC_FLAG_GLOBAL_HEADER’ was not declared in this scope
c->flags |= CODEC_FLAG_GLOBAL_HEADER;
^
modules/highgui/CMakeFiles/opencv_highgui.dir/build.make:230: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.cpp.o' failed
make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.cpp.o] Error 1
CMakeFiles/Makefile2:2349: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui.dir/all' failed
What could be wrong?

My solution is to grep the missing defines (2 in total) from FFmpeg by using grep -r which leads to the following code found in libavcodec/avcodec.h:
#define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22)
#define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER
#define AVFMT_RAWPICTURE 0x0020
Copy and paste it to the top of:
opencv-3.3.0/modules/videoio/src/cap_ffmpeg_impl.hpp
Compile and everything works even with the latest sources

Easiest change for the CODEC_FLAG_GLOBAL_HEADER is to change it to AV_CODEC_FLAG_GLOBAL_HEADER, it was redefined in a newer version.
Note the "AV_" in front

in opencv:0/2.4 there is no modules/videoio directory! to get that old version (2.4.13-r3) to compile with newest media-video/ffmpeg on gentoo (4.1.3) I had to add above changes to modules/highgui/src/cap_ffmpeg_api.hpp with this
patch:
--- opencv-2.4.13/modules/highgui/src/cap_ffmpeg_api.hpp 2019-05-27 13:28:05.736339890 +0200
+++ opencv-2.4.13-new/modules/highgui/src/cap_ffmpeg_api.hpp 2019-05-27 13:27:48.787198507 +0200
## -12,6 +12,10 ##
#define OPENCV_FFMPEG_API
#endif
+#define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22)
+#define CODEC_FLAG_GLOBAL_HEADER
AV_CODEC_FLAG_GLOBAL_HEADER
+#define AVFMT_RAWPICTURE 0x0020
+
enum
{
CV_FFMPEG_CAP_PROP_POS_MSEC=0,
(i.e. I created the path and file /etc/portage/patches/media-libs/opencv-2.4.13-r3/old-ffmpeg.patch with that contents.)
in defense to gentoo, I should mention, the new media-libs/opencv:0/3.4.1 is also available, as is the old media-video/ffmpeg-3.4.5, so I could alternatively also play around with masking out versions or file a bug for developers to do that for me...

Related

Backward cpp can no longer build, missing lbdf despite linking

I am on arch and made the mistake of upgrading.
Before I could build bacward-cpp, now I get the following error:
../libraries/backward-cpp/backward.hpp:1357:10: error: ‘bfd_get_section_flags’ was not declared in this scope; did you mean ‘bfd_set_section_flags’?
1357 | if ((bfd_get_section_flags(fobj.handle.get(), section) & SEC_ALLOC) == 0)
| ^~~~~~~~~~~~~~~~~~~~~
| bfd_set_section_flags
../libraries/backward-cpp/backward.hpp:1360:24: error: ‘bfd_get_section_vma’ was not declared in this scope; did you mean ‘bfd_set_section_vma’?
1360 | bfd_vma sec_addr = bfd_get_section_vma(fobj.handle.get(), section);
| ^~~~~~~~~~~~~~~~~~~
| bfd_set_section_vma
../libraries/backward-cpp/backward.hpp:1361:26: error: ‘bfd_get_section_size’ was not declared in this scope; did you mean ‘bfd_set_section_size’?
1361 | bfd_size_type size = bfd_get_section_size(section);
| ^~~~~~~~~~~~~~~~~~~~
| bfd_set_section_size
make[1]: *** [VulkanEngine.make:233: obj/Debug/VulkanDebugging.o] Error 1
make: *** [Makefile:30: VulkanEngine] Error 2
I am linking with both lbdf and ldl, by doing -lbfd -ldl as arguments to g++. I am also doing #define BACKWARD_HAS_BFD 1 before including the header as per the documentation.
I am at a loss.
The corresponding macros of binutils changed slightly.
You have to drop the _get from the section macros and remove the fobj.handle.get() parameter manually: bfd_get_section_flags(fobj.handle.get(), section) to bfd_section_flags(section).

opencv - cmake mingw32-make error [duplicate]

opencv installation using mingw32-make command in windows 10 platform, then likely end up in getting the below error.
Windows version : 10
OpenCv:3.2.0
Please suggest me in installing.
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp: In constructor 'testing::internal::Mutex::Mutex()':
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8829:45: error: cannot convert 'CRITICAL_SECTION* {aka _CRITICAL_SECTION*}' to '_RTL_CRITICAL_SECTION*' in initialization
critical_section_(new CRITICAL_SECTION) {
^
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8830:48: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void InitializeCriticalSection(LPCRITICAL_SECTION)'
::InitializeCriticalSection(critical_section_);
^
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp: In destructor 'testing::internal::Mutex::~Mutex()':
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8840:46: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'PCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void DeleteCriticalSection(PCRITICAL_SECTION)'
::DeleteCriticalSection(critical_section_);
^
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp: In member function 'void testing::internal::Mutex::Lock()':
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8848:43: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void EnterCriticalSection(LPCRITICAL_SECTION)'
::EnterCriticalSection(critical_section_);
^
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp: In member function 'void testing::internal::Mutex::Unlock()':
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8858:43: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void LeaveCriticalSection(LPCRITICAL_SECTION)'
::LeaveCriticalSection(critical_section_);
^
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp: In member function 'void testing::internal::Mutex::ThreadSafeLazyInit()':
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8879:27: error: cannot convert 'CRITICAL_SECTION* {aka _CRITICAL_SECTION*}' to '_RTL_CRITICAL_SECTION*' in assignment
critical_section_ = new CRITICAL_SECTION;
^
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8880:54: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void InitializeCriticalSection(LPCRITICAL_SECTION)'
::InitializeCriticalSection(critical_section_);
^
modules\ts\CMakeFiles\opencv_ts.dir\build.make:237: recipe for target 'modules/ts/CMakeFiles/opencv_ts.dir/src/ts_gtest.cpp.obj' failed
mingw32-make[2]: *** [modules/ts/CMakeFiles/opencv_ts.dir/src/ts_gtest.cpp.obj] Error 1
CMakeFiles\Makefile2:5379: recipe for target 'modules/ts/CMakeFiles/opencv_ts.dir/all' failed
mingw32-make[1]: *** [modules/ts/CMakeFiles/opencv_ts.dir/all] Error 2
Makefile:159: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
I also faced the same problem while trying to build OpenCV 3.2.0 using mingw32 on Windows10. I searched a bit to find a fix on Github for similar problem. It said the problem was:
MinGW defined _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two separate (equivalent) structs, instead of using typedef
So, you have to add another typedef GTEST_CRITICAL_SECTION for _CRITICAL_SECTION and _RTL_CRITICAL_SECTION and use this typedef for either case.
Here is what to do :
Edit "ts_gtest.h" which is inside "opencv\sources\modules\ts\include\opencv2\ts\"
Replace this line (probably line 723)
// assuming CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION.
// This assumption is verified by
// WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION.
struct _RTL_CRITICAL_SECTION;
with
#if GTEST_OS_WINDOWS_MINGW
// MinGW defined _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two
// separate (equivalent) structs, instead of using typedef
typedef struct _CRITICAL_SECTION GTEST_CRITICAL_SECTION;
#else
// Assume CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION.
// This assumption is verified by
// WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION
typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
#endif
Replace this line (probably on line 3060 before your edit - line number would have changed as you modified first part)
_RTL_CRITICAL_SECTION* critical_section_;
with
GTEST_CRITICAL_SECTION* critical_section_;
These two changes should fix your above error.
It was fixed by using TDM-gcc mingw compiler.

"error: expected primary-expression before 'volatile'"

I'm trying to compile NRF driver with MinGW 4.8.2. I'm getting this error:
In file included from
b:/nrfdriver/sdk/nRF51_SDK_8.1.0_b6ed55f/components/device/nrf51.h:119:0,
from b:/nrfdriver/sdk/nRF51_SDK_8.1.0_b6ed55f/components/softdevice/s130/headers/nrf_soc.h:50,
from b:/nrfdriver/pc-ble-driver-0.5.0/driver/inc_override/nrf_soc.h:21,
from b:/nrfdriver/pc-ble-driver-0.5.0/driver/inc_override/app_util_platform.h:26,
from b:/nrfdriver/sdk/nRF51_SDK_8.1.0_b6ed55f/components/drivers_nrf/uart/app_uart.h:27,
from b:\nrfdriver\pc-ble-driver-0.5.0\driver\src\app_uart_pc.c:13:
C:/MinGW/mingw64/lib/gcc/x86_64-w64-mingw32/4.8.2/include/xmmintrin.h:
In function 'void _mm_setcsr(unsigned int)':
b:/nrfdriver/sdk/nRF51_SDK_8.1.0_b6ed55f/components/toolchain/gcc/core_cm0.h:164:21:
error: expected primary-expression before 'volatile' #define __I
volatile /*!< Defines 'read only' permissions */
^ driver\CMakeFiles\s130_nrf51_ble_driver.dir\build.make:297: recipe for
target 'driver/CMakeFiles/s130_nrf51_ble_driver.dir/src/app_uart_pc.c
.obj' failed
Error comes from this line:
#define __I volatile /*!< Defines 'read only' permissions */
How can such a simple #define lead to a compiler error and any idea how I should fix that? (upgrading the compiler is not an option as this version of the driver is supposed to be built with this version of MinGW).
Note that the driver is meant to be built in 32bits and I'm trying to build it targetting 64bits, dunno if that could be the cause of the problem...
What if we also look in the xmmintrin.h header?
/* Set the control register to I. */
extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_setcsr (unsigned int __I)
{
__builtin_ia32_ldmxcsr (__I);
}
Ouch, another use of __I.

Configure Eclipse CDT or Codeblocks to get LLVM IR intellisense

I want to configure Eclipse (or Codeblocks) so that when I write a pass, I can at least take advantage of Intellisense (even if building passes directly from within Eclipse is not possible). Update: I am getting at least some intellisense once I enabled Parsing-based Proposals in Eclipse (details below)
So far I have configured Eclipse to use clang to compile simple C++ programs.
To get intellisense for LLVM pass, I added /usr/local/include to Includes directories and tried code:
#include <iostream>
#include <llvm/IR/Function.h>
using namespace std:
int main() {
cout << "Hello World" << endl;
return 0;
}
It doesn't fail on #include <llvm/IR/Function.h> itself (i.e. it can find this header file), but upon including subsequent files, gives me
/usr/local/include/llvm/Support/DataTypes.h:58:3: error: "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"
Any pointers to how I could make it give me intellisense at least?
Complete Log
01:22:48 **** Rebuild of configuration Debug for project HelloWorld2 ****
Info: Internal Builder is used for build
clang++ -I/usr/local/include -O0 -emit-llvm -g3 -Wall -c -fmessage-length=0 -o src/HelloWorld2.bc ../src/HelloWorld2.cpp
In file included from ../src/HelloWorld2.cpp:10:
In file included from /usr/local/include/llvm/IR/Function.h:22:
In file included from /usr/local/include/llvm/IR/Argument.h:17:
In file included from /usr/local/include/llvm/ADT/Twine.h:14:
/usr/local/include/llvm/Support/DataTypes.h:58:3: error: "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"
# error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"
^
/usr/local/include/llvm/Support/DataTypes.h:62:3: error: "Must #define __STDC_CONSTANT_MACROS before " "#including Support/DataTypes.h"
# error "Must #define __STDC_CONSTANT_MACROS before " \
^
In file included from ../src/HelloWorld2.cpp:10:
In file included from /usr/local/include/llvm/IR/Function.h:22:
In file included from /usr/local/include/llvm/IR/Argument.h:19:
In file included from /usr/local/include/llvm/IR/Attributes.h:19:
In file included from /usr/local/include/llvm/ADT/ArrayRef.h:14:
In file included from /usr/local/include/llvm/ADT/SmallVector.h:20:
/usr/local/include/llvm/Support/MathExtras.h:273:24: error: use of undeclared identifier 'INT64_C'
return N >= 64 || (-(INT64_C(1)<<(N-1)) <= x && x < (INT64_C(1)<<(N-1)));
^
/usr/local/include/llvm/Support/MathExtras.h:273:56: error: use of undeclared identifier 'INT64_C'
return N >= 64 || (-(INT64_C(1)<<(N-1)) <= x && x < (INT64_C(1)<<(N-1)));
^
/usr/local/include/llvm/Support/MathExtras.h:299:26: error: use of undeclared identifier 'UINT64_C'
return N >= 64 || x < (UINT64_C(1)<<(N));
^
/usr/local/include/llvm/Support/MathExtras.h:331:24: error: use of undeclared identifier 'INT64_C'
return N >= 64 || (-(INT64_C(1)<<(N-1)) <= x && x < (INT64_C(1)<<(N-1)));
^
/usr/local/include/llvm/Support/MathExtras.h:331:56: error: use of undeclared identifier 'INT64_C'
return N >= 64 || (-(INT64_C(1)<<(N-1)) <= x && x < (INT64_C(1)<<(N-1)));
^
In file included from ../src/HelloWorld2.cpp:10:
In file included from /usr/local/include/llvm/IR/Function.h:22:
In file included from /usr/local/include/llvm/IR/Argument.h:19:
In file included from /usr/local/include/llvm/IR/Attributes.h:19:
In file included from /usr/local/include/llvm/ADT/ArrayRef.h:14:
/usr/local/include/llvm/ADT/SmallVector.h:232:20: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
void push_back(T &&Elt) {
^
/usr/local/include/llvm/ADT/SmallVector.h:476:33: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
iterator insert(iterator I, T &&Elt) {
^
/usr/local/include/llvm/ADT/SmallVector.h:645:46: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
SmallVectorImpl &operator=(SmallVectorImpl &&RHS);
^
/usr/local/include/llvm/ADT/SmallVector.h:383:12: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for (auto I = this->end(), E = this->begin() + N; I != E; ++I)
^
/usr/local/include/llvm/ADT/SmallVector.h:764:70: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
SmallVectorImpl<T> &SmallVectorImpl<T>::operator=(SmallVectorImpl<T> &&RHS) {
^
/usr/local/include/llvm/ADT/SmallVector.h:878:27: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
SmallVector(SmallVector &&RHS) : SmallVectorImpl<T>(N) {
^
/usr/local/include/llvm/ADT/SmallVector.h:883:44: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
const SmallVector &operator=(SmallVector &&RHS) {
^
In file included from ../src/HelloWorld2.cpp:10:
In file included from /usr/local/include/llvm/IR/Function.h:22:
In file included from /usr/local/include/llvm/IR/Argument.h:19:
In file included from /usr/local/include/llvm/IR/Attributes.h:20:
In file included from /usr/local/include/llvm/ADT/FoldingSet.h:21:
/usr/local/include/llvm/Support/Allocator.h:134:70: error: expected expression
BumpPtrAllocatorImpl<AllocatorT, SlabSize, SizeThreshold>> {
^
/usr/local/include/llvm/Support/Allocator.h:346:2: error: expected a type
};
^
/usr/local/include/llvm/Support/Allocator.h:346:2: error: expected class name
/usr/local/include/llvm/Support/Allocator.h:346:2: error: expected '{' after base class list
/usr/local/include/llvm/Support/Allocator.h:362:53: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
SpecificBumpPtrAllocator(SpecificBumpPtrAllocator &&Old)
^
/usr/local/include/llvm/Support/Allocator.h:366:64: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
SpecificBumpPtrAllocator &operator=(SpecificBumpPtrAllocator &&RHS) {
^
/usr/local/include/llvm/Support/Allocator.h:375:5: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto DestroyElements = [](char *Begin, char *End) {
^
/usr/local/include/llvm/Support/Allocator.h:375:28: error: expected expression
auto DestroyElements = [](char *Begin, char *End) {
^
/usr/local/include/llvm/Support/Allocator.h:381:10: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for (auto I = Allocator.Slabs.begin(), E = Allocator.Slabs.end(); I != E;
^
/usr/local/include/llvm/Support/Allocator.h:381:29: error: no member named 'Slabs' in 'llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096>'
for (auto I = Allocator.Slabs.begin(), E = Allocator.Slabs.end(); I != E;
~~~~~~~~~ ^
/usr/local/include/llvm/Support/Allocator.h:381:58: error: no member named 'Slabs' in 'llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096>'
for (auto I = Allocator.Slabs.begin(), E = Allocator.Slabs.end(); I != E;
~~~~~~~~~ ^
/usr/local/include/llvm/Support/Allocator.h:383:52: error: no member named 'computeSlabSize' in 'llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096>'
size_t AllocatedSlabSize = BumpPtrAllocator::computeSlabSize(
~~~~~~~~~~~~~~~~~~^
/usr/local/include/llvm/Support/Allocator.h:384:35: error: no member named 'Slabs' in 'llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096>'
std::distance(Allocator.Slabs.begin(), I));
~~~~~~~~~ ^
/usr/local/include/llvm/Support/Allocator.h:386:35: error: no member named 'Slabs' in 'llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096>'
char *End = *I == Allocator.Slabs.back() ? Allocator.CurPtr
~~~~~~~~~ ^
/usr/local/include/llvm/Support/Allocator.h:386:60: error: no member named 'CurPtr' in 'llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096>'
char *End = *I == Allocator.Slabs.back() ? Allocator.CurPtr
~~~~~~~~~ ^
/usr/local/include/llvm/Support/Allocator.h:392:10: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for (auto &PtrAndSize : Allocator.CustomSizedSlabs) {
^
/usr/local/include/llvm/Support/Allocator.h:392:39: error: no member named 'CustomSizedSlabs' in 'llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096>'
for (auto &PtrAndSize : Allocator.CustomSizedSlabs) {
~~~~~~~~~ ^
/usr/local/include/llvm/Support/Allocator.h:392:27: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for (auto &PtrAndSize : Allocator.CustomSizedSlabs) {
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
13 warnings and 20 errors generated.
01:22:50 Build Finished (took 1s.509ms)
UPDATE: Eclipse does give me intellisense (at least some of it), I had to check Parsing-based Proposals in Window -> Preferences -> C/C++ -> Editor -> Content Assist -> Advanced (It was unchecked by default).
This is not answering the question directly, but it will ensure, you have a correctly working build environment. It is specific for code blocks.
First checkout the source tree of llvm (directly taken from the getting started guide):
git clone http://llvm.org/git/llvm.git
cd llvm/tools
git clone http://llvm.org/git/clang.git
cd ..
cd projects
git clone http://llvm.org/git/compiler-rt.git
git clone http://llvm.org/git/libcxx.git
git clone http://llvm.org/git/libcxxabi.git
git clone http://llvm.org/git/test-suite.git
git clone http://llvm.org/git/openmp.git
Remove anything you don't like.
Then create an directory outside the llvm directory:
cd ..
mkdir build
Change your directory (cd) to there and run:
cd build
cmake -g "CodeBlocks - Unix Makefiles" <your configure options> ../llvm
Assuming llvm shares the root path, otherwise change the ../llvm line to the correct path. Then open it as an existing project in code::blocks.
If all went well, your build environment is setup correctly and code completion should work.

Conversion error in boost 1.49/1.50/1.51 ASIO with MinGW & GCC 4.7.0

I'm getting some strange error from within boost::asio when simply including the asio.hpp header file, which then includes other headers till win_static_mutex.ippwithin which it generates an conversion error.
I use MinGW with GCC 4.7 with the -std=gnu++11 compiler flag (see here why gnu++11 and not c++11). The error occurs in boost 1.49, 1.50 and 1.51 (current).
The full error reads as following:
In file included from boost1.49/boost/asio/detail/win_static_mutex.hpp:71:0,
from boost1.49/boost/asio/detail/static_mutex.hpp:23,
from boost1.49/boost/asio/detail/impl/signal_set_service.ipp:24,
from boost1.49/boost/asio/detail/signal_set_service.hpp:210,
from boost/asio/signal_set_service.hpp:19,
from boost/asio/basic_signal_set.hpp:24,
from boost/asio.hpp:26,
from MyCode\Client.cpp:3:
boost1.49/boost/asio/detail/impl/win_static_mutex.ipp: In member function 'int boost::asio::detail::win_static_mutex::do_init()':
boost1.49/boost/asio/detail/impl/win_static_mutex.ipp:51:63: error: invalid conversion from 'const wchar_t*' to 'size_t {aka unsigned int}' [-fpermissive]
boost1.49/boost/asio/detail/impl/win_static_mutex.ipp:51:63: error: invalid conversion from 'unsigned int' to 'const wchar_t*' [-fpermissive]
boost1.49/boost/asio/detail/impl/win_static_mutex.ipp:53:10: warning: declaration of 'mutex' shadows a global declaration [-Wshadow]
As I said in the beginning the only thing I do in my code is including the asio.hpp header:
#include <boost/asio.hpp>
The lines 43-53 from boost's win_static_mutex.ipp file are (I've marked the line 51):
using namespace std; // For sprintf.
wchar_t mutex_name[128];
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(UNDER_CE)
swprintf_s(mutex_name, 128,
#else // BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(UNDER_CE)
swprintf(mutex_name,
#endif // BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(UNDER_CE)
L"asio-58CCDC44-6264-4842-90C2-F3C545CB8AA7-%u-%p",
static_cast<unsigned int>(::GetCurrentProcessId()), this); // line 51
HANDLE mutex = ::CreateMutexW(0, TRUE, mutex_name);
Is there now some definitions I have to define or any other compiler flags or would one need to change something directly in boost or is it rather something with MinGW that needs to be changed?
It seems to be an error in Boost. You can try to update Boost to a later release (1.51 is available) and hope it's fixed there, otherwise you should report it as a bug.
One ugly 'solution' is to set the compiler flag -fpermissive.
At the moment I see only this 'solution' and one needs to wait until boost catches up again with GCC 4.7.0...