我有一些c++代码(雪球演示- demo.cc),并使用g++在我的RaspPI Zero上成功地构建了它:
g++ -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -I../../ -std=c++0x -Wall -Wno-sign-compare -Wno-unused-local-typedefs -Winit-self -rdynamic -DHAVE_POSIX_MEMALIGN -Iportaudio/install/include -O3 demo.cc portaudio/install/lib/libportaudio.a ../..//lib/rpi/libsnowboy-detect.a -ldl -lm -Wl,-Bstatic -Wl,-Bdynamic -lrt -lpthread portaudio/install/lib/libportaudio.a -L/usr/lib/atlas-base -lf77blas -lcblas -llapack_atlas -latlas -lasound -o demo为了调试它,我尝试使用QtCreator并创建Qt项目文件:
QT -= gui
CONFIG += c++11 console
CONFIG -= app_bundle
HEADERS += demo.h
SOURCES += \
demo.cc
INCLUDEPATH += ../../
INCLUDEPATH += portaudio/install/include
LIBS += -Lportaudio/install/lib \
-lportaudio \
-L../../lib/rpi -lsnowboy-detect \
-L/usr/lib/atlas-base \
-ldl -lm -lrt -lpthread \
-lf77blas -lcblas -llapack_atlas -latlas -lasound但在QtCreator中使用此配置时,我会收到构建错误:
/home/pi/Prj/snowboy/examples/C++/demo.cc:213: error: undefined reference to `snowboy::SnowboyDetect::SnowboyDetect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'我是否忘记在Qt项目文件中指定与g++一起使用的任何参数?
有没有可能你建议我一种简单的方法来调试Raspb Pi zero中具有外部依赖关系的c++代码?
发布于 2019-05-28 03:40:08
雪人出于某种不道德的原因,要求你使用-D_GLIBCXX_USE_CXX11_ABI=0 (谷歌吧)。您的命令行中有此标志,这在Snowboy的上下文中是正确的,但在.pro文件中缺少此标志。添加它。
QMAKE_CPPFLAGS += -D_GLIBCXX_USE_CXX11_ABI=0或者类似的东西。
您也可以尝试将您的语言标准选项降级为C++98 (不推荐,但如果您的演示没有使用任何C++11特定的代码,则应该可以)。
我个人认为,任何在2019年仍在使用-D_GLIBCXX_USE_CXX11_ABI=0的软件都需要报废或派生,但无论是什么都可以。
发布于 2020-08-09 23:32:43
这个问题帮助我在qt-creator上成功地运行了Snowboy演示。
为了帮助更多的人,我将给这个问题一个更完整的答案:只需将代码添加到.pro文件:
QMAKE_CXXFLAGS += -D_GLIBCXX_USE_CXX11_ABI=0
LIBS+= /home/zhurui/QtProject/Test/lib/libsnowboy-detect.a \
-ldl -lm -lrt -lpthread \
/home/zhurui/QtProject/Test/portaudio/install/lib/libportaudio.a \
-L/usr/lib/atlas-base \
-lf77blas -lcblas -llapack_atlas \
-latlas -lasoundhttps://stackoverflow.com/questions/56331456
复制相似问题