[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

simple import/export problem

Posted on 1998-12-27
1
Medium Priority
?
260 Views
Last Modified: 2010-04-02
hi,
I have 2 functions, SendMsg and Main.
I need to declare SendMsg as a dll and Main as a normal win32 console application and then export SendMsg out to Main.

I declare in the following ways:

for SendMsg
-----------
#define DLLExport __declspec(dllexport)
DLLExport int SendMsg()
{
      // do something
}

for main
--------
#define DLLImport __declspec(dllimport)
extern DLLImport int SendMsg();

void main()
{
      cout<<"sending msg using dll"<<endl;
      int results = SendMsg();
}

I added sendmsg.dll as one of the files in Main for building. And I encountered this problem:

main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) int __cdecl SendMsg(void)" (__imp_?SendMsg@@YAHXZ)
Debug/appa.exe : fatal error LNK1120: 1 unresolved externals

Pls advise what have I missed out?

Thanks,
Andrea
0
Comment
Question by:tanmh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 2

Accepted Solution

by:
zyqwert earned 30 total points
ID: 1181107
To implicitly link like this, you need to include sendmsg.lib in the project main, you do not need sendmsg.dll.

1) Remove SendMsg.dll from project main.
2) Add SendMsg.Lib to project main.

Let me know if there is any problem.



0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
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 viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

650 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