Cross compilation with clang - c++

I am attempting to cross compile a program from an x86_64 linux machine to arm 64-bit (aarch64) format. The file that I am attempting to cross-compile uses OpenCV. I am able to successfully cross-compile programs that don't include external libraries, but when I include OpenCV I get the following error:
/usr/local/lib/libopencv_shape.so.3.2.0: error adding symbols: File in wrong format
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [helloworld] Error 1
make[1]: *** [CMakeFiles/helloworld.dir/all] Error 2
make: *** [all] Error 2
Any help would be much appreciated!

Related

ld: library not found for -lclangRewrite

The following error occurs when I am building eos using cmake on macOS.
ld: library not found for -lclangRewrite
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [programs/abi_gen/abi_gen] Error 1
make[1]: *** [programs/abi_gen/CMakeFiles/abi_gen.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 74%] Built target eos_chain
make: *** [all] Error 2
I find some related issues, but they are seemingly all about ios and xcode and I don't know what I should do in a project like eos. How can I fix it?
I meet the same 2 errors when building from source code of EOS step by step.
Alternatively You can use another method by running the script(https://github.com/EOSIO/eos#automac):
./build.sh darwin

Emscripten cpuid.h

Edit: Im trying to generate LLVM from a c++ project, not build the LLVM system itself.
I'm trying to build LLVM through emscripten, but I need the header 'cpuid.h'.
/home/emsdk-portable/emscripten/1.37.21/build/project/main.cpp:35:10: fatal error: 'cpuid.h' file not found
#include <cpuid.h>
^~~~~~~~~
1 error generated.
ERROR:root:compiler frontend failed to generate LLVM bitcode, halting
CMakeFiles/project.dir/build.make:86: recipe for target 'CMakeFiles/project.dir/main.cpp.o' failed
make[2]: *** [CMakeFiles/project.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/project.dir/all' failed
make[1]: *** [CMakeFiles/project.dir/all] Error 2
Makefile:116: recipe for target 'all' failed
make: *** [all] Error 2
According to this github cpuid.h should exist (Shouldn't it?) with the included clang, but neither I nor the program itself is finding it for the include.
Fastcomp is the default backend and as such I thought cpuid.h should be locateable by whatever my program is.
Any ideas on finding/fixing the problems? Thanks

Undefined reference when compiling library with clang

I'm trying to build the libdepixelize library , but I'm getting the following error:
[100%] Linking CXX executable depixelize-kopf2011
/usr/bin/ld: /usr/local/lib/lib2geom.a(nearest-point.o): undefined reference to symbol '_ZNKSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEE3strEv##GLIBCXX_3.4.21'
//usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line
clang: error: linker command failed with exit code 1 (use -v to see invocation)
src/depixelize-kopf2011/CMakeFiles/depixelize-kopf2011.dir/build.make:95: recipe for target 'src/depixelize-kopf2011/depixelize-kopf2011' failed
make[2]: *** [src/depixelize-kopf2011/depixelize-kopf2011] Error 1
CMakeFiles/Makefile2:142: recipe for target 'src/depixelize-kopf2011/CMakeFiles/depixelize-kopf2011.dir/all' failed
make[1]: *** [src/depixelize-kopf2011/CMakeFiles/depixelize-kopf2011.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
I'm using clang with libstdc++ as compiler. GCC didn't work either.
EDIT: I used this in the CMakeLists file: set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++") and then did cmake -DCMAKE_CXX_COMPILER="clang++" .. and make to compile it. The full log is here: https://hastebin.com/axasololuc.js
I have no idea what exactly it means, or even how to fix it.

Compiling opencv for ARM platform

I want to put C++ opencv algorithm on ARM-Linux based camera.
I am able to do Configure and Generate steps for opencv build using CMake.
Then when I try to do “make” operation on terminal I am facing some issue.
->>>>>>>>>>>>>>>>>Issue->>>
Linking CXX shared library ../../lib/libopencv_core.so
/opt/montavista_pro_arm_v5t_le/bin/../lib/gcc/armv5tl-montavista-linux-gnueabi/4.2.0/../../../../armv5tl-montavista-linux-gnueabi/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make[2]: *** [lib/libopencv_core.so.3.0.0] Error 1
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make: *** [all] Error 2
->>>>>>>>>>>>>>>>
I searched online. I tried to do some stuff from link http://answers.opencv.org/question/33564/opencv-master-branch-compilation-issue/ . I removed ${ZLIB_LIBRARIES} option in modules/core/CMakeLists.txt.
But still I am facing same issue.
Can you please help me with that.

llvm error: linking error to libLTO.so

During compilation of llvm I get following error:
llvm[2]: ======= Finished Linking Debug+Asserts Executable llvm-config
llvm[2]: Installing Debug+Asserts /usr/local/bin/llvm-config
make[2]: Leaving directory `/usr/bin/tools/llvm-config'
make[2]: Entering directory `/usr/bin/tools/lto'
llvm[2]: Compiling LTODisassembler.cpp for Debug+Asserts build (PIC)
llvm[2]: Compiling lto.cpp for Debug+Asserts build (PIC)
llvm[2]: Linking Debug+Asserts Shared Library libLTO.so
collect2: ld terminated with signal 9 [Killed]
make[2]: *** [/usr/bin/Debug+Asserts/lib/libLTO.so] Error 1
make[2]: Leaving directory `/usr/bin/tools/lto'
make[1]: *** [install] Error 1
make[1]: Leaving directory `/usr/bin/tools'
make: *** [install] Error 1
I do configure llvm by giving path of gcc & g++ compilers.
I don't get any error during configuration; but during build same error persist with clang also. I am using Ubntu-12.10 32 bit.
OK, so to solve this problem, I referred to llvm.org and during configuration added few options as follows:
sudo ./configure CC="/usr/bin/gcc" CXX="/usr/bin/g++" --enable-optimization --enable-jit --enable-debug-runtime --enable-targets=all
And I ran a build as SuperUser.
I faced the same error using Ubuntu 13.04 (arch: x86_64). The following error
collect2: ld terminated with signal 9 [Killed]
was an issue with memory usage. I was indeed using a Koding.com cloud VM with 1GB RAM.
I tried the compilation on my laptop as a normal user and the compilation finished without any issues. I used:
$ ./configure
$ make -j4