Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6149063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:23:24+00:00 2026-05-23T19:23:24+00:00

I’m relatively new to C & C++ and stuck at compiling (or should I

  • 0

I’m relatively new to C & C++ and stuck at compiling (or should I say linking) for the whole 2 days. Anyone gives me an idea would be appreciated.
Error message and 3 code files are below. These are what I cut down to minimum from I’m actually working on so that you guys can take a better glimpse at.

Env: Ubuntu 10.10, Eclipse Indigo CDT, g++ (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5

Error message:

**** Build of configuration Debug for project SceneRec2 ****

make all 
Building file: ../src/AdaBoost.cpp
Invoking: GCC C++ Compiler
g++ -I"/home/ubuntuLove/Documents/workspace_eclipse/SceneRec2/Includes" -I/usr/src/linux-headers-2.6.35-30/arch/um/include/shared -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/AdaBoost.d" -MT"src/AdaBoost.d" -o "src/AdaBoost.o" "../src/AdaBoost.cpp"
Finished building: ../src/AdaBoost.cpp

Building file: ../src/AdaMain.cpp
Invoking: GCC C++ Compiler
g++ -I"/home/ubuntuLove/Documents/workspace_eclipse/SceneRec2/Includes" -I/usr/src/linux-headers-2.6.35-30/arch/um/include/shared -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/AdaMain.d" -MT"src/AdaMain.d" -o "src/AdaMain.o" "../src/AdaMain.cpp"
../src/AdaMain.cpp: In function ‘int main(int, char**)’:
../src/AdaMain.cpp:6: warning: deprecated conversion from string constant to ‘char*’
Finished building: ../src/AdaMain.cpp

Building target: SceneRec2
Invoking: GCC C++ Linker
g++  -o "SceneRec2"  ./src/AdaBoost.o ./src/AdaMain.o   
./src/AdaMain.o: In function `main':
/home/ubuntuLove/Documents/workspace_eclipse/SceneRec2/Debug/../src/AdaMain.cpp:5: undefined reference to `AdaBoost<double>::AdaBoost()'
/home/ubuntuLove/Documents/workspace_eclipse/SceneRec2/Debug/../src/AdaMain.cpp:6: undefined reference to `AdaBoost<double>::readFromFile(char*)'
/home/ubuntuLove/Documents/workspace_eclipse/SceneRec2/Debug/../src/AdaMain.cpp:8: undefined reference to `AdaBoost<double>::~AdaBoost()'
/home/ubuntuLove/Documents/workspace_eclipse/SceneRec2/Debug/../src/AdaMain.cpp:8: undefined reference to `AdaBoost<double>::~AdaBoost()'
collect2: ld returned 1 exit status
make: *** [SceneRec2] Error 1

**** Build Finished ****

Note-1. I receive the same result when I execute g++ on terminal.

Note-2. The path of .o files in the argument for linker should be correct (./src/###.o).

AdaBoost.h

#ifndef _ADABOOST_H
#define _ADABOOST_H

#include <iostream>

const double eps = 2.2204e-16;

template<class T>
class AdaBoost
{
        int N; //Number of Instances
        int D; //Number of Dimensions
        int nL; //Number of Learners / Classifiers / Rules

        T** fVectors;
        int* labels;

        void learnRule(int t, double* dist);
        double genRule(int t, int* L, double* dist);

    public:

        //Default Constructor
        AdaBoost();

        //Constructor
        AdaBoost(T** data, int* labels, int n, int d, int nL);

        //Train function
        void train();

        //Test function
        void test(double** data, double* pMap);
        void test(double** data, double* pMap, int n);

        int writeToFile(char* fName);
        int readFromFile(char* fName);

        //Destructor
        ~AdaBoost();
};
#endif

AdaBoost.cpp

#include "AdaBoost.h"    
#include <fstream>

using namespace std;

template class AdaBoost<double> ;

template<class T>
int AdaBoost<T>::readFromFile(char* fName) {

    ifstream inFile;

    int temp;
    int d, dir;
    float thr, wt;

    inFile.open(fName);
    if (!inFile)
        return 0;

    inFile >> temp;
    this->nL = temp;

    int k = 0;
    while (!inFile.eof() && k < nL) {

        inFile >> d;
        inFile >> thr;
        inFile >> dir;
        inFile >> wt;

        k++;
    }

    inFile.close();

    return 1;
}

AdaMain.cpp

#include "AdaBoost.h"
using namespace std;
int main(int argc, char** argv)
{
    AdaBoost<double> rdClass;
    rdClass.readFromFile("Naerer");

    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:23:24+00:00Added an answer on May 23, 2026 at 7:23 pm

    You need to put the definition of template<class T>
    int AdaBoost<T>::readFromFile(char* fName)
    into AdaBoost.h, and remove AdaBoost.cpp from your build.

    It’s best to put all template code into the header. C++ linkers are required to eliminate duplicate instantiations of template code so you won’t get “multiply defined symbol” errors.

    P.S. You should declare the function as template<class T>
    int AdaBoost<T>::readFromFile(const char* fName)
    to get rid of the deprecated conversion from string constant to ‘char*’ warning. The function does not need to alter the filename.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to count the length of a string with PHP. The string
I want use html5's new tag to play a wav file (currently only supported
Does anyone know how can I replace this 2 symbol below from the string
I'm parsing an XML file, the creators of it stuck in a bunch social
I would like to run a str_replace or preg_replace which looks for certain words
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.