im currently converting a Qt Creator project to a cmake project and can't compile my program anymore. Im using the Library PcapPlusPlus as a submodule because we did some major changes to the original library. I use the buildchain suggested in their instructions and use "./configure-linux --default" and "make libs" within the submodule. So the path to the *.a files are correct. Also mentioning that the project can still be compiled with Qt Creator (which also has the same dependencies).
This is my CMakeLists.txt:
cmake_minimum_required(VERSION 3.16)
project(mitm)
set(CMAKE_PREFIX_PATH ~/Qt/5.15.0/gcc_64/lib/cmake/)
#pthread
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
#pcap
include(FindPCAP.cmake)
find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets REQUIRED)
set(CMAKE_CXX_STANDARD 14)
include_directories(.)
include_directories("${CMAKE_SOURCE_DIR}/../Pcap++/header/")
include_directories("${CMAKE_SOURCE_DIR}/../Packet++/header/")
include_directories("${CMAKE_SOURCE_DIR}/../Common++/header/")
add_executable(mitm "")
set_target_properties(mitm PROPERTIES
AUTOMOC ON
AUTOUIC ON
AUTORCC ON)
set(SOURCE_FILES
classes/base/wrapper/connection.cpp
classes/base/wrapper/connection.h
classes/base/wrapper/connectionlist.cpp
classes/base/wrapper/connectionlist.h
classes/base/wrapper/hostlist.cpp
classes/base/wrapper/hostlist.h
classes/base/connectionmanager.cpp
classes/base/connectionmanager.h
main.cpp
wmain.cpp
wmain.h
wmain.ui
wsetup.cpp
wsetup.h
wsetup.ui)
set(RESOURCE_FILES
fonts.qrc)
target_sources(mitm PRIVATE
${SOURCE_FILES}
${RESOURCE_FILES})
target_link_libraries(mitm PRIVATE
Qt5::Widgets
"${CMAKE_SOURCE_DIR}/../Common++/Lib/Release/libCommon++.a"
"${CMAKE_SOURCE_DIR}/../Pcap++/Lib/libPcap++.a"
"${CMAKE_SOURCE_DIR}/../Packet++/Lib/libPacket++.a"
Threads::Threads
${PCAP_LIBRARY}
)
/usr/bin/ld: ../../Pcap++/Lib/libPcap++.a(PcapLiveDevice.o): in function `pcpp::PcapLiveDevice::startCaptureBlockingMode(bool (*)(pcpp::RawPacket*, pcpp::PcapLiveDevice*, void*), void*, int)':
/home/bemerged/Documents/Git/mitm/Pcap++/src/PcapLiveDevice.cpp:492: undefined reference to `pcpp::clockGetTime(long&, long&)'
/usr/bin/ld: /home/bemerged/Documents/Git/mitm/Pcap++/src/PcapLiveDevice.cpp:512: undefined reference to `pcpp::clockGetTime(long&, long&)'
/usr/bin/ld: ../../Pcap++/Lib/libPcap++.a(PcapLiveDevice.o): in function `pcpp::PcapLiveDevice::getIPv4Address() const':
/home/bemerged/Documents/Git/mitm/Pcap++/src/PcapLiveDevice.cpp:905: undefined reference to `pcpp::sockaddr2in_addr(sockaddr*)'
/usr/bin/ld: /home/bemerged/Documents/Git/mitm/Pcap++/src/PcapLiveDevice.cpp:901: undefined reference to `pcpp::sockaddr2string(sockaddr*, char*)'
/usr/bin/ld: /home/bemerged/Documents/Git/mitm/Pcap++/src/PcapLiveDevice.cpp:905: undefined reference to `pcpp::sockaddr2in_addr(sockaddr*)'
/usr/bin/ld: ../../Pcap++/Lib/libPcap++.a(PcapLiveDevice.o): in function `pcpp::PcapLiveDevice::PcapLiveDevice(pcap_if*, bool, bool, bool)':
/home/bemerged/Documents/Git/mitm/Pcap++/src/PcapLiveDevice.cpp:101: undefined reference to `pcpp::sockaddr2string(sockaddr*, char*)'
Im pretty new to cmake und tried my best so far. Im sure this is a linking problem within the pcap++ library. As you might guess I googled around 2 hours now and found nothing to solve my problem.