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 858629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:34:02+00:00 2026-05-15T08:34:02+00:00

I am facing a few problems with undefined reference to errors. I may not

  • 0

I am facing a few problems with “undefined reference to ” errors. I may not be able to post the code, but the declarations and the way I am calling the functions are as follows:

Declarations:

template <typename T>
int pitch_detect(deque<T>& x, int offset, int len);

template <typename T>
int is_voiced(
  deque<T>& x, int offset, int len,
  double avg_energy, int pre_voice,
  short& s_flag,
  long nsamples
);

I am calling the above functions as follows:

x = is_voiced(superFrame_, cur_offset_, f_len_,
    avgEnergy_, frame_voicing_[1], silence_flag_, nsamples_);

y = pitch_detect(superFrame_, cur_offset_, f_len_);

The above statements (where I am calling the functions), get flagged as errors. These are the messages:

undefined reference to `int
is_voiced(std::deque >&, int, int,
double, int, short&, long)

undefined reference to `int
pitch_detect(std::deque >&, int, int)’

Any help in decoding the above errors is most welcome.
Thanks,
Sriram

Edit:
The above functions are defined in a separate header and corresponding C++ file. I get no problems when I try to compile them and create an object file. These errors are seen in the linker stage.

  • 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-15T08:34:03+00:00Added an answer on May 15, 2026 at 8:34 am

    Have you provided definitions for those templates? Are you explicitly instantiating the templates yourself or allowing the compiler to instantiate them?

    If you provide a template declaration but the compiler does not see the definition in the same translation unit, it will assume that the template will be instantiated in another translation unit, and will just generate the call, but not compile (without seeing the definition it cannot possibly do it) the specific instantiation. Later at link time the linker will see the call, but will not see the instantiation and will fail with the undefined reference error.

    The simplest solution is just having the template declaration and definition together:

    template <typename T>
    int is_voiced( deque<T>& x, int offset, int len, double avg_energy, int pre_voice, short& s_flag, long nsamples ) 
    {
      // code here
    }
    

    Then when you use is_voiced(...) the compiler will implicitly instantiate the template for you (it sees the code, and it will compile it).

    There are a few cases where you do not want the compiler to implicitly instantiate your templates (you know what types are going to be used, and you do not want the compiler to allow other uses –or it is expensive to compile and want to speed compilation up by only instantiating the templates in a single translation unit). For those cases you will need to provide your own explicit instantiation in a translation unit.

    // header
    template <typename T>
    int is_voiced( deque<T>& x, int offset, int len, double avg_energy, int pre_voice, short& s_flag, long nsamples ); 
    
    // cpp
    template <typename T>
    int is_voiced( deque<T>& x, int offset, int len, double avg_energy, int pre_voice, short& s_flag, long nsamples ) {
       // code goes here
    }
    // explicit instantiation for int
    template int is_voiced( deque<int>& x, int offset, int len, double avg_energy, int pre_voice, short& s_flag, long nsamples );
    

    Then compile that implementation file and link it with the rest of the project.

    Note: it is advisable to provide the full template definition in the header so that the compiler can implicitly instantiate it, unless you have a good reason not to do so.

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

Sidebar

Ask A Question

Stats

  • Questions 492k
  • Answers 492k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes there is. Where you would write an install hook… May 16, 2026 at 10:24 am
  • Editorial Team
    Editorial Team added an answer You should pass it through awk first to get rid… May 16, 2026 at 10:24 am
  • Editorial Team
    Editorial Team added an answer No there is no way to customize the results of… May 16, 2026 at 10:24 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm facing few problems especially with event bubbling and also with the live method.
I am facing an issue with my code . the thing is i want
And of course I want to do this code-wise. It's not that there isn't
We are facing one problem with facebook. we integrated FB in our web application,
I have a .NET 2.0 server that seems to be running into scaling problems,
I'm trying to understand the basics of practical programming around character encodings. A few
Is it generally a really bad idea to not use the built-in asp.net membership
My bash fu is not what it should be. I want to create a
I am facing problem when comparing 2 strings values using C:When tag I am
I am facing a strange problem in cakePHP. The issue is when ever i

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.