Bleach
Bleach

Reputation: 156

Problem with configuring c++ project in QtCreator

I have some c++ code (Snowboy demo - demo.cc) and successfully build it on my RaspPI Zero using g++:

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

To debug it I try to use QtCreator and create Qt project file:

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

But with this configuration in QtCreator I receive build errors:

/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&)'

Did I forget to specify any parameters that was used with g++ in Qt project file?

Is it possible you advise me a simple way to debug c++ code with external dependencies in Raspb Pi zero?

Upvotes: 0

Views: 338

Answers (2)

Wszhurui
Wszhurui

Reputation: 11

This question help me run the Snowboy demo on qt-creator successfully.

I will give the question a fuller answer, to help more people: You just add the code to .pro file:

    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

Upvotes: 1

n. m. could be an AI
n. m. could be an AI

Reputation: 119847

Snowboy for some ungodly reason requires you to use -D_GLIBCXX_USE_CXX11_ABI=0 (google it). You have this flag in your command line, which is correct in the context of Snowboy, but are missing it in your .pro file. Add it.

QMAKE_CPPFLAGS += -D_GLIBCXX_USE_CXX11_ABI=0

or something like that.

You can also try downgrading your language standard option to C++98 (not recommended but should work if your demo is not using any c++11-specific code).


I personally think that any software that is still using -D_GLIBCXX_USE_CXX11_ABI=0 in 2019 needs to be scrapped or forked, but whatever floats your boat.

Upvotes: 1

Related Questions