Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何使用CMakeLists.txt中的cmake链接编译器的交叉编译libpcap库_C++_Cmake_Libpcap - Fatal编程技术网

C++ 如何使用CMakeLists.txt中的cmake链接编译器的交叉编译libpcap库

C++ 如何使用CMakeLists.txt中的cmake链接编译器的交叉编译libpcap库,c++,cmake,libpcap,C++,Cmake,Libpcap,我正在使用libpcap从连接到基于linux的ARM AARC64硬件的以太网接口捕获一些UDP数据包。我用Ubuntu 16.04在主机上编译代码,使用CMA3.3.1,LIPPCAP1.91,代码是用C++编写的。p> 为了交叉编译libpcap,我遵循以下链接()。交叉编译后,我需要将这些交叉编译的目标库添加到CMakeLists.txt中,以便cmake编译器理解。 我想了解如何在CMakeLists.txt文件中以何种方式添加这些链接 我现在有两个CMakeLists.txt。一个用

我正在使用libpcap从连接到基于linux的ARM AARC64硬件的以太网接口捕获一些UDP数据包。我用Ubuntu 16.04在主机上编译代码,使用CMA3.3.1,LIPPCAP1.91,代码是用C++编写的。p> 为了交叉编译libpcap,我遵循以下链接()。交叉编译后,我需要将这些交叉编译的目标库添加到CMakeLists.txt中,以便cmake编译器理解。 我想了解如何在CMakeLists.txt文件中以何种方式添加这些链接

我现在有两个CMakeLists.txt。一个用于大项目文件夹,另一个位于项目文件夹的源文件夹内。我的文件夹结构如下所示: 伊思·里德 ->构建主机 ->建立目标 ->克马克 ->src ->伊思·里德 ->main.cpp ->CMakeLists.txt(子CMakeLists.txt) ->CMakeLists.txt(对于项目,main-CMakeLists.txt)

我有一个main.cpp,其中我使用pcap.h中的函数打开接口,捕获数据包,并使用回调函数处理这些数据包

我想知道如何在CMakeLists.txt中添加交叉编译库,并在硬件中使用交叉编译的二进制文件来侦听以太网接口。
如果我在这里遗漏了什么或做了什么错事,请告诉我。

您看过在CMake中链接库的内容吗?交叉编译库的链接方式与普通库相同。(当然,你也需要交叉编译你的项目)。这能回答你的问题吗?
--The main CMakeLists.txt is as below:
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(PCAP_LIBRARY /home/rsidhan1/Downloads/libpcap-1.9.1/libpcap.so.1.9.1) // this file was created after building for ARM 

Project(Testing C CXX)

include_directories(/home/rsidhan1/Downloads/libpcap-1.9.1/)

set(PROJECTS eth_read)

foreach(PROJECT ${PROJECTS})
    add_subdirectory(src/${PROJECT})
endforeach()



--The sub CMakeLists.txt is as below:
project(eth_read C CXX)

set(PUBLIC_DOCS
    README.md
)

set(SOURCES
    main.cpp   
)

target_link_libraries(eth_read /home/rsidhan1/Downloads/libpcap-1.9.1/)