michalkielan / MatrixLibs

Small matrix library, written C++11
Mozilla Public License 2.0
1 stars 2 forks source link

clang errors, warnings #31

Closed michalkielan closed 7 years ago

michalkielan commented 7 years ago

Step to reproduce:

$ mkdir build && cd build
$ CXX=/usr/bin/clang++ cmake ..
$ make

Clang version clang version 3.8.0-2

Current behaviour: Error in linking time, a lot of warnings due to the curly brackets in matrix objects initialization

/usr/bin/ld: /usr/lib/llvm-3.8/bin/../lib/LLVMgold.so: error loading plugin: /usr/lib/llvm-3.8/bin/../lib/LLVMgold.so: cannot open shared object file: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
tst/compare/CMakeFiles/test-compare.dir/build.make:94: recipe for target 'tst/compare/test-compare' failed
make[2]: *** [tst/compare/test-compare] Error 1
CMakeFiles/Makefile2:163: recipe for target 'tst/compare/CMakeFiles/test-compare.dir/all' failed
make[1]: *** [tst/compare/CMakeFiles/test-compare.dir/all] Error 2
Makefile:94: recipe for target 'all' failed
make: *** [all] Error 2

Expected behaviour: compile without warnings and errors using clang

JaroslawWiosna commented 7 years ago

I cannot reproduce...

➜ MatrixLibs git:(fix31) ✗ clang++ --version

clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin

@michal915 I have no errors, but maybe I didn't triggered CXX as clang?

JaroslawWiosna commented 7 years ago

I've finally reproduced http://stackoverflow.com/a/12843988 System wide C++ change on Ubuntu:


sudo apt-get install clang
sudo update-alternatives --config c++

Will print something like this:

   Selection    Path              Priority   Status
 ------------------------------------------------------------
 * 0            /usr/bin/g++       20        auto mode
   1            /usr/bin/clang++   10        manual mode
   2            /usr/bin/g++       20        manual mode

and after pressing '1' and cmake . && make errors just like you described

JaroslawWiosna commented 7 years ago

https://bugs.launchpad.net/ubuntu/+source/llvm-toolchain-snapshot/+bug/1254970

I ran into this and my workaround was:

ln -sf /usr/lib/llvm-3.4/lib/LLVMgold.so /usr/lib/LLVMgold.so echo /usr/lib/llvm-3.4/lib >> /etc/ld.so.conf ldconfig

I also had to add -B/usr/lib/gold-ld to my clang options to get it to use /usr/bin/ld.gold instead of /usr/bin/ld.bfd

(-B takes a directory containing ld, not a path to a linker!)

This might be worth trying...


Or also I think this is needed http://llvm.org/docs/GoldPlugin.html I have also tried to do

sudo apt-get install binutils-gold binutils-dev

from here but it didn't work...