thp / psmoveapi

Cross-platform library for 6DoF tracking of the PS Move Motion Controller. Sensor fusion, computer vision, ambient display (LED orb).
https://thp.io/2010/psmove/
Other
467 stars 160 forks source link

compilation problem #29

Closed fontviea closed 12 years ago

fontviea commented 12 years ago

Hi,

I've got a compilation error during link stage of psmoveapi static lib :

Linking C shared module _psmove.so /usr/bin/ld: libpsmoveapi_static.a(psmove.c.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC libpsmoveapi_static.a: could not read symbols: Bad value collect2: ld returned 1 exit status


When trying to build using package It complains about libopencv-dev not found (the lib is called libcv-dev on my distrib (Mint))

All sources come from repo, following all README instructions.

thp commented 12 years ago

Which OS? Which Architecture? Which Compiler/Version?

You usually don't want the "libcv-dev" package, but the "libopencv-dev" package. libcv-dev is the old, transitional packages and might go away in the future.

fontviea commented 12 years ago

Hi, more precision :

-- Configuring done -- Generating done -- Build files have been written to: /opt/psmove/psmoveapi2/psmoveapi/build [ 30%] Built target psmoveapi_static Linking C shared module _psmove.so /usr/bin/ld: libpsmoveapi_static.a(psmove.c.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC libpsmoveapi_static.a: could not read symbols: Bad value collect2: ld returned 1 exit status make[2]: * [_psmove.so] Erreur 1 make[1]: * [CMakeFiles/_psmove.dir/all] Erreur 2 make: *\ [all] Erreur 2

thp commented 12 years ago

Can you try adding add_definitions(-fPIC) to the CMakeLists.txt file, then re-run cmake and then re-run make? Does this fix the issue?

jpola commented 12 years ago

Hello,

I've got the same error on my machine: -- Ubuntu 12.04 kernel: 3.2.0-32-generic -- ccmake version 2.8.7 -- gcc (Ubuntu/Linaro 4.4.7-1ubuntu2) 4.4.7 -- GNU ld (GNU Binutils for Ubuntu) 2.22

After adding your suggestion to CMakeLists.txt the psmoveapi compiled succesfully. Thanks.

thp commented 12 years ago

Thanks - so, after some investigation the problem seems to be that we can't link the Python module (itself a shared library) to the PS Move API static library. I've added the -fPIC switch as a temporary workaround now until (if ever) we find a better solution. Commit 3eeef2d

There's an interesting thread over at the FreeBSD mailing list related to that very issue, from 2005: http://lists.freebsd.org/pipermail/freebsd-amd64/2005-April/004644.html