【问题标题】:ERROR LNK2019 ( Unresolved external symbol) IN VS2008 WITH ITK AND FFTW带有 ITK 和 FFTW 的 VS2008 中的错误 LNK2019(未解析的外部符号)
【发布时间】:2011-07-08 11:08:50
【问题描述】:

我正在使用 ITK 执行一个用于处理医学图像的项目。经过大量工作后没有进一步的编译错误,但在链接过程中我有以下信息:

1>------生成开始:proyect:prueba_r01,配置:Debug Win32 ------ 1>链接... 1>创建库 C:\Documents and Settings\GTTS\Mis documentos\Visual Studio 2008\Projects\prueba_r01\Debug\prueba_r01.lib 和对象 C:\Documents and Settings\GTTS\Mis documentos\Visual Studio 2008\Projects\prueba_r01 \调试\prueba_r01.exp

1>prueba_r01.obj : 错误 LNK2019: extern symbol "public: double (* __thiscall prueba_r01::multiply_matrix_2D(double ()[2],double ()[2],int,int ))[2]" (?multiply_matrix_2D@prueba_r01@@QAEPAY01NPAY01N0HH@Z) 未解决,在函数“private: void __thiscall prueba_r01::filtro(void)” (?filtro@prueba_r01@@AAEXXZ) 中引用

1>C:\Documents and Settings\GTTS\Mis documentos\Visual Studio 2008\Projects\prueba_r01\Debug\prueba_r01.exe : 致命错误 LNK1120: 1 externos sin resolver

1>prueba_r01 - 2 个错误,0 个警告 ========== 一般:0 正确,1 错误,0 实现,0 省略 ==========

方法 multiply_matrix_2D 在私有槽“filtro()”中调用时产生错误(翻译为过滤器) 文件头是:

#include <QtGui/QMainWindow>
#include "ui_prueba_r01.h"
#include "vicdef.h"
#include "itkImage.h"
#include "math.h"
#include <complex>
#include "fftw3.h"
using namespace std;

#define PI 3.14159265

class prueba_r01 : public QMainWindow
{
Q_OBJECT

public:
typedef double PixelType;
typedef itk::Image < PixelType, 2> ImageType;
    ImageType::Pointer imagen;

double** H;

prueba_r01(QWidget *parent = 0, Qt::WFlags flags = 0);
~prueba_r01();

void matrix2D_H(int ancho, int alto, double eta, double sigma);
fftw_complex* multiply_matrix_2D(fftw_complex* out, fftw_complex* H,int a, int b);

private slots:
void openRGB();
void filtro();


private:
Ui::prueba_r01Class ui;
};

#endif // PRUEBA_R01_H

并且问题所在的主要部分在.cpp文件中,并显示在这里:

fftw_complex* res ;
res = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)*a*b);
fftw_complex* H_casted= reinterpret_cast<fftw_complex*> (&H);
res = multiply_matrix_2D(out,H_casted, a, b);

将**double指针转换为*fftw_complex的过程在这里完成,因为我想将频域中的滤波器(H(w))与图像的fft变换的结果相乘,这就是原因。重要的是要注意 fftw_complex 是 double[2],第一行用于实部,第二行用于虚部 有问题的方法如下所示:

 fftw_complex* multiply_matrix_2D(fftw_complex* out, fftw_complex* H, int a ,int b){
/* The matrix out[axb] or [n0x(n1/2)+1] is the image after the FFT , and the           out_H[axb] is the filter in the frequency domain,
both are multiplied POINT TO POINT, it has to be called  twice, one for the imaginary part and another for the normal part
*/
 fftw_complex *res;
 res = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)*a*b);
 for (int i0 = 0; i0<a ; i0++){
for (int i1 = 0; i1<b ; i1++){
 res[i1+a*i0][0] = out[i1+a*i0][0]*(H[0][0]+H[0][1]); // real part          
 res[i1+a*i0][1] = out[i1+a*i0][1]*(H[0][0]+H[0][1]); // imaginary part
    }
 }
 return res;
 }

任何帮助都会非常好!我现在很迷茫…… 谢谢!格拉西亚斯! 安东尼奥

【问题讨论】:

    标签: c++ visual-studio-2008 visual-c++ fftw itk


    【解决方案1】:

    将cpp文件中的函数头改为:

    fftw_complex* prueba_r01::multiply_matrix_2D(fftw_complex* out, fftw_complex* H, int a, int b) 
    

    你在实现中忘记了类名(prueba_r01::),因此找不到函数体

    【讨论】:

    • 我不会说愚蠢,我猜这就是人们所说的常规盲法 ;-) 你对代码越熟悉,就越难发现此类错误
    猜你喜欢
    • 2012-10-31
    • 2012-08-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多