CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2009
    Location
    Boston
    Posts
    364

    linker error, can't see the problem, not sure what to do next

    Hello,

    I have a function in one src file called from code in a different src file.

    In ig_cfunc.cpp
    Code:
    #include "ig_tools.h"
    
    int x2_count = 0.0;
    float rel_branch_degree_tmp = 0.0;
    string type;
    
    vector<int> is_disp_type;
    
    rel_branch_degree_tmp = calc_rel_branch_degree( type,
                                                    x2_count,
                                                    ig_set[ig_set_number].atomNum,
                                                    ig_set[ig_set_number].sub_atomNum,
                                                    is_disp_type );

    In ig_tools.h
    Code:
    extern float calc_rel_branch_degree( const string &type,
                                         int &N, 
                                         const vector<int> &dispersion_subgraph,
                                         const vector<int> &sub_list,
                                         const vector<int> &dispersion_type_list );
    In ig_tools.cpp
    Code:
    //  SUBROUTINE to compute the second order difference chi index
    float calc_rel_branch_degree(const string &type,
                                 int &N, 
                                 const vector<int> &dispersion_subgraph,
                                 const vector<int> &sub_list,
                                 const vector<int> &dispersion_type_list) {
    
    ...
    
    }
    I am getting a linker error,
    Code:
    ig_cfunc.cpp:1609: error: `calc_rel_branch_degree' undeclared (first use this function)
    I have deleted all of the objects and recompiled to make sure that everything is in sync. I can't see what the issue is here and I'm not sure what to do next. This code actually worked until I changed the name of the function, so the types are all correct and such. This is the format I use for all external functions, I am I have no idea what the issue is here.

    Suggestions would be greatly appreciated.

    LMHmedchem

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: linker error, can't see the problem, not sure what to do next

    What compiler are you using?

    In ig_tools.h, why is calc_rel_branch_degree() declared as extern?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured