Yocto ADT Eclipse Plugin C++11 (Autotools) configuration

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Yocto ADT Eclipse Plugin C++11 (Autotools) configuration

1,896 Views
arnaudne
Contributor II

Hi everyone,

Context:

I am using an iMX6UL EVK with a custom, working, image generated with Yocto.

I would like to use Eclipse to develop C++ applications for this target, I then used :

bitbake my-image -c populate_sdk

bitbake meta-ide-support

This gave me an SDK and toolchain that I installed by executing the generated script.

I configured the Eclipse IDE (Mars.2) to use Yocto ADT Plugin, and configured it to use my SDK and  toolchain.

I created a new C++ application (Yocto Autotools Hello World Project), built and deployed the template without any error (It successfully ran on the target board).

Problem :

But the problem is that when I create a "more" complex application and have to use C++11, I can't compile anymore (The compiler is complaining about C++11 compatibility).

#error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

I got rid of this error by adding in Project Properties -> Autotools -> Configure -> Advanced :

CXXFLAGS="${CXXFLAGS} -std=gnu++11" CPPFLAGS="${CPPFLAGS} -std=gnu++11"

But then came other (ugly) errors:

undefined reference to `Audio::Audio(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'

undefined reference to `Audio::~Audio()'

For reference this is my Audio class:

Audio.h

#include <iostream>

#include <string>

#include <cstdint>

#include <alsa/asoundlib.h>

#define SAMPLE_SIZE (sizeof(int))     // bytes per sample

typedef struct {

    int numSamples;

    short *pData;

} wavedata_t;

class Audio {

public:

    Audio(std::string pcm_device = "default");

    virtual ~Audio();

    bool playbackFile(std::string path);

protected:

    snd_pcm_t *pcm_handle;

    bool configurePCM(std::string pcm_device, uint channels = 2, uint sampleRate = 44100, snd_pcm_format_t format = SND_PCM_FORMAT_S16_LE, snd_pcm_access_t access = SND_PCM_ACCESS_RW_INTERLEAVED);

    bool closePCM();

    // Helpers

    bool loadWavFile(std::string path, wavedata_t *pWaveStruct);

};

Audio.cpp

#include "Audio.h"

Audio::Audio(std::string pcm_device) {

    configurePCM(pcm_device);

}

Audio::~Audio() {

    closePCM();

}

bool Audio::playbackFile(std::string path) {

    <code>

}

bool Audio::configurePCM(std::string pcm_device, uint channels, uint sampleRate, snd_pcm_format_t format, snd_pcm_access_t access) {

    <code>

}

bool Audio::closePCM() {

    <code>

}

// Read in the file to dynamically allocated memory.

// !! Client code must free memory in wavedata_t !!

bool Audio::loadWavFile(std::string path, wavedata_t *pWaveStruct)

{

     <code>

}

Question :

How should I configure Eclipse to successfully compile C++11 applications using Autotools via Yocto ADT Plugin ?

Thanks in advance. :smileyhappy:

Arnaud (France)

Labels (2)
0 Kudos
Reply
2 Replies

1,169 Views
Yuri
NXP Employee
NXP Employee

Hello,

  According to https://www.kernel.org/doc/

C99 standard (current version of the C programming language) is supported.

So, it is good idea to use it with Linux apps.

Have a great day,
Yuri

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,169 Views
arnaudne
Contributor II

Thank you for your reply,

But what if I must use C++11 ? What should I do to make it work ?

Thank you

Arnaud

0 Kudos
Reply