我有一个这样的文件(〜/Pobrane/multi-rtl/swig/multi_rtl_swig.i):

/* -*- c++ -*- */

#define MULTI_RTL_API

%include "gnuradio.i"           // the common stuff
%include "feval.i"

//load generated python docstrings
%include "multi_rtl_swig_doc.i"

%{
#include "multi_rtl/vector_sink_cn.h"
%}

%include "multi_rtl/vector_sink_cn.h"
GR_SWIG_BLOCK_MAGIC2(multi_rtl, vector_sink_cn);

并且在制作过程中出现以下错误:
[ 26%] Swig source multi_rtl_swig.i
Deprecated command line option: -modern. This option is now always on.
~/Pobrane/multi-rtl/swig/multi_rtl_swig.i:5: Error: Unable to find 'gnuradio.i'
~/Pobrane/multi-rtl/swig/multi_rtl_swig.i:6: Error: Unable to find 'feval.i'
make[2]: *** [swig/CMakeFiles/multi_rtl_swig_swig_compilation.dir/build.make:81: swig/CMakeFiles/multi_rtl_swig.dir/multi_rtl_swigPYTHON.stamp] Error 1
make[2]: *** Delete file 'swig/CMakeFiles/multi_rtl_swig.dir/multi_rtl_swigPYTHON.stamp'
make[2]: Opuszczenie katalogu '~/Pobrane/multi-rtl/build'
make[1]: *** [CMakeFiles/Makefile2:407: swig/CMakeFiles/multi_rtl_swig_swig_compilation.dir/all] Błąd 2
make[1]: Opuszczenie katalogu '~/Pobrane/multi-rtl/build'
make: *** [Makefile:158: all] Błąd 2

当然,这些文件在以下目录中:
gnuradio.i - /usr/include/gnuradio/swig/gnuradio.i
feval.i - /usr/include/gnuradio/swig/feval.i

在以下命令(我从make VERBOSE=1命令知道)期间发生了此错误:
cd ~/Pobrane/multi-rtl/build/swig && /usr/bin/cmake -E env SWIG_LIB=/usr/share/swig/4.0.1 /usr/bin/swig -python -fvirtual -modern -keyword -w511 -w314 -relativeimport -module multi_rtl_swig -I~/Pobrane/multi-rtl/lib -I~/Pobrane/multi-rtl/include -I~/Pobrane/multi-rtl/build/lib -I~/Pobrane/multi-rtl/build/include -I/usr/include -I/usr/include -I~/Pobrane/multi-rtl/build/swig -I~/Pobrane/multi-rtl/swig -I/usr/include/python2.7 -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I~/Pobrane/multi-rtl/lib -I~/Pobrane/multi-rtl/include -I~/Pobrane/multi-rtl/build/lib -I~/Pobrane/multi-rtl/build/include -I/usr/include -I/usr/include -I~/Pobrane/multi-rtl/build/swig -I~/Pobrane/multi-rtl/swig -I/usr/include/python2.7 -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -outdir ~/Pobrane/multi-rtl/build/swig -c++ -I~/Pobrane/multi-rtl/lib -I~/Pobrane/multi-rtl/include -I~/Pobrane/multi-rtl/build/lib -I~/Pobrane/multi-rtl/build/include -I/usr/include -o ~/Pobrane/multi-rtl/build/swig/CMakeFiles/multi_rtl_swig.dir/multi_rtl_swigPYTHON_wrap.cxx ~/Pobrane/multi-rtl/swig/multi_rtl_swig.i

我想知道此错误来自何处,引起的原因以及如何解决。

编辑

我知道是什么原因造成的。我使用了不推荐使用的$ {GNURADIO_RUNTIME_INCLUDE_DIRS}宏。更换后
foreach(incdir ${GNURADIO_RUNTIME_INCLUDE_DIRS})
    list(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}/gnuradio/swig)
endforeach(incdir)


list(APPEND GR_SWIG_INCLUDE_DIRS "/usr/local/include/gnuradio/swig")
list(APPEND GR_SWIG_INCLUDE_DIRS "/usr/include/gnuradio/swig")

一切正常。但是,这是一个临时解决方案。如何在gnuradio 3.8中实现类似的功能?

最佳答案

如您所知,您需要编辑swig/CMakeLists.txt并替换foreach循环,在该循环中,将路径添加到GR_SWIG_INCLUDE_DIRS变量中

set(GR_SWIG_INCLUDE_DIRS $<TARGET_PROPERTY:gnuradio::runtime_swig,INTERFACE_INCLUDE_DIRECTORIES>)
set(GR_SWIG_TARGET_DEPS gnuradio::runtime_swig)

关于linux - cmake找不到/usr/include/gnuradio/swig/gnuradio.i,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/61018097/

10-10 11:57