c++ - pybind11 & dlib:gcc 命令的 CMake 替代方案
问题描述
我正在尝试*.whl
使用 pybind11 和 dlib 从 C++ 源代码构建一个 python 包。
这个 GCC 对我很有用:
gcc -O3 -Wall -shared -I /home/user/dlib /home/user/dlib/dlib/all/source.cpp -lpthread -lX11 -ljpeg -lpng -DDLIB_JPEG_SUPPORT -DDLIB_PNG_SUPPORT -std=c++11 -fPIC `python3 -m pybind11 --includes` age_and_gender.cpp -o age_and_gender`python3-config --extension-suffix`
现在我正在尝试*.whl
从这个示例构建 python 包:
https ://github.com/pybind/cmake_example
我的CMakeLists.txt
文件:
cmake_minimum_required(VERSION 2.8.12)
if (CMAKE_VERSION VERSION_LESS 3.0)
PROJECT(example_app CXX)
else()
cmake_policy(SET CMP0048 NEW)
PROJECT(example_app VERSION "1.0.0" LANGUAGES CXX)
endif()
add_compile_options(
-O3
-Wall
-shared
-fPIC
-lpthread
-lX11
-ljpeg
-lpng
-DDLIB_JPEG_SUPPORT
-DDLIB_PNG_SUPPORT
-std=c++11
)
add_executable(dlib_source "/home/user/dlib/dlib/all/source.cpp")
include_directories("/home/user/dlib")
add_subdirectory(pybind11)
pybind11_add_module(example_app "src/main.cpp")
我认为这不是正确的版本CMakeLists.txt
。鉴于我的“gcc”命令有效,帮助编写正确的 CMakeLists.txt 文件。
当我尝试打包时,出现此错误import
:*.whl
from example_app import *
Segmentation fault (core dumped)
解决方案
推荐阅读
- c# - 如何从工具窗口访问当前代码编辑器?
- email - 如何使用 Outlook 的 SMTP 服务器发送电子邮件?
- android - BufferQueueProducer 问题专门针对 Android Q Pixel 3 和 3 XL 设备。模拟器工作正常
- python - Instagram 页面无法通过 Tor 的 urlopen() 加载。可能是什么原因/解决方法?
- r - 具有可变数量参数的递归函数
- python - 用于比较两个数据框并使用真/假创建新列的功能
- ubuntu - SSH 在使用以太网电缆一段时间后无限期挂起;甚至无法断开连接
- excel - 如何减少/增加 excel 列中的计数器?
- go - 将 Websocket 消息发送到 Go 中的特定通道(使用 Gorilla)
- ios - 将 Int 的值分配给两个单独的变量