Error Compiling libc++ using Clang 3.0 on Ubuntu - clang

When I try to compile libc++ (libcxx) on my Ubuntu 12.04 with LLVM 3.0 and Clang 3.0 i get the error
+ clang++ -c -g -Os -fPIC -std=c++0x -fstrict-aliasing -Wall -Wextra -Wshadow -Wconversion -Wnewline-eof -Wpadded -Wmissing-prototypes -Wstrict-aliasing=2 -Wstrict-overflow=4 -nostdinc++ -I../include ../src/stdexcept.cpp
../src/stdexcept.cpp:18:10: fatal error: 'cxxabi.h' file not found
#include <cxxabi.h>
^
1 error generated.
Where should I put cxxabi.h? It's currently in the following places
/usr/include/c++/4.4/cxxabi.h
/usr/include/c++/4.6/cxxabi.h
/usr/include/c++/4.7/cxxabi.h

My best guess is that any of these cxxabi.h will work. The only thing std except.cpp is looking for is if it is being used with libc++abi, which will be false for all 3 of your cxxabi.h.

Related

How do I clean a dart build? And modify the g++ flags?

I'm cross-building dart for armel (a client hired me to solve problems there)
I'm building on ubuntu 14.04 (the armel gcc/g++ is 4.7.3).
I want to take out -Werror since I'm seeing:
/usr/bin/arm-linux-gnueabi-g++ '-DDART_NO_SNAPSHOT' '-DDART_PRECOMPILER' '-DTARGET_ARCH_ARM' '-DNDEBUG' '-D_FORTIFY_SOURCE=2' -Iruntime -Werror -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wvla -Woverloaded-virtual -g3 -ggdb3 -fno-rtti -fno-exceptions -fstack-protector -Wa,--noexecstack -marm -mfpu=vfp -Wno-psabi -fno-strict-overflow -O3 -ffunction-sections -fno-omit-frame-pointer -MMD -MF out/ReleaseXARM/.deps/out/ReleaseXARM/obj.target/libdart_vm_nosnapshot/runtime/vm/compiler.o.d.raw -c -o out/ReleaseXARM/obj.target/libdart_vm_nosnapshot/runtime/vm/compiler.o runtime/vm/compiler.cc
In file included from runtime/vm/isolate.h:18:0,
from runtime/vm/growable_array.h:15,
from runtime/vm/compiler.h:9,
from runtime/vm/compiler.cc:5:
runtime/vm/thread.h: In static member function 'static dart::RawError* dart::Compiler::CompileClass(const dart::Class&)':
runtime/vm/thread.h:167:17: error: variable 'thread' might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbered]
cc1plus: all warnings being treated as errors
make: *** [out/ReleaseXARM/obj.target/libdart_vm_nosnapshot/runtime/vm/compiler.o] Error 1
BUILD FAILED
I'm working with this dart git tree:
commit 1d028eed8dfa00ac9d4ff685e61b01e6909dbeb4
Author: Paul Berry <paulberry#google.com>
Date: Wed Nov 30 12:28:51 2016 -0800
This is an actual bug in the code. One way to fix it would be to mark the thread variable volatile.

How to get the options with which clang was compiled

It is possible to get gcc configure options with gcc -v (an example is here). Is there a similar way to retrieve the compilation options of clang?
My real task is the following one: I have an environment with a compiler (clang) which I want to improve. Now I have some patch for clang that I applied and I want to rebuild the patched sources, but I also want to be sure that nothing changes from the vanilla build apart from my patch; in particular, that all the build flags I use are the same.
No, probably not. But it's possible to get the CXXFLAGS/LDFLAGS clang was compiled with via llvm-config.
$ llvm-config --cxxflags
-I/opt/compiler/llvm-trunk/include -march=native -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -std=c++11 -ffunction-sections -fdata-sections -O3 -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
$ llvm-config --ldflags
-L/opt/compiler/llvm-trunk/lib
$ llvm-config --system-libs
-lrt -ldl -lcurses -latomic -lpthread -lz -lm
If you are on a Linux distribution, then simply check the PKGBUILD (or similar) to find the exact flags.

linking error: "undefined reference to `pthread_atfork'" in Armadillo library

