首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不编译c++程序,缺少配置cmake文件

不编译c++程序,缺少配置cmake文件
EN

Stack Overflow用户
提问于 2022-05-21 18:47:58
回答 2查看 254关注 0票数 1

试图在debian上编译dot11decrypt,安装了apt-get install libtins4.0apt-get install libtins-dev,但是cmake ..找不到包libtins,下面是错误:

代码语言:javascript
复制
CMake Error at CMakeLists.txt:4 (FIND_PACKAGE):
By not providing "Findlibtins.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "libtins", but
CMake did not find one.

Could not find a package configuration file provided by "libtins" with any
of the following names:

libtinsConfig.cmake
libtins-config.cmake

Add the installation prefix of "libtins" to CMAKE_PREFIX_PATH or set
"libtins_DIR" to a directory containing one of the above files.  If
"libtins" provides a separate development package or SDK, be sure it has
been installed.


-- Configuring incomplete, errors occurred!
See also "/home/user/dot11decrypt/build/CMakeFiles/CMakeOutput.log".

cat:dot11Dect/CMakeLists.txt

代码语言:javascript
复制
1. CMAKE_MINIMUM_REQUIRED(VERSION 2.8.1)
2. PROJECT(dot11decrypt)
3. 
4. FIND_PACKAGE(libtins REQUIRED)
5.
6. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
7.
8. ADD_EXECUTABLE(dot11decrypt dot11decrypt.cpp)
9. TARGET_LINK_LIBRARIES(dot11decrypt ${LIBTINS_LIBRARIES} pthread)

find / -name Findlibtins.cmake或libtinsConfig.cmake不会带来任何结果。

我在网上找到了这些文件,但仍然没有成功,我想我必须安装一些东西,但不知道是什么。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-05-21 19:51:40

你不需要从源代码编译..。find_package是一个非常灵活的配置点!您只需要提供您自己的find模块就可以完成构建。幸运的是,这很简单。我所做的是:

代码语言:javascript
复制
$ https://github.com/mfontanini/dot11decrypt
$ cd dot11decrypt
$ mkdir _patches
$ vim _patches/Findlibtins.cmake
$ cat _patches/Findlibtins.cmake 
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBTINS REQUIRED libtins)
$ cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_MODULE_PATH=$PWD/_patches
CMake Deprecation Warning at CMakeLists.txt:1 (CMAKE_MINIMUM_REQUIRED):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Checking for module 'libtins'
--   Found libtins, version 4.0
-- Configuring done
-- Generating done
-- Build files have been written to: /home/alex/test/dot11decrypt/build
$ cmake --build build/
[ 50%] Building CXX object CMakeFiles/dot11decrypt.dir/dot11decrypt.cpp.o
/home/alex/test/dot11decrypt/dot11decrypt.cpp: In function ‘void decrypt_traffic(unique_fd, const string&, decrypter_tuple)’:
/home/alex/test/dot11decrypt/dot11decrypt.cpp:333:39: warning: ‘Tins::Sniffer::Sniffer(const string&, unsigned int, bool, const string&, bool)’ is deprecated [-Wdeprecated-declarations]
  333 |     Sniffer sniffer(iface, 2500, false);
      |                                       ^
In file included from /usr/include/tins/dns.h:38,
                 from /usr/include/tins/tins.h:33,
                 from /home/alex/test/dot11decrypt/dot11decrypt.cpp:25:
/usr/include/tins/sniffer.h:369:5: note: declared here
  369 |     TINS_DEPRECATED(Sniffer(const std::string& device, unsigned max_packet_size,
      |     ^~~~~~~~~~~~~~~
[100%] Linking CXX executable dot11decrypt
[100%] Built target dot11decrypt

这里的关键是创建一个最小的查找模块。这只是我的系统上的两行,因为它不能被重用.

代码语言:javascript
复制
# _patches/Findlibtins.cmake
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBTINS REQUIRED libtins)

这只是委派将LIBTINS_LIBRARIES设置为pkg-config的责任。要将这个查找模块连接到构建中,我只需在-DCMAKE_MODULE_PATH=$PWD/_patches配置命令行中设置CMake。

此外,您肯定应该与dot11decrypt作者一起打开一个错误报告,说明他们的错误和过时的构建。注意我发布的日志中措辞强烈的反对意见警告。

票数 1
EN

Stack Overflow用户

发布于 2022-05-21 20:10:01

我用的是Tsyvarev溶液。

代码语言:javascript
复制
# installing missing dependencies for libtins
apt-get install libpcap-dev libssl-dev cmake
# installing libtins
git clone https://github.com/mfontanini/libtins.git
cd libtins
mkdir build
cd build
cmake ../
make
checkinstall

现在,cmake将到达dot11decrypt丢失的文件。

代码语言:javascript
复制
# installing dot11decrypt
git clone https://github.com/mfontanini/dot11decrypt.git
cd dot11decrypt/
mkdir build
cd build/
cmake ../
make

现在应该有dot11decrypt可执行文件了。

如果我不得不再做一次的话,我会先尝试一下亚历克斯的解决方案。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72332376

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档