저는 cmake를 사용하고 있습니다. cmake를 사용하여 랩톱에서 프로젝트를 컴파일 할 수 있었지만 라스베리에서는 작동하지 않습니다.CMake는 라스베리에 컴파일하지 않습니다.
cmake_minimum_required (VERSION 2.6)
project (TestPL)
include_directories("${PROJECT_BINARY_DIR}")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
find_package(GLIB REQUIRED)
find_package(MHD REQUIRED)
add_subdirectory (librerie)
set (EXTRA_LIBS ${EXTRA_LIBS} librerie)
include_directories (${GLib_INCLUDE_DIRS} ${EXTRA_LIBS})
# add the executable
add_executable(TestPL main.c)
target_link_libraries (TestPL ${GLib_LIBRARY} ${MHD_LIBRARY} ${EXTRA_LIBS} m)
이 librerie에서 CMakeLists입니다 :
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.28")
-- checking for one of the modules 'glib-2.0'
-- Found GLib: /usr/lib/arm-linux-gnueabihf/libglib-2.0.so (found version "2.42.1")
-- Found mhd: /usr/include
CMake Error at cmake/FindGLIB.cmake:39 (add_library): add_library cannot create imported target "glib-2.0" because another target with the same name already exists.
Call Stack (most recent call first):librerie/CMakeLists.txt:2 (find_package)
-- Found GLib: /usr/lib/arm-linux-gnueabihf/libglib-2.0.so (found version "2.42.1")
-- Configuring incomplete, errors occurred!
See also "/home/pi/pl1/CMakeFiles/CMakeOutput.log".
이 내 프로젝트 구조입니다 :
이
내가 라즈베리에 얻을 오류입니다src->
---- CMakeLists.txt
---- main.c
---- librerie->
-------------- CMakeLists.txt
-------------- cJSON.c
-------------- cJSON.h
-------------- config.c
-------------- config.h
-------------- server_web.c
-------------- server_web.h
-------------- funzioni_thread.c
-------------- funzioni_thread.h
---- cmake->
-------------- FindGLIB.cmake
-------------- FindMHD.cmake
이 먼저 CMakeLists입니다 디렉토리 :
find_package(GLIB REQUIRED)
find_package(MHD REQUIRED)
include_directories (${GLib_INCLUDE_DIRS} ${EXTRA_LIBS})
add_library (librerie cJSON.c config.c generic.c server_web.c funzioni_thread.c)
target_link_libraries (librerie ${GLib_LIBRARY} ${MHD_LIBRARY})
내가 뭘 잘못하고 있니?
대단히 감사합니다! 그게 문제 였어, 지금은 효과가있다! 내가 이해하지 못하는 이유는 내 랩톱에서의 잘못된 길조차도 조용하게 작동하는 이유입니다. – Mex
아마 랩톱에 가져온 대상 대신 변수를 정의하는 'FindGLIB.cmake' 스크립트가 다릅니다. 목표와 달리 변수의 재정의는 CMake의 오류가 아닙니다. – Tsyvarev
FindGLIB.cmake 스크립트는 라즈베리와 랩톱에서 동일합니다. 모든 프로젝트 파일을 복사했는데 팔에서는 다르게 작업합니까?, boh, 어쨌든, 다시 한 번 감사드립니다! – Mex