3

I have downloaded some C++ which I want to compile from source. After running cmake ../src and then make from the command line, whilst in the build directory, I get the following error:

/usr/bin/ld: /usr/local/lib/libBulletCollision.a(btDbvtBroadphase.o):
relocation R_X86_64_32S against `_ZTV16btDbvtBroadphase' can not be used when making a shared object;
recompile with -fPIC

I believe that this is something to do with trying to create a shared library, but not providing the necessary memory to do so (although I don't fully understand this...). Anyway, following the advice I've seen around, I tried the following instead:

make CXXFLAGS='-fPIC'

However, this gives me exactly the same error as before. Any ideas as to why this did not solve the problem?

Karnivaurus
  • 22,823
  • 57
  • 147
  • 247
  • 1
    Run `make clean` first. – user253751 Jan 19 '16 at 20:24
  • It is really strange that makefile doesn't work out of the box. Presumably, if you downloaded the software, it should include correct makefile? Are you sure the error is with the downloaded library? – SergeyA Jan 19 '16 at 20:27
  • I tried running `make clean` first, but that did not help. I've followed all the instructions on the GitHub project page (https://github.com/dartsim/dart/wiki/DART%205.1%20Installation%20for%20Ubuntu), where it says that it should just compile fine for Ubuntu 14.04... – Karnivaurus Jan 19 '16 at 20:32
  • 2
    Why do you have your own version of bullet in /usr/local, why not use the system one? Note that the error message is about recompiling bullet, not dart. – Marc Glisse Jan 19 '16 at 21:01

1 Answers1

1

I believe Mark is correct when he says the error is about libBulletCollision.a. You are building a .so built with -fPIC but linking against a .a that did not use -fPIC. You will either need to change and build a static library or rebuild and install a new dependent libBulletCollision.a using -fPIC.

By the way, you should add the -fPIC flag to your build in a more permanent way in the cmake configure step rather in this transient way overriding CXXFLAGS when running make.

Also using make VERBOSE=1 with cmake generated makefile builds is quite helpful when debugging builds.

Phil
  • 5,822
  • 2
  • 31
  • 60