?
Solved

simple import/export problem

Posted on 1998-12-27
1
Medium Priority
?
256 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

Independent Software Vendors: 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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

801 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