Alpha Compiling peripheral.joystick issue
#1
I'm cross compiling for ARM in a buildroot toolchain.
Updating and compiling Leia wasn't too difficult, but the old peripheral.joystick addon isn't compatible (it gives me an error saying this when KODI starts).
But when I update to the newest commit for peripheral.joystick, it runs into two issues.
The first is that it can't find the KODI include files. Looks like Leia didn't copy that correctly for some reason, but an easy fix with passing a cmake parameter.
I'm stuck on the second issue. It compiles up past 75% and then fails and insists that there's a symbol error and I need to add -fPIC to the build flags. Sure, that's easy, except adding that doesn't make the error go away. I've cleaned the package install and it still thinks there's no -fPIC, so maybe the cmakelists isn't passing the flags all the way down to the makefile?
Strange that the previous version didn't have this issue.

Any and all advice is welcomed!
Reply
#2
Add
Code:
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
to the CMakeLists.txt of peripheral.joystick to enable -fPIC.

Please post the config and build log of peripheral.joystick to actually see what happens.
Reply
#3
I added that line to CMakeLists.txt but unfortunately it made no difference. Here's the output from the buildroot toolchain. Any other advice? 

(mkdir -p /home/adam/rb-c2/output/build/kodi-peripheral-joystick-80224e1466d113ccfd87ed76a00d36bbaeed1916/ && cd /home/adam/rb-c2/output/build/kodi-peripheral-joystick-80224e1466d113ccfd87ed76a00d36bbaeed1916/ && rm -f CMakeCache.txt && PATH="/home/adam/rb-c2/output/host/bin:/home/adam/rb-c2/output/host/sbin:/home/adam/bin:/home/adam/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"  /usr/bin/cmake /home/adam/rb-c2/output/build/kodi-peripheral-joystick-80224e1466d113ccfd87ed76a00d36bbaeed1916/ -DCMAKE_TOOLCHAIN_FILE="/home/adam/rb-c2/output/host/share/buildroot/toolchainfile.cmake" -DCMAKE_INSTALL_PREFIX="/usr" -DCMAKE_COLOR_MAKEFILE=OFF -DBUILD_DOC=OFF -DBUILD_DOCS=OFF -DBUILD_EXAMPLE=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TEST=OFF -DBUILD_TESTS=OFF -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=ON  -DPREFIX=/home/adam/rb-c2/output/target/recalbox/share_init/kodi -DKODI_INCLUDE_DIR=/home/adam/rb-c2/output/host/include/kodi -DCMAKE_C_FLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -O3  -fpic -marm -mfloat-abi=hard -mfpu=neon -march=armv8-a+crc -mcpu=cortex-a53" -DCMAKE_CXX_FLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -O3  -fpic -marm -mfloat-abi=hard -mfpu=neon -march=armv8-a+crc -mcpu=cortex-a53"  )
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: /home/adam/rb-c2/output/host/bin/arm-buildroot-linux-gnueabihf-gcc
-- Check for working C compiler: /home/adam/rb-c2/output/host/bin/arm-buildroot-linux-gnueabihf-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /home/adam/rb-c2/output/host/bin/arm-buildroot-linux-gnueabihf-g++
-- Check for working CXX compiler: /home/adam/rb-c2/output/host/bin/arm-buildroot-linux-gnueabihf-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Checking to see if CXX compiler accepts flag -flto
-- Checking to see if CXX compiler accepts flag -flto - yes
-- Looking for include file syslog.h
-- Looking for include file syslog.h - found
-- Looking for include file linux/joystick.h
-- Looking for include file linux/joystick.h - found
-- Checking for module 'libudev'
--   Found libudev, version 220
-- Found UDEV: /home/adam/rb-c2/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libudev.so  
-- JOYSTICK_VERSION=1.4.6
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    BUILD_DOC
    BUILD_DOCS
    BUILD_EXAMPLE
    BUILD_EXAMPLES
    BUILD_TEST
    BUILD_TESTING
    BUILD_TESTS


