Jump to content
Caaarloo

Linker error in Energia IDE

Recommended Posts

Hi! 

Im getting these errors:

Quote

Imperial_March.cpp.o: In function `_GLOBAL__sub_I__ZN14Imperial_MarchC2Ev':
Imperial_March.cpp:(.text.startup._GLOBAL__sub_I__ZN14Imperial_MarchC2Ev+0x6): undefined reference to `std::ios_base::Init::Init()'
Imperial_March.cpp:(.text.startup._GLOBAL__sub_I__ZN14Imperial_MarchC2Ev+0x1c): undefined reference to `std::ios_base::Init::~Init()'
collect2.exe: error: ld returned 1 exit status

 

This is my main code, it just reproduces a tone:

Reproductor.ino

#include "Nota.h"
#include "Imperial_March.h"
using namespace std;
#include <vector>
#include <string>
template class std::basic_string<char>;
#define DO 261.626
#define RE 293.665
#define MIb 311.127
#define MI 329.628
#define FA 349.228
#define FAs 369.994
#define SOL 391.995
#define SOLs 415.305
#define LA 440.000
#define SIb 466.164
#define SI 493.883
#define DOM 523.251
#define DOMs 554.365
#define REM 587.330
#define MIMb 622.254
#define MIM 659.255
#define FAM 698.456
#define FAMs 739.989
#define SOLM 783.991



const int BUZZER1 = PA_7;
const int BUZZER2 = PF_1;
float duracion_negra = 1.0;
const int NUMERO_NOTAS = 216;
void setup() {                
  // initialize the digital pin as an output.
  pinMode(BUZZER1, OUTPUT);     
  pinMode(BUZZER2, OUTPUT); 
  const float DURANCION_MINIMA = duracion_negra/4.0;
  Imperial_March cancion;
}

void loop() {
  float nota_a_tocar = MI;
  digitalWrite(BUZZER1, HIGH);   // turn the signal to buzzer high
  digitalWrite(BUZZER2, HIGH);   // turn the signal to buzzer high
  delayMicroseconds( 1/(2*nota_a_tocar) *1000000 );      // wait for half cycle
  digitalWrite(BUZZER1, LOW);    // turn the signal to buzzer low
  digitalWrite(BUZZER2, LOW);    // turn the signal to buzzer low
  delayMicroseconds( 1/(2*nota_a_tocar) *1000000 );      // wait for half cycle
}

And the class I created, is just a "song":

 

Imperial_March.cpp

#include "Imperial_March.h"
#include <iostream>
Imperial_March::Imperial_March()
{
    std::string notas_aux[] = {"SOL","SOL","SOL","MIb","SIb","SOL","MIb","SIb","SOL","REM","REM","REM",   //12
    "MIMb","SIb","FAs","RE","SIb","SOL","SOLM","SOL","SOL","SOLM","FAMs","FAM",                       //24
    "MIM","SOLs","DOMs","DOM","SI","SIb","MIb","FAs","MI","FA","SIb","SOL",                           //36
    "SI","SI","SOLM","SOL","SOL","SOLM","FAMs","FAM","MIM","SOLs","DOMs","DOM",                       //48
    "SI","SIb","MIb","FAs","MI","SI","SOL","MIb","SIb","SOL","SOL","SOL",                             //60
    "SOL","MIb","SIb","SOL","MIb","SIb","SOL","RE","RE","RE","MIMb","SIb",                            //72
    "FAs","RE","SIb","SOL"};

    tamanio = sizeof(notas_aux)/sizeof(std::string);

    unsigned int i = 0;
    for(i=0; i<tamanio; i++)
        notas.push_back(notas_aux[i]);
}

Imperial_March::~Imperial_March(){}

std::string Imperial_March::Get_nota(int pos){
    return notas[pos];
}

int Imperial_March::Get_tamanio(){
    return tamanio;
}

namespace std {
  void __throw_length_error(char const*){}
  
  void __throw_logic_error(char const*){}
  
  //void ios_base::Init(){}
}

 

And its header

Imperial_March.h

#ifndef IMPERIAL_MARCH_H
#define IMPERIAL_MARCH_H
#include "Nota.h"
#include <string>
#include <vector>

class Imperial_March
{
    public:
        Imperial_March();
        ~Imperial_March();
        std::string Get_nota(int pos);
        int Get_tamanio();

    private:
        std::vector<std::string> notas;
        int tamanio;
};

#endif // IMPERIAL_MARCH_H

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×