Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross-compile using CMake #243

Closed
brunoluiz opened this issue Apr 13, 2015 · 3 comments
Closed

Cross-compile using CMake #243

brunoluiz opened this issue Apr 13, 2015 · 3 comments
Labels

Comments

@brunoluiz
Copy link

Hi,

I am trying to cross-compile from my amd64 computer to an armhf BeagleBone. With other libraries I simply pass some arguments to ./configure and it prepare necessary Makefile. Then I compile and save it at /usr/arm-linux-gnueabihf.

How I do that for libjsoncpp?

@cdunn2001
Copy link
Contributor

This is really a cmake question. Here is a link that might help.

FWIW, I suggest considering a new language called nim (aka nimlang, formerly nimrod).

@brunoluiz
Copy link
Author

I solved it using this toolchain file: http://sourceforge.net/p/crengine/crengine/ci/master/tree/tools/toolchain-arm-linux-gnueabi.cmake

# CMake toolchain file for building ARM software on OI environment

# this one is important
SET(CMAKE_SYSTEM_NAME Linux)
#this one not so much
SET(CMAKE_SYSTEM_VERSION 1)

# specify the cross compiler
SET(CMAKE_C_COMPILER   /usr/bin/arm-linux-gnueabihf-gcc)
SET(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++)
SET(CMAKE_STRIP /usr/bin/arm-linux-gnueabihf-strip)

# where is the target environment 
SET(CMAKE_FIND_ROOT_PATH  /usr/arm-linux-gnueabihf)

# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

I am using an Ubuntu 14.04 and did the same thing of README.md guide, but with some modifications:

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=None -DJSONCPP_LIB_BUILD_STATIC=ON -DJSONCPP_LIB_BUILD_SHARED=ON -DCMAKE_INSTALL_PREFIX=/usr/arm-linux-gnueabihf -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-arm-linux-gnueabihf.cmake -G "Unix Makefiles" ..
make
sudo make install

@cdunn2001
Copy link
Contributor

Thanks! I added this to the wiki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants