?
Solved

link error

Posted on 2003-03-28
2
Medium Priority
?
283 Views
Last Modified: 2010-04-01
Below is my program and I am getting linking errors.  They are listed below as well.  
I know that it is something small and overlooked but please help me out.  Thank you.

#include "cppvm.h"
int main()
{
  // connect to pvm
     cppvmConnection pvmConn;
  // send descriptor
  // (blocking send
  //  to parent process)
  cppvmSendStream sendStrm(pvmConn,
    CPPvmSBparent);
 
  // message
  cppvmString sendMsg("hello world!");
 
  // send message
  sendStrm << sendMsg;

  return 0;
}

Linking...
LINK : warning LNK4044: unrecognized option "nodefaultlibrary:libcd"; ignored
hello2.obj : error LNK2001: unresolved external symbol "public: __thiscall cppvmConnection::cppvmConnection(void)" (??0cppvmConnection@@QAE@XZ)
hello2.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall cppvmConnection::~cppvmConnection(void)" (??1cppvmConnection@@UAE@XZ)
hello2.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall cppvmSendStream::~cppvmSendStream(void)" (??1cppvmSendStream@@UAE@XZ)
hello2.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall cppvmString::~cppvmString(void)" (??1cppvmString@@UAE@XZ)
hello2.obj : error LNK2001: unresolved external symbol "public: __thiscall cppvmString::cppvmString(char *)" (??0cppvmString@@QAE@PAD@Z)
hello2.obj : error LNK2001: unresolved external symbol "public: __thiscall cppvmSendStream::cppvmSendStream(class cppvmConnection &,enum cppvmSendConnection,int)" (??0cppvmSendStream@@QAE@AAVcppvmConnection@@W4cppvmSendConnection@@H@Z)
hello2.obj : error LNK2001: unresolved external symbol "public: void __thiscall cppvmObject::cppvmSend(class cppvmSendStream &)" (?cppvmSend@cppvmObject@@QAEXAAVcppvmSendStream@@@Z)
Debug/hello2.exe : fatal error LNK1120: 7 unresolved externals
Error executing link.exe.
0
Comment
Question by:silverFox
2 Comments
 
LVL 12

Accepted Solution

by:
Salte earned 300 total points
ID: 8227993
You didn't link the library that you should include to call the functions and stuff defined in that include file. You include the #include file but didn't tell the linker to include the .lib file.

When you do #include "foo.h" you just tell the compiler that there are some functions and methods available somewhere and the arguments etc to them. The #include "foo.h" does not magically cause those functions to be defined. They are defined when the linker links the corresponding foo.lib file.

Change your makefile or project file to include the library that comes with that include file "cppvm.h"

Alf
0
 
LVL 3

Expert Comment

by:Madz
ID: 8230058
Assuming cppvm.cpp is the file that contains the definition of the functions that you are calling, add either the lib in which cppvm.cpp is included(if one exists) or add cppvm.cpp directly into your project. Both ways the linker would find the function definitions.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question