Ich bin Crosscompile eine Software für ARM Cortex A8 und mit CMAKE-Tool Makefile zu generieren.Linux Cross Compiling Linker Problem mit undefinierten Verweis auf `g_thread_init 'und` org_freedesktop_DBus_request_name'
meine CMakeLists.txt Datei ist als unten
cmake_minimum_required(VERSION 2.8)
PROJECT(sierra-software)
include_directories($ENV{PREFIX}/include/sierra)
include_directories($ENV{PREFIX}/include/glib-2.0)
include_directories($ENV{PREFIX}/lib/glib-2.0/include)
include_directories($ENV{PREFIX}/include)
include_directories($ENV{PREFIX}/include/dbus-1.0)
include_directories($ENV{PREFIX}/lib/dbus-1.0/include)
find_package(PkgConfig)
# target_include_directories(sierra PUBLIC $<BUILD_INTERFACE:$ENV{PREFIX}/include>
# use, i.e. don't skip the full RPATH for the build tree
# SET(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
# SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
# the RPATH to be used when installing
# SET(CMAKE_INSTALL_RPATH "/home/deep/projects/code/build/lib")
IF(CMAKE_CROSSCOMPILING)
set(CMAKE_INSTALL_PREFIX $ENV{PREFIX})
# add_definitions(-g)
# SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
# add_definitions(-O3 -Wall -c -fmessage-length=0)
ELSE(CMAKE_CROSSCOMPILING)
add_definitions(-DSIMULATE_FIFOS -O3 -g)
set(CMAKE_INSTALL_PREFIX /home/host/satsys/usr)
ENDIF(CMAKE_CROSSCOMPILING)
include_directories(${GTHREAD_INCLUDE_DIRS} ${DBUS_GLIB_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS})
link_directories(${GTHREAD_LIBRARY_DIRS} ${DBUS_GLIB_LIBRARY_DIRS} ${GLIB2_LIBRARY_DIRS})
include_directories(NetSerSel/src TrackingData/src ClientExternalGPS/src AlsaSierraConf/src Discretes/src alsa_relay/src smsHandle/src DBUSBaseConnection/src ClientModemsCommunication/src)
add_subdirectory(NetSerSel)
add_subdirectory(Discretes)
add_subdirectory(TrackingData)
add_subdirectory(ClientExternalGPS)
add_subdirectory(AlsaSierraConf)
add_subdirectory(alsa_relay)
add_subdirectory(smsHandle)
add_subdirectory(ModemsManagement)
add_subdirectory(TrackingManagement)
add_subdirectory(serveur_sierra)
add_subdirectory(ModemTalk)
add_subdirectory(DspicTalk)
add_subdirectory(send_msg)
add_subdirectory(get_data)
folgenden Befehl I Makefile erzeugen
[linux-devkit]:~/projects/code/src/sierra-software> cmake -DCMAKE_TOOLCHAIN_FILE=./arm.cmake
-- The C compiler identification is GNU 4.7.3
-- The CXX compiler identification is GNU 4.7.3
-- Check for working C compiler: /home/deep/ti-sdk-am335x-evm-07.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin/arm-linux-gnueabihf-gcc
-- Check for working C compiler: /home/deep/ti-sdk-am335x-evm-07.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin/arm-linux-gnueabihf-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working CXX compiler: /home/deep/ti-sdk-am335x-evm-07.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin/arm-linux-gnueabihf-g++
-- Check for working CXX compiler: /home/deep/ti-sdk-am335x-evm-07.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin/arm-linux-gnueabihf-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Found PkgConfig: /home/deep/ti-sdk-am335x-evm-07.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin/pkg-config (found version "0.25")
-- checking for module 'alsa'
-- found alsa, version 1.0.26
-- checking for module 'dbus-1'
-- found dbus-1, version 1.6.8
-- checking for module 'glib-2.0'
-- found glib-2.0, version 2.34.3
-- checking for module 'dbus-glib-1'
-- found dbus-glib-1, version 0.100.2
-- checking for module 'gthread-2.0'
-- found gthread-2.0, version 2.34.3
-- checking for module 'glib-2.0'
-- found glib-2.0, version 2.34.3
-- Configuring done
-- Generating done
-- Build files have been written to: /home/deep/projects/code/src/sierra-software
wenn ich kompilieren Projekt Befehl machen gibt sie Fehler folgende [
linux-devkit]:~/projects/code/src/sierra-software> make
Scanning dependencies of target NetSerSel
[ 2%] Building C object NetSerSel/CMakeFiles/NetSerSel.dir/src/libNetSerSel.c.o
Linking C static library libNetSerSel.a
[ 2%] Built target NetSerSel
Scanning dependencies of target Discretes
[ 5%] Building C object Discretes/CMakeFiles/Discretes.dir/src/libDiscretes.c.o
Linking C static library libDiscretes.a
[ 5%] Built target Discretes
Scanning dependencies of target TrackingData
[ 7%] Building C object TrackingData/CMakeFiles/TrackingData.dir/src/libTrackingData.c.o
Linking C static library libTrackingData.a
[ 7%] Built target TrackingData
Scanning dependencies of target ClientExternalGPS
[ 10%] Building C object ClientExternalGPS/CMakeFiles/ClientExternalGPS.dir/src/libClientSharedExtGPSInfo.c.o
Linking C static library libClientExternalGPS.a
[ 10%] Built target ClientExternalGPS
Scanning dependencies of target AlsaSierraConf
[ 12%] Building C object AlsaSierraConf/CMakeFiles/AlsaSierraConf.dir/src/AlsaSierraConf.c.o
Linking C static library libAlsaSierraConf.a
[ 12%] Built target AlsaSierraConf
Scanning dependencies of target alsa_relay
[ 15%] Building C object alsa_relay/CMakeFiles/alsa_relay.dir/src/alsa_relay.c.o
Linking C static library libalsa_relay.a
[ 15%] Built target alsa_relay
Scanning dependencies of target smsHandle
[ 17%] Building C object smsHandle/CMakeFiles/smsHandle.dir/src/smsHandle.c.o
Linking C static library libsmsHandle.a
[ 17%] Built target smsHandle
Scanning dependencies of target ModemsManagement
[ 20%] Building C object ModemsManagement/CMakeFiles/ModemsManagement.dir/src/marshaller.c.o
[ 22%] Building C object ModemsManagement/CMakeFiles/ModemsManagement.dir/src/libGSM.c.o
[ 25%] Building C object ModemsManagement/CMakeFiles/ModemsManagement.dir/src/libIridium.c.o
[ 27%] Building C object ModemsManagement/CMakeFiles/ModemsManagement.dir/src/Tools.c.o
[ 30%] Building C object ModemsManagement/CMakeFiles/ModemsManagement.dir/src/libsms.c.o
[ 32%] Building C object ModemsManagement/CMakeFiles/ModemsManagement.dir/src/libDspic.c.o
[ 35%] Building C object ModemsManagement/CMakeFiles/ModemsManagement.dir/src/libGC864.c.o
[ 37%] Building C object ModemsManagement/CMakeFiles/ModemsManagement.dir/src/main.c.o
[ 40%] Building C object ModemsManagement/CMakeFiles/ModemsManagement.dir/src/libSharedDevicesInfo.c.o
[ 42%] Building C object ModemsManagement/CMakeFiles/ModemsManagement.dir/src/libSharedModemsInfo.c.o
[ 45%] Building C object ModemsManagement/CMakeFiles/ModemsManagement.dir/src/libDBusModemsManagement.c.o
/home/deep/projects/code/src/sierra-software/ModemsManagement/src/libDBusModemsManagement.c: In function ‘InitDbus’:
/home/deep/projects/code/src/sierra-software/ModemsManagement/src/libDBusModemsManagement.c:149:2: warning: ‘g_type_init’ is deprecated (declared at /home/deep/projects/code/build/include/glib-2.0/gobject/gtype.h:681) [-Wdeprecated-declarations]
/home/deep/projects/code/src/sierra-software/ModemsManagement/src/libDBusModemsManagement.c:150:2: warning: ‘g_thread_init’ is deprecated (declared at /home/deep/projects/code/build/include/glib-2.0/glib/deprecated/gthread.h:265) [-Wdeprecated-declarations]
[ 47%] Building C object ModemsManagement/CMakeFiles/ModemsManagement.dir/src/libSMSmanagement.c.o
[ 50%] Building C object ModemsManagement/CMakeFiles/ModemsManagement.dir/src/libSBD960x.c.o
[ 52%] Building C object ModemsManagement/CMakeFiles/ModemsManagement.dir/src/libModem.c.o
[ 55%] Building C object ModemsManagement/CMakeFiles/ModemsManagement.dir/src/DList.c.o
[ 57%] Building C object ModemsManagement/CMakeFiles/ModemsManagement.dir/src/SFifo.c.o
[ 60%] Building C object ModemsManagement/CMakeFiles/ModemsManagement.dir/src/libThuraya.c.o
[ 62%] Building C object ModemsManagement/CMakeFiles/ModemsManagement.dir/src/DiscretesFifo.c.o
[ 65%] Building C object ModemsManagement/CMakeFiles/ModemsManagement.dir/src/MList.c.o
[ 67%] Building C object ModemsManagement/CMakeFiles/ModemsManagement.dir/src/pduconv.c.o
[ 70%] Building C object ModemsManagement/CMakeFiles/ModemsManagement.dir/src/KList.c.o
Linking C executable ModemsManagement
CMakeFiles/ModemsManagement.dir/src/libDBusModemsManagement.c.o: In function `InitDbus':
libDBusModemsManagement.c:(.text+0x162c): undefined reference to `g_thread_init'
libDBusModemsManagement.c:(.text+0x17b0): undefined reference to `org_freedesktop_DBus_request_name'
collect2: error: ld returned 1 exit status
ModemsManagement/CMakeFiles/ModemsManagement.dir/build.make:590: recipe for target 'ModemsManagement/ModemsManagement' failed
make[2]: *** [ModemsManagement/ModemsManagement] Error 1
CMakeFiles/Makefile2:429: recipe for target 'ModemsManagement/CMakeFiles/ModemsManagement.dir/all' failed
make[1]: *** [ModemsManagement/CMakeFiles/ModemsManagement.dir/all] Error 2
Makefile:117: recipe for target 'all' failed
make: *** [all] Error 2
Der Fehler zeigt deutlich, dass das Problem mit der Verknüpfung von 012 verbunden istIch habe überprüft, libgthread.so Pfad zu Toolchain Lib-Ordner und auch libgib-2.0.so Bibliothek ordnungsgemäß enthalten.
schlagen Sie bitte vor, wie Sie dieses undefinierte Referenzproblem lösen.
** Die Verknüpfung ** wird mit dem Befehl 'target_link_libraries' durchgeführt, ist jedoch in dem von Ihnen angegebenen Code nicht vorhanden. – Tsyvarev
ja target_link_libraries sind in Unterverzeichnisse enthalten, wo CMakeLists.txt zum Beispiel in ModemsManagement Verzeichnis enthalten target_link_libraries (ModemsManagement Pthread $ {DBUS_LIBRARIES} $ {GLIB_LIBRARIES} $ {DBUS_GLIB_LIBRARIES} $ {} ALSA_LIBRARIES alsa_relay sierra_fifo asound AlsaSierraConf NetSerSel Discretes ClientExternalGPS mz) installieren (ZIELE ModemsManagement RUNTIME DESTINATION bin ) – Deep
Bitte, bieten [MCVE]. Ohne genaue Befehle (und Argumente) anzuzeigen, die Sie verwenden, ist es schwierig, etwas vorzuschlagen. Derzeit enthält der Code eine Menge Dinge, die nichts mit dem Problem zu tun haben (wie das Installieren von Features) und wichtige Informationen (wie 'pkg_check_modules()' Aufrufe oder Anpassungen für Pthread) vermissen lassen. Mach das via [edit] deinen Beitrag, nicht in Kommentaren. – Tsyvarev