error LNK2019: unresolved external symbol - cl compiler

N

NewsGroup

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.
 
M

mlimber

NewsGroup said:
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
 
P

pasa_1

mlimber said:
NewsGroup said:
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
 
M

Michael

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,961
Messages
2,570,130
Members
46,689
Latest member
liammiller

Latest Threads

Top