Giter Site home page Giter Site logo

Comments (5)

BillyDonahue avatar BillyDonahue commented on May 28, 2024

Does this cmake invocation usually work? Can you cross-compile other projects successfully with those options?

from jsoncpp.

Derrekito avatar Derrekito commented on May 28, 2024

I appreciate your response. However, I usually avoid cmake, so I cannot adequately answer your question. But I've tried
passing some of these cross-compilation flags directly and also by creating
and passing a toolchain file.

https://cmake.org/cmake/help/book/mastering-cmake/chapter/Cross%20Compiling%20With%20CMake.html

Here's my aarch-toochain.cmake file

# aarch64-toolchain.cmake

# Set the target system name
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)

# Set the cross compilers
set(bin_path /usr/bin)
set(CMAKE_C_COMPILER ${bin_path}/aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${bin_path}/aarch64-linux-gnu-g++)

# Set the target architecture
set(CMAKE_SYSTEM_PROCESSOR aarch64)

here's my cmake .. -DCMAKE_TOOLCHAIN_FILE=../aarch-toolchain.cmake output

-- The CXX compiler identification is GNU 11.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/aarch64-linux-gnu-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- JsonCpp Version: 00.11.0
-- Compiled with C++11(or newer) standard!
-- Looking for C++ include clocale
-- Looking for C++ include clocale - found
-- Looking for localeconv
-- Looking for localeconv - found
-- Looking for C++ include sys/types.h
-- Looking for C++ include sys/types.h - found
-- Looking for C++ include stdint.h
-- Looking for C++ include stdint.h - found
-- Looking for C++ include stddef.h
-- Looking for C++ include stddef.h - found
-- Check size of lconv
-- Check size of lconv - done
-- Performing Test HAVE_DECIMAL_POINT
-- Performing Test HAVE_DECIMAL_POINT - Success
-- Found Python3: /usr/bin/python3.10 (found version "3.10.12") found components: Interpreter
-- Configuring done
-- Generating done
-- Build files have been written to: /home/derrekito/Downloads/jsoncpp/build

It seems to skip looking at CXX processor, which makes me think this has something to do with the project defaulting to my host compiler.

from jsoncpp.

BillyDonahue avatar BillyDonahue commented on May 28, 2024

I don't know cmake very well.

This line is very suspicious:

    -- Check for working CXX compiler: /usr/bin/aarch64-linux-gnu-g++ - skipped

There's sometimes a config log you can look at to see deeper diagnostics?
Maybe someone else with more cmake experience can chime in?

from jsoncpp.

Derrekito avatar Derrekito commented on May 28, 2024

My CMakeCache.txt seems to suggest that CMAKE is recognizing the cross-compile args, but isn't actually producing a cross-compiled object.

cat CMakeCache.txt | grep aarch64
CMAKE_ADDR2LINE:FILEPATH=/usr/bin/aarch64-linux-gnu-addr2line
CMAKE_AR:FILEPATH=/usr/bin/aarch64-linux-gnu-ar
CMAKE_CXX_COMPILER_AR:FILEPATH=/usr/bin/aarch64-linux-gnu-gcc-ar-11
CMAKE_CXX_COMPILER_RANLIB:FILEPATH=/usr/bin/aarch64-linux-gnu-gcc-ranlib-11
CMAKE_LINKER:FILEPATH=/usr/bin/aarch64-linux-gnu-ld
CMAKE_NM:FILEPATH=/usr/bin/aarch64-linux-gnu-nm
CMAKE_OBJCOPY:FILEPATH=/usr/bin/aarch64-linux-gnu-objcopy
CMAKE_OBJDUMP:FILEPATH=/usr/bin/aarch64-linux-gnu-objdump
CMAKE_RANLIB:FILEPATH=/usr/bin/aarch64-linux-gnu-ranlib
CMAKE_READELF:FILEPATH=/usr/bin/aarch64-linux-gnu-readelf
CMAKE_STRIP:FILEPATH=/usr/bin/aarch64-linux-gnu-strip
CMAKE_TOOLCHAIN_FILE:FILEPATH=/home/derrekito/Downloads/jsoncpp/aarch64-toolchain.cmake

from jsoncpp.

Derrekito avatar Derrekito commented on May 28, 2024

CMakeLists.txt is overriding the compiler settings. Commenting out the set(CMAKE_CXX_COMPILER "/usr/bin/g++") line fixed my issue.

file lib/libjsoncpp.so.00.11.0
lib/libjsoncpp.so.00.11.0: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=c0f7bfaca719ab7e6a28dd6f21a382192cdebff2, not stripped

I'll edit the CMakeLists.txt to check for the flag before clobbering such settings.

if(NOT CMAKE_CXX_COMPILER)
    set(CMAKE_CXX_COMPILER "/usr/bin/g++")
endif()

The only issue now is that tests fail when the compiled object isn't meant for the host system. Should I press with a pull request anyway??

from jsoncpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.