在QtCreator中配置c ++项目时出现问题
Problem with configuring c++ project in QtCreator
我有一些 c++ 代码(Snowboy demo - 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 ++ 代码?
雪男孩出于某种不敬虔的原因要求你使用-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
的软件都需要报废或分叉,但无论什么漂浮你的船。
这个问题
帮助我在qt-creator上成功运行了雪童演示。
我会给这个问题一个更全面的答案,以帮助更多的人:您只需将代码添加到 .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 -lasound
相关文章:
- Eulers 项目问题 no 345 听不懂几行代码
- 基本 Cuda C++项目集成问题
- C++ 从链表中删除项目时出现问题
- 双向链表问题 - 包含项目但不显示
- 在单元测试项目中包括 .c 文件,并从多个 cpp 文件访问它而不会出现链接问题
- 如何解决在 clr 项目的特定文件中写入数据的问题?
- 在Android Studio项目中使用tensorflow lite C++API的问题
- 相同的代码,不同的结果?从其他项目包含有什么问题?
- 我的自定义 C++ DLL 的 C# 项目中的 DLL 端口有什么问题?
- 在QtCreator中配置c ++项目时出现问题
- 编译示例 Cinder 项目时存在大量未解决的外部问题
- 将C库链接到Qt项目时出现问题
- VS 2017 C 静态LIB与 /MD项目依赖性问题编辑
- 测试项目在访问私有静态方法时遇到问题,尽管我从未直接调用过它
- 在 win32 控制台项目 VS2015 中静态链接 libcurl 的问题
- 鸟类调查中的项目在代码中遇到问题.如何像数据库系统一样存储数据
- 小型学校项目存在多个问题
- 为该项目报告C++奇怪的Klocwork问题
- 内存管理容器设计问题 - 项目需要继承
- 困难与问题.3项目欧拉(c++)