怀疑自创建继承类的链接问题
Suspected linking issue with self created inherited class
我有一些问题与类程序。我认为这是链接器的问题。这个程序没有语法问题,而且可以编译。问题是由程序中的一个类引起的。我试着从头开始重写这个,希望它是一个简单的语法错误,但没有工作。我还确保类文件位于包含目录列表中包含的目录中。
调用导致问题的FillerImage类的文件。
#include <cstdlib>
#include <sstream>
#include <iostream>
#include "globals.h" //some global variables are included here
#include "pixel.h" //includes the pixel class for storing individual pixels
#include "image.h" //includes the image class we will be using.
#include "FillerImage.h"
using namespace std;
//declare your global variables here!
image* IM;
//load the filler images from the given folder into a vector of fillerImage.
bool loadFillerImagesFromFolder(string folder)
{
for (int i = FIRST_FILLER_NUMBER; i<= LAST_FILLER_NUMBER; i++){
stringstream num;
num << i;
string filepath = folder + "/" + num.str() + FILLER_IMAGE_EXT;
FillerImage* tmpFil = new FillerImage(filepath);
}
return false;
}
头文件
#ifndef FILLERIMAGE_H
#define FILLERIMAGE_H
#include "image.h"
#include "pixel.h"
using namespace std;
class FillerImage :image
{
public:
FillerImage(string filepath);
bool setAverageColour();
private:
int timesUsed;
pixel averageColour;
};
#endif
.
#include "FillerImage.h"
#include "pixel.h"
#include "image.h"
using namespace std;
FillerImage::FillerImage(string filepath):image(filepath){
timesUsed = 0;
}
bool FillerImage::setAverageColour(){
pixel** pix = getPixels();
int height = getHeight();
int width = getWidth();
int averageRed, averageBlue, averageGreen = 0;
for (int i = 0; i < height; i++){
for (int j = 0; j< width; j++){
averageRed += pix[i][j].red;
averageBlue += pix[i][j].blue;
averageGreen += pix[i][j].green;
}
}
pixel tmppix;
int pixels = width*height;
tmppix.red = averageRed/pixels;
tmppix.blue = averageBlue/pixels;
tmppix.green = averageGreen/pixels;
averageColour = tmppix;
}
FillerImage继承的图像类是由我的老师创建的,在上一个程序中工作得很好,所以我认为这不是问题。
Netbeans给出的错误是
g++ -headerpad_max_install_names - 0cs215pgm5。应用程序/内容/MacOS/cs215pgm5 mainForm。o形象。o cs215pgm5.o主要。o moc_mainForm。/Library/Frameworks -L/Library/Frameworks架构x86_64的未定义符号:"FillerImage::FillerImage(std::basic_string, std::allocator>)",引用自:loadFillerImagesFromFolder(std::basic_string, std::allocator>)在cs215pgm5。o ld:在体系结构x86_64中找不到符号退出状态make: * [cs215pgm5. 5]app/Contents/MacOS/cs215pgm5] Error 1
BUILD FAILED (exit value 2, total time: 131ms)
感谢您提供的帮助
似乎你还没有包括fillerimage.cpp
在你的构建。如果您确实在使用Qt,那么它可能没有在Qt应用程序的. profile文件中列出source
。
- 使用jsoncpp库时出现链接问题
- Cmake 链接问题:未定义对 Button::mousePressEvent(QGraphicsSceneMouseE
- 如何将GTest与CMake一起使用?遵循谷歌指南时的链接问题
- 未解决的外部链接问题
- 'make check' GLIBC 运行时的链接问题
- 在树莓派上用libtorch构建程序时的链接问题
- 野牛弹性链接问题
- 与 AWS 开发工具包的链接问题
- Qt & Firebase C++ SDK 在 iOS 上的链接问题
- 链接问题 boost::p ython::numpy.
- 与 32 位共享对象的链接问题
- 在单元测试项目中包括 .c 文件,并从多个 cpp 文件访问它而不会出现链接问题
- 安卓链接问题
- LLVM 传递链接问题:未定义的符号
- Cmake Mac OSX库链接问题:在Linux上进行编译,但在Mac上进行了编译
- 用libclang解析源文件 - 链接问题包括文件
- C / C++链接问题与非常简单的设置
- Zbar 在 vs2015 链接问题
- Vulkan + GLFW + Cmake在Linux环境下的链接问题
- TFS构建由于链接问题而失败