recently I updated my armadillo to version 5.200.1, but when i tried to compile my code using
g++ -std=c++11 -m64 -O3 -Wall -I. -I/opt/OpenBLAS/include -fopenmp -o code.cpp.o -c code.cpp
g++ -std=c++11 -m64 -O3 -Wall -I. -I/opt/OpenBLAS/include -fopenmp -o main.cpp.o -c main.cpp
g++ -std=c++11 -m64 -O3 -o code.cpp.o main.cpp.o -lgomp -L/opt/OpenBLAS/lib -lopenblas -larmadillo
I got error message in the final linking step
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../lib/libarmadillo.so:
undefined reference to `pthread_atfork'
collect2: error: ld returned 1 exit status
make: *** [a.out] Error 1
This error appears in my machine with Ubuntu 14.04LTS + gcc 4.9.2.
The Armadillo itself is linked with OpenBLAS 0.2.14 (I followed the procedure provided by Armadillo in installation)
such error doesn't occur in my macosx laptop (the same library). It means something problems with my ubuntu machine. I tried to re-install the Armadillo 4.650.2 (this version worked before), but the same error kept appearing (now older doesn't work like before). The only thing that i did before updating those libraries were "apt-self update" and "apt-self upgrade" of my ubuntu machine
is there any suggestion to fix this problem?
I also use armadillo on Ubuntu Linux
I had the same problem first when I started to program with armadillo. For g++ I only had to add -larmadillo as command line option. such as this
g++ -O2 -o armadillo_example armadillo_example.cpp -larmadillo

License plate recogntion using OpenCV

I got a good Automatic Number Plate Recognition Project from github (https://github.com/kornelik/anpr ). In order to run this we need OpenCV and Tesseract Optical Character Recognition library (https://code.google.com/p/tesseract-ocr/). It works fine in my Ubuntu 12.04 , 32bit system.
The problem is that while I setting the same working code in another system (Ubuntu 12.04 , 32 bit) after configuring OpenCV and Tesseract it produces the following error while making the project.I am struggling to find out what is the issue
The error is
g++ -Wall -Werror -O2 -c main.cpp -o main.o
g++ -Wall -Werror -O2 -c recognizer.cpp -o recognizer.o
g++ -Wall -Werror -O2 -c conio.cpp -o conio.o
g++ -Wall -Werror -O2 -c ocr_char.cpp -o ocr_char.o
ocr_char.cpp: In constructor ‘anpr::OCRChar::Impl::Impl(const string&, const string&)’:
ocr_char.cpp:17:9: error: ‘set’ is not a member of ‘std’
ocr_char.cpp:17:18: error: expected primary-expression before ‘char’
ocr_char.cpp:17:18: error: expected ‘;’ before ‘char’
ocr_char.cpp:23:17: error: ‘goodChars’ was not declared in this scope
make: *** [ocr_char.o] Error 1
Is your code updated? On nov 2013 there was a commit to include the set header:
https://github.com/kornelik/anpr/commit/2a63fb362e6fc79ac73f172195a893b37287d3bf
The error message you got seems to be related to that.
Compiled ok on Ubuntu 14.04 64 bits.

invalid value '' in '-std=' when switch from GCC 4.2 to LLVM 2.0

I'd like to change from using GCC version 4.2 to LLVM version 2.0 in XCode4.
When I change the compiler flag to to LLVM I get an error: invalid value '' in '-std='. Was having it in the *_prefix.pch file, but after turning off the GCC_Precompile_prefix_header the error moved to a new point in my code.
The initial value use seems to refer to an empty string.
What's going on here.
The full error message is below.
Many thanks
CompileC /Users/cram/Library/Developer/Xcode/DerivedData/MightyMemory-cceuiavwfpmibiczfvlodqgugfnb/Build/Intermediates/MightyMemory.build/Debug-iphonesimulator/MightyMemory.build/Objects-normal/i386/GameViewController.o Classes/GameViewController.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/cram/Projects/MightyMemory
setenv LANG en_US.US-ASCII
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin:/usr/local/git/bin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang -x objective-c -arch i386 -fmessage-length=0 -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -std= -Wno-trigraphs -fpascal-strings -O0 -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -fexceptions -fasm-blocks -mmacosx-version-min=10.6 -gdwarf-2 -fvisibility=hidden -fobjc-abi-version=2 -fobjc-legacy-dispatch -D__IPHONE_OS_VERSION_MIN_REQUIRED=40000 -iquote /Users/cram/Library/Developer/Xcode/DerivedData/MightyMemory-cceuiavwfpmibiczfvlodqgugfnb/Build/Intermediates/MightyMemory.build/Debug-iphonesimulator/MightyMemory.build/MightyMemory-generated-files.hmap -I/Users/cram/Library/Developer/Xcode/DerivedData/MightyMemory-cceuiavwfpmibiczfvlodqgugfnb/Build/Intermediates/MightyMemory.build/Debug-iphonesimulator/MightyMemory.build/MightyMemory-own-target-headers.hmap -I/Users/cram/Library/Developer/Xcode/DerivedData/MightyMemory-cceuiavwfpmibiczfvlodqgugfnb/Build/Intermediates/MightyMemory.build/Debug-iphonesimulator/MightyMemory.build/MightyMemory-all-target-headers.hmap -iquote /Users/cram/Library/Developer/Xcode/DerivedData/MightyMemory-cceuiavwfpmibiczfvlodqgugfnb/Build/Intermediates/MightyMemory.build/Debug-iphonesimulator/MightyMemory.build/MightyMemory-project-headers.hmap -I/Users/cram/Library/Developer/Xcode/DerivedData/MightyMemory-cceuiavwfpmibiczfvlodqgugfnb/Build/Products/Debug-iphonesimulator/include -I/Users/cram/Library/Developer/Xcode/DerivedData/MightyMemory-cceuiavwfpmibiczfvlodqgugfnb/Build/Intermediates/MightyMemory.build/Debug-iphonesimulator/MightyMemory.build/DerivedSources/i386 -I/Users/cram/Library/Developer/Xcode/DerivedData/MightyMemory-cceuiavwfpmibiczfvlodqgugfnb/Build/Intermediates/MightyMemory.build/Debug-iphonesimulator/MightyMemory.build/DerivedSources -F/Users/cram/Library/Developer/Xcode/DerivedData/MightyMemory-cceuiavwfpmibiczfvlodqgugfnb/Build/Products/Debug-iphonesimulator -include /Users/cram/Projects/MightyMemory/MaxMemory_Prefix.pch -c /Users/cram/Projects/MightyMemory/Classes/GameViewController.m -o /Users/cram/Library/Developer/Xcode/DerivedData/MightyMemory-cceuiavwfpmibiczfvlodqgugfnb/Build/Intermediates/MightyMemory.build/Debug-iphonesimulator/MightyMemory.build/Objects-normal/i386/GameViewController.o
error: invalid value '' in '-std='
I solved the problem. For the next person to run up against this: It turns out that the options that were passed to the compiler were incorrect; not that I changed them from what they were when using gcc. The error was that the GCC_C_LANGUAGE_STANDARD was not set, i.e. the argument that XCode4 put is was '' (a blank string). I set it to compiler default and all was good.

Resources