链接器错误未定义引用c++; 我在DEV C++中创建了一个项目。编译时我得到了这个错误。

链接器错误未定义引用c++; 我在DEV C++中创建了一个项目。编译时我得到了这个错误。,c++,wavelet,C++,Wavelet,[Linker error]未定义对“dwt_sym(std::vector>&,int,std::string,std::vector>&,std::vector>&,std::vector>&”的引用 这是我的代码: #include <iostream> #include <fstream> #include "wavelet2d.h" #include <vector> #include <string> #include <cmat

[Linker error]未定义对“dwt_sym(std::vector>&,int,std::string,std::vector>&,std::vector>&,std::vector>&”的引用

这是我的代码:

#include <iostream>
#include <fstream>
#include "wavelet2d.h"
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main() {
    cout << "********J- LEVEL DISCRETE WAVELET TRANSFORM IMPLEMENTATION*********"; 
        cout << "This program accepts signal from the user in a file format " << endl;
        cout << "and performs Discrete Wavelet Transform with specified   " << endl;
        cout << "wavelet. "                                               << endl;
        cout << "                                                             " <<endl;
        cout << " The Following Wavelets are in the Database:                 " <endl;
        cout << " haar, db1, db2, db3, db4, db5, db6, db7, db8, db9, db10,  "   <<endl;
        cout << " db11, db12, db13, db14, db15.                               " <<endl;
        cout << " bior1.1, bio1.3, bior1.5, bior2.2, bior2.4,bior2.6,bior2.8, " <<endl;
        cout << " bior3.1, bior3.3, bior3.5, bior3.7, bior3.9, bior4.4,"        <<endl;
        cout << " bior5.5, bior6.8."                                            <<endl;
        cout << " coif1, coif2, coif3, coif4, coif5."                           <<endl;
        cout << "Please Enter the Wavelet Name at the Prompt( No quotes)     :" <<endl;

        string nm; // nm will store the name of Wavelet Family
        cin >> nm;
        cout << "Enter the name of signal file at the Prompt eg., signal.txt :" <<endl;
        char inp[50];
        cin >> inp;
        vector<double> sig;
        ifstream sig_inp(inp);
        if ( !sig_inp.good()){
            cout << "The File doesn't exist"<< endl;
        }
        while (sig_inp) {
            double temp;
            sig_inp >> temp;
            sig.push_back(temp);
        }
        sig.pop_back();
        vector<double> original;
        original = sig;
        cout << "Please Enter the Number of DWT Stages J             :" << endl;

        int J;
        cin >> J ;

        vector<double> dwt_output, flag;

        // perform J-Level DWT
        vector<int> length;

        dwt_sym(sig, J, nm, dwt_output,flag,length);
            ofstream dwtout("dwtout.txt");
            for (unsigned int i = 0; i < dwt_output.size(); i++){
             dwtout << dwt_output[i] << endl;

        }


        //Perform J-Level IDWT
        vector<double> output;
        idwt_sym(dwt_output, flag,nm,output,length);

        ofstream sig1("recon.txt");
        ofstream diff("diff.txt");

        cout <<" Recon signal size" << output.size() << endl;
        for (unsigned int i = 0; i < output.size(); i++){
            sig1 << output[i] << endl;
            diff << output[i] - original[i] << endl;

        }
        //gnudwtplot(J);
        return 0;
}
#包括
#包括
#包括“小波2d.h”
#包括
#包括
#包括
使用名称空间std;
int main(){

cout您确定dwt_sym函数接受所有这些向量作为输入或输出吗?确保您提供的输入类型与dwt_sym函数声明中的类型完全匹配(假设它位于此处看不到的外部头文件中)


[编辑]我刚刚意识到,链接器错误意味着它编译成功,这意味着提供了正确的输入。请检查以确保没有链接到错误版本的库或使用错误的库路径。

这是因为它无法找到包含dwt_sym()的.lib引用必须在项目属性(链接器选项)中检查路径

您现在可能需要给出确切的路径(硬编码)来测试它。一旦它起作用,请将其更改为正确的相对路径


同时检查您当前的配置。您可能在调试中提供了库名称。但可能正在生成版本。

这就是我解决问题的方法

  • 请按照以下操作说明操作:
  • 特别是:在LINUX环境下工作

    ln-sf libwavelet2d.so.1.0 libwavelet2d.so

    ln-sf libwavelet2d.so.1.0 libwavelet2d.so.1

    export LD\u LIBRARY\u PATH=“您的工作文件夹”

  • wavelet2d.h
    wavelet2d.cpp
    复制到您的工作文件夹中
  • 您可以从中找到这两个文件

  • 安装fftw库
  • 你可以用谷歌
    fftw
    。下载和安装fftw库很容易

  • 汇编:

  • $g++XXX.cpp wavelet2d.cpp-lm-lfftw3

    你链接了所有需要的库吗?是的,我链接了…没有工作未定义的引用意味着链接器找不到实现你调用的函数的函数体。dwt_sym()和idwt_sym()在哪里实现?它们在“wavelet2d.h”中声明了吗?是否有相应的源文件未被编译并随后链接?问题在于lib文件,我删除了它并添加了新的1。但当我构建它时,它给出了错误,相应的dll文件丢失