-- Build files have been written to: /home/adam/rb-c2/output/build/kodi-peripheral-joystick-80224e1466d113ccfd87ed76a00d36bbaeed1916
>>> kodi-peripheral-joystick 80224e1466d113ccfd87ed76a00d36bbaeed1916 Building
PATH="/home/adam/rb-c2/output/host/bin:/home/adam/rb-c2/output/host/sbin:/home/adam/bin:/home/adam/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"  /usr/bin/make -j5  -C /home/adam/rb-c2/output/build/kodi-peripheral-joystick-80224e1466d113ccfd87ed76a00d36bbaeed1916/
Scanning dependencies of target peripheral.joystick
[  2%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/addon.cpp.o
[  4%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/api/IJoystickInterface.cpp.o
[  6%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/api/JoystickManager.cpp.o
[  8%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/api/Joystick.cpp.o
[ 10%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/api/JoystickInterfaceCallback.cpp.o
[ 13%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/api/JoystickTranslator.cpp.o
[ 15%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/api/JoystickUtils.cpp.o
[ 17%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/api/PeripheralScanner.cpp.o
[ 19%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/buttonmapper/ButtonMapper.cpp.o
[ 21%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/buttonmapper/ButtonMapTranslator.cpp.o
[ 23%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/buttonmapper/ButtonMapUtils.cpp.o
[ 26%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/buttonmapper/ControllerTransformer.cpp.o
[ 28%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/buttonmapper/DriverGeometry.cpp.o
[ 30%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/buttonmapper/JoystickFamily.cpp.o
[ 32%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/filesystem/DirectoryCache.cpp.o
[ 34%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/filesystem/DirectoryUtils.cpp.o
[ 36%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/filesystem/Filesystem.cpp.o
[ 39%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/filesystem/FileUtils.cpp.o
[ 41%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/filesystem/generic/ReadableFile.cpp.o
[ 43%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/filesystem/generic/SeekableFile.cpp.o
[ 45%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/filesystem/vfs/VFSFileUtils.cpp.o
[ 47%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/filesystem/vfs/VFSDirectoryUtils.cpp.o
[ 50%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/log/Log.cpp.o
[ 52%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/log/LogAddon.cpp.o
[ 54%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/settings/Settings.cpp.o
[ 56%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/log/LogConsole.cpp.o
[ 58%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/storage/ButtonMap.cpp.o
[ 60%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/storage/Device.cpp.o
[ 63%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/storage/DeviceConfiguration.cpp.o
[ 65%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/storage/JustABunchOfFiles.cpp.o
[ 67%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/storage/MouseTranslator.cpp.o
[ 69%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/storage/StorageManager.cpp.o
[ 71%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/storage/StorageUtils.cpp.o
[ 73%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/storage/api/DatabaseJoystickAPI.cpp.o
[ 76%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/storage/xml/ButtonMapXml.cpp.o
[ 78%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/storage/xml/DatabaseXml.cpp.o
[ 80%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/storage/xml/DeviceXml.cpp.o
[ 82%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/storage/xml/JoystickFamiliesXml.cpp.o
[ 84%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/utils/StringUtils.cpp.o
[ 86%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/log/LogSyslog.cpp.o
[ 89%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/api/linux/JoystickInterfaceLinux.cpp.o
[ 91%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/api/linux/JoystickLinux.cpp.o
[ 93%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/api/udev/JoystickInterfaceUdev.cpp.o
[ 95%] Building CXX object CMakeFiles/peripheral.joystick.dir/src/api/udev/JoystickUdev.cpp.o
[ 97%] Linking CXX shared library peripheral.joystick.so
/home/adam/rb-c2/output/host/lib/gcc/arm-buildroot-linux-gnueabihf/5.5.0/../../../../arm-buildroot-linux-gnueabihf/bin/ld: CMakeFiles/peripheral.joystick.dir/src/addon.cpp.o: relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
CMakeFiles/peripheral.joystick.dir/src/addon.cpp.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
CMakeFiles/peripheral.joystick.dir/build.make:1218: recipe for target 'peripheral.joystick.so.1.4.6' failed
make[5]: *** [peripheral.joystick.so.1.4.6] Error 1
CMakeFiles/Makefile2:99: recipe for target 'CMakeFiles/peripheral.joystick.dir/all' failed
make[4]: *** [CMakeFiles/peripheral.joystick.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make[3]: *** [all] Error 2
package/pkg-generic.mk:234: recipe for target '/home/adam/rb-c2/output/build/kodi-peripheral-joystick-80224e1466d113ccfd87ed76a00d36bbaeed1916/.stamp_built' failed
make[2]: *** [/home/adam/rb-c2/output/build/kodi-peripheral-joystick-80224e1466d113ccfd87ed76a00d36bbaeed1916/.stamp_built] Error 2
Makefile:79: recipe for target '_all' failed
make[1]: *** [_all] Error 2
make[1]: Leaving directory '/home/adam/rb-c2/buildroot'
Makefile:25: recipe for target 'buildBR' failed
make: *** [buildBR] Error 2
Reply
#4
As an additional detail, reverting commit 5063c97 from addon.cpp allows it to compile successfully, but then fails with the same error on another file. So there's clearly something in the code causing the issue. I don't want to revert too many commits in fear of making Leia tell me the addon is not compatible. Is that just a version number check or what?
Reply
#5
You pass -fpic not -fPIC in your C and CXX flags.
Could fix your issue as your linker tells 'recompile with -fPIC'.
Reply
#6
yes, those flag are case sensitive
Reply
#7
I have indeed tried it with both values, the uppercase -fPIC and the lowercast -fpic. Neither has had any effect and the error is exactly the same.
Reply
#8
the most likely reason is that you link against some system lib(provided by build-root) that was not compiled with PIC.
Hard to debug this without knowing the environment. Fact is that kodi compiles fine on normal linux, as well as with our depends system.
Reply
#9
I have confirmed this is an issue specific to the way the source is setup to pass CXX flags all the way down to CMAKE. I was able to get it to successfully compile by hacking CMAKE.

Some background...
Using the buildroot toolchain, within the package (mk) file you can update the CMAKE C and CXX flags by doing this (using KODI for example because I know this works and have tested it): KODI_CONF_OPTS += -DCMAKE_C_FLAGS="$(TARGET_CFLAGS) $(KODI_C_FLAGS)"
Following this same process, I appended this to the project for peripherals.joystick: 
KODI_PERIPHERAL_JOYSTICK_CONF_OPTS += \
    -DPREFIX=$(TARGET_DIR)/recalbox/share_init/kodi \
    -DKODI_INCLUDE_DIR=$(TARGET_DIR)/usr/include/kodi \
    -DCMAKE_C_FLAGS="$(TARGET_CFLAGS) -DPIC -fPIC" \
    -DCMAKE_CXX_FLAGS="$(TARGET_CXXFLAGS)  -DPIC -fPIC" 

Unfortunately adding those values did not resolve the issue. I tried uppercase and lowercase, as well as some other flags such as -mword-relocations. Nothing resolved it.

So I cleared the source for this package and let it begin the compile fresh and then fail with the error I posted above. Then I browsed into the build directory for this app and manually updated the file CMakeFiles/peripheral.joystick.dir/build.make. I manually added -fPIC to every build command for every file listed (fixing just the addon.cpp.o was not sufficient, as fixing just that one would cause another to fail with the same error). Here is an example of one of the lines I added to:
    /home/adam/rb-c2/output/host/bin/arm-buildroot-linux-gnueabihf-g++   $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -fPIC -o CMakeFiles/peripheral.joystick.dir/src/api/JoystickInterfaceCallback.cpp.o -c /home/adam/rb-c2/output/build/kodi-peripheral-joystick-80224e1466d113ccfd87ed76a00d36bbaeed1916/src/api/JoystickInterfaceCallback.cpp

Then I deleted all the compiled files under the CMakeFiles/peripheral.joystick.dir/src folder and ran make again to rebuild them all with the new parameter I added. 

The project then compiles and links successfully. So essentially the CXX flags that I define in the package (mk) files are not getting passed all the way down to the build.make file at compile time. Until this is fixed the package will not compile successfully without the hand-holding that I have described. Please advise.
Reply
#10
As an aside... after all that... Leia still says that the joystick support addon is not supported Sad What am I missing here? I compiled commit 80224e1466d113ccfd87ed76a00d36bbaeed1916, which is the newest available version. Why doesn't Leia see this as compatible?
Reply
#11
mind trying https://github.com/wsnipex/xbmc/commit/5...b2d40634bd instead of hacking cxx_flags

as for kodi "not seeing" the addon: provide a Debug Log
Reply
#12
Yep that worked much better Smile Thanks!
Reply

Logout Mark Read Team Forum Stats Members Help
Compiling peripheral.joystick issue0