开发者

Undefined Symbols

开发者 https://www.devze.com 2022-12-19 08:46 出处:网络
The Image class is a subclass of the BMP class.I am attempting to use some methods TellHeight(), TellWidth(), etc. from the BMP class in order to manipulate an image in this method.However, when I cre

The Image class is a subclass of the BMP class. I am attempting to use some methods TellHeight(), TellWidth(), etc. from the BMP class in order to manipulate an image in this method. However, when I create a BMP and attempt to call functions on it, upon compilation I get an error saying

Undefined Symbols:

BMP::BMP(), referenced from:

Image::invertcolors()

This is the method invertcolors():

void Image::invertcolors()
{
BMP img_invert;
img_invert.ReadFromFile("inverted.bmp");
//int height =img_invert.TellHeight();
//int width = img_invert.TellWidth();

//for(int i = 0; i<height; i++)
//{
//for(int j =0; j<width; j++)
//{
//RGBApixel* current = img_invert(j,i);
//current->Blue = 255 - (current->Blue);
//current->Green = 255 - (current->Green);
//current->Red = 255 - (current->Red);
//current->Alpha = 255 - (current->Alpha);
//}
//}
}
开发者_StackOverflow


Undefined symbol is a link time error. When you are linking your binary, you need to link with the compiled code that defines that function.

If BMP is part of an external library, you'll need to add something like this to your link line:

 -L/path/to/lib -lbmp


BMP does not have a no-argument constructor, you must use another means to get an instance of BMP to use.


Your BMP class does not have a default constructor. Either implement one, or make Image call its parent's initializer properly. For example,

// this class does not have a default constructor:
class Parent 
{
public:
   Parent( int a ) { /* .. */ }
};


// so this one must call its parent's constructor with a parameter
class Child : public Parent
{
public:
   Child() : Parent(42) { /* .. */ } 
}


looks more like a linker error. THe BMP library is not being linked in

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号