-1

I've created a project in dev c++.While compiling i got this error.

[Linker error] undefined reference to `dwt_sym(std::vector >&, int, std::string, std::vector >&, std::vector >&, std::vector >&)'

This is my code:

#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;
}

How to fix the problem??

greatwolf
  • 20,287
  • 13
  • 71
  • 105

3 Answers3

0

Are you sure that the dwt_sym function takes in all of those vectors as inputs or outputs? Make sure that the types for the inputs you are providing match exactly with the types in the dwt_sym function declaration (assuming that it is in an external header file that cannot be seen here).

[EDIT] I just realized that a linker error means that it compiled successfully, meaning that the right inputs were provided. Check to make sure you aren't linking in the wrong version of the library or using the wrong library path.

Andrew
  • 1,581
  • 3
  • 18
  • 31
0

This is for sure that it cannot find the .lib references containing dwt_sym() function. You must check the path in Project properties (Linker options).

You may want to give the exact path (hard code it) for now to test it. Once it works, change it to correct relative path.

Also check your current configuration. You may have given the library name in Debug. But may be building Release.

Gautam Jain
  • 6,789
  • 10
  • 48
  • 67
  • The problem is with the lib file,i deleted it and added new 1.But when i build it,it gives the error,respective dll file is missing – user3046395 Nov 30 '13 at 04:34
0

This is how I solved the problem.

  1. follow the working instructions here from: http://wavelet2d.sourceforge.net/

especially:Working in LINUX Environment

ln -sf libwavelet2d.so.1.0 libwavelet2d.so

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

export LD_LIBRARY_PATH="your working folder"

  1. copy wavelet2d.h and wavelet2d.cpp into your working folder.

you can find these two files from wavelib

  1. install fftw library.

you can google fftw. It is easy to download and install fftw library.

  1. compile:

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

Niu
  • 1
  • 2