How to properly use dockcross for cross-compilation?

Viewed 1820

Some Background

I am trying to cross-compile an app I have for RaspberryPi 3B. I have installed dockcross as below:

docker run --rm dockcross/linux-armv6 > ./dockcross
chmod +x ./dockcross
mv ./dockcross ~/bin/

On my host, macOS high sierra, I can compile and link without a problem.

Issue

First I run: dockcross cmake -Bbuild -H.. After that running dockcross make, naturally, compiler gives an error: <some-lib/some-lib.h> not found.

After this I accessed the container bash by dockcross bash and installed all missing libs and their headers to container. Unfortunately, error is same and compiler can't find headers. Contents of my CMakeLists.txt:

cmake_minimum_required (VERSION 3.0)
project (myLibProject)

include_directories(
    .
    /usr/include
)

link_directories(
    /usr/lib
)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

file(GLOB SOURCES
    "include/*.h"
    "src/*.cpp"
)

add_library(myLibProject ${SOURCES})

target_link_libraries(myLibProject some-lib)

When dry-run make - make -n - I can't see the include directive for folders other than current - . - folder :

/usr/bin/arm-linux-gnueabihf-g++   -I/work/.  -std=c++11   -o CMakeFiles/myLibProject.dir/src/src1.cpp.o -c /work/src/src1.cpp

If I manually run the above command by adding -I/usr/include, compiler successfully compiles src1.cpp.o

Questions

  1. Why CMake haven't picked-up other directories? They are present at container linux.

  2. My project have a lot of dependencies, for example boost. How should I modify my CMakeLists.txt to properly compile my projects using dockcross?

0 Answers
Related