What should I do with C ++ libraries for cross-compiling?

Here is my part of my compiler:

IF(UNIX)
    ## Compiler flags

    # specify the cross compiler
    SET(CMAKE_C_COMPILER   /home/username/projects/buildroot/output/host/usr/bin/arm-linux-gcc)
    SET(CMAKE_CXX_COMPILER /home/username/projects/buildroot/output/host/usr/bin/arm-linux-g++)

    if(CMAKE_COMPILER_IS_GNUCXX)
        set(CMAKE_CXX_FLAGS "-O3")
        set(CMAKE_EXE_LINKER_FLAGS "-lsqlite3 -lrt -lpthread")
    endif()

    target_link_libraries(complex
      ${Boost_FILESYSTEM_LIBRARY}
      ${Boost_SYSTEM_LIBRARY})
ENDIF(UNIX)

There are 3 problems: -lsqlite3 -lrt -lpthread

How do I make them for my architecture and point here? How to set (using set?) The path of compiled libraries after I recompile them in some way for my architecture?

+3
source share
2 answers

If you want to cross-compile with CMake, you really need to use a tool binding file for this. See the CMake Wiki for an introduction. To use third-party libraries (i.e., not included in the cross-compilation toolchain), you also need to cross-compile them.

. toolchain buildroot, CMake. -DCMAKE_TOOLCHAIN_FILE=/home/username/projects/buildroot/output/toolchainfile.cmake CMake. CMAKE_C_COMPILER CMAKE_CXX_COMPILER CMakeLists.txt. , CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS .

, sqlite3 buildroot, , . :

find_path(SQLITE3_INCLUDE_DIR sqlite3.h)
find_library(SQLITE3_LIBRARY sqlite3)
if(NOT SQLITE3_INCLUDE_DIR)
  message(SEND_ERROR "Failed to find sqlite3.h")
endif()
if(NOT SQLITE3_LIBRARY)
  message(SEND_ERROR "Failed to find the sqlite3 library")
endif()

find_package(Threads REQUIRED)

# ...

target_link_libraries(complex
  ${Boost_FILESYSTEM_LIBRARY}
  ${Boost_SYSTEM_LIBRARY}
  ${SQLITE3_LIBRARY}
  ${CMAKE_THREAD_LIBS_INIT}
  rt)

, CMAKE_CXX_FLAGS -O3. -DCMAKE_BUILD_TYPE=Release .

+6

. , .

Btw., -lpthread, POSIX. -pthread , .

+2

All Articles