I have the following pieces of code:
Leomedia.h
#include "MusicMetaDatter.h"
#ifndef LEOMEDIA_H
#define LEOMEDIA_H
namespace Leomedia
{
typedef enum
{
read,
write
} FileMode;
}
#endif // LEOMEDIA_H
MusicMetaDatter.h
#ifndef MUSICMETADATTER_H
#define MUSICMETADATTER_H
#include "Leomedia.h"
#include <string>
/**
* METADATTER
* @Version 1.0.0a
* @Author: Sergio Andrés Ibañez (Leonnears)
* @Twitter: Leonnears
* @Package: Leomedia
*/
namespace Leomedia
{
typedef enum
{
mp3,
m4a,
flac,
ape,
wavPack,
aiff,
wav,
ogg,
tta
} AudioFileType;
class MusicMetaDatter
{
public:
MusicMetaDatter(std::string fileName, AudioFileType type, FileMode mode);
virtual ~MusicMetaDatter();
private:
std::string md_fileName;
AudioFileType md_fileType;
FileMode md_fileMode;
};
}
#endif // MUSICMETADATTER_H
MusicMetaDatter.cpp
#include "MusicMetaDatter.h"
#include <string>
Leomedia::MusicMetaDatter::MusicMetaDatter(std::string fileName, AudioFileType type, FileMode mode)
{
this -> md_fileName = fileName;
this -> md_fileType = type;
this -> md_fileMode = mode;
}
Leomedia::MusicMetaDatter::~MusicMetaDatter()
{
//dtor
}
MetaDatterTest.cpp
#include <iostream>
#include "Leomedia.h"
#include <string>
using namespace std;
int main()
{
Leomedia::MusicMetaDatter meta("troll", Leomedia::mp3, Leomedia::read);
return 0;
}
When I compile MetaDatterTest I get the following errors:
undefined reference to Leomedia::MusicMetaDatter::MusicMetaDatter(std::string, Leomedia::AudioFileType, Leomedia::FileMode)' undefined reference to Leomedia::MusicMetaDatter::~MusicMetaDatter()' undefined reference to Leomedia::MusicMetaDatter::~MusicMetaDatter()'
All the files are in the same directory. I'm using mingw 4.4.1
Can someone help me with this? It has dumbfounded me beyond understanding.
You haven't given your compile command, but I suspect it lacks MusicMetaDatter.cpp
in it.
Should be something like
g++ -o MetaDatterTest MetaDatterTest.cpp MusicMetaDatter.cpp
Those are linker errors. It compiled just fine. When you link it, you'll need to link to the code that contains the destructor for MusicMetaDatter
or you'll get that error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With