error LNK2019: unresolved external symbol - cl compiler

Discussion in 'C++' started by NewsGroup, Oct 27, 2006.

  1. NewsGroup

    NewsGroup Guest

    Hello,

    I am trying to write a code to interface with ILOG OPL development
    studio using their C++ libraries and header files. But I am encountering
    linker issues, an example being -

    error LNK2019: unresolved external symbol "public: void __thiscall
    IloOplModelI::printSolution(class std::basic_ostream<char,struct
    std::char_traits<char> > &,long)"
    (?printSolution@IloOplModelI@@QAEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@J@Z)
    referenced in function "public: void __thiscall
    IloOplModel::printSolution(class std::basic_ostream<char,struct
    std::char_traits<char> > &)"
    (?printSolution@IloOplModel@@QAEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)

    Any idea why this is happening? Is this because OPL libraries are not
    linked properly? If it is, how do I link the OPL library files using cl
    in the command line? I am pretty new to using the cl compiler. Thanks in
    advance.

    Raj.
     
    NewsGroup, Oct 27, 2006
    #1
    1. Advertising

  2. NewsGroup

    mlimber Guest

    NewsGroup wrote:
    > I am trying to write a code to interface with ILOG OPL development
    > studio using their C++ libraries and header files. But I am encountering
    > linker issues, an example being -
    >
    > error LNK2019: unresolved external symbol "public: void __thiscall
    > IloOplModelI::printSolution(class std::basic_ostream<char,struct
    > std::char_traits<char> > &,long)"
    > (?printSolution@IloOplModelI@@QAEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@J@Z)
    > referenced in function "public: void __thiscall
    > IloOplModel::printSolution(class std::basic_ostream<char,struct
    > std::char_traits<char> > &)"
    > (?printSolution@IloOplModel@@QAEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
    >
    > Any idea why this is happening? Is this because OPL libraries are not
    > linked properly? If it is, how do I link the OPL library files using cl
    > in the command line? I am pretty new to using the cl compiler. Thanks in
    > advance.


    This is not really a C++ *language* issue
    (http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.9), but a
    tools and environment and/or third-party library issue. [OT]However, it
    appears that IloOplModel::printSolution() does not appear in the files
    supplied to the linker. I gather that this is a library class' member
    function, not your own class' member function. Did you build the
    library correctly? Has that function been deprecated or intentionally
    omitted from the library? Have you supplied all necessary files to the
    linker?[/OT]

    For further help, you may want to ask in a forum dedicated to your
    development tools or to the library.

    Cheers! --M
     
    mlimber, Oct 27, 2006
    #2
    1. Advertising

  3. NewsGroup

    pasa_1 Guest

    mlimber wrote:
    > NewsGroup wrote:
    > > I am trying to write a code to interface with ILOG OPL development
    > > studio using their C++ libraries and header files. But I am encountering
    > > linker issues, an example being -
    > >
    > > error LNK2019: unresolved external symbol "public: void __thiscall
    > > IloOplModelI::printSolution(class std::basic_ostream<char,struct
    > > std::char_traits<char> > &,long)"
    > > (?printSolution@IloOplModelI@@QAEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@J@Z)
    > > referenced in function "public: void __thiscall
    > > IloOplModel::printSolution(class std::basic_ostream<char,struct
    > > std::char_traits<char> > &)"
    > > (?printSolution@IloOplModel@@QAEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
    > >
    > > Any idea why this is happening? Is this because OPL libraries are not
    > > linked properly? If it is, how do I link the OPL library files using cl
    > > in the command line? I am pretty new to using the cl compiler. Thanks in
    > > advance.

    >
    > This is not really a C++ *language* issue
    > (http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.9), but a
    > tools and environment and/or third-party library issue. [OT]However, it
    > appears that IloOplModel::printSolution() does not appear in the files
    > supplied to the linker. I gather that this is a library class' member
    > function, not your own class' member function. Did you build the
    > library correctly? Has that function been deprecated or intentionally
    > omitted from the library? Have you supplied all necessary files to the
    > linker?[/OT]
    >
    > For further help, you may want to ask in a forum dedicated to your
    > development tools or to the library.
    >
    > Cheers! --M


    I believe this is linking error is caused because the linker can't find
    the symbol, the following example will also cause this linking error:

    extern char B[100]; // B is not in avilable to the linker
    int main() {
    B[0] = ' ';
    }

    For more details go to the following web site:

    http://msdn2.microsoft.com/en-us/library/799kze2z.aspx
     
    pasa_1, Oct 27, 2006
    #3
  4. NewsGroup

    Michael Guest

    > error LNK2019: unresolved external symbol "public: void __thiscall
    > IloOplModelI::printSolution(class std::basic_ostream<char,struct
    > std::char_traits<char> > &,long)"
    > (?printSolution@IloOplModelI@@QAEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@J@Z)
    > referenced in function "public: void __thiscall
    > IloOplModel::printSolution(class std::basic_ostream<char,struct
    > std::char_traits<char> > &)"
    > (?printSolution@IloOplModel@@QAEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
    >
    > Any idea why this is happening?


    Like others have said, it's a linking error because it can't find the
    appropriate printSolution function. It looks like you're using
    something like printSolution(string&, long) - I've seen this kind of
    link error when my library was compiled with Unicode and my other code
    was compiled without Unicode (or vice versa). Assuming you have a
    printSolution somewhere (i.e., didn't just forget to write that
    function), I'd check Unicode settings.

    Michael
     
    Michael, Oct 27, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Scott Allen
    Replies:
    8
    Views:
    11,053
    Scott Allen
    May 2, 2004
  2. Mastadex
    Replies:
    4
    Views:
    772
    Mastadex
    Oct 1, 2005
  3. Trent
    Replies:
    9
    Views:
    660
    Trent
    Jun 29, 2007
  4. Replies:
    1
    Views:
    340
  5. Tauqir
    Replies:
    2
    Views:
    2,286
    Tauqir
    Apr 9, 2010
Loading...

Share This Page