Solved

Open Watcom IDE - Import DLL

Posted on 2009-05-08
7
746 Views
Last Modified: 2012-06-27
Hi,
I am working on a project using the Open Watcom IDE. I wrote and compiled a seperate DLL that I want to use in my main project. I declared it in my code using __declspec(dllimport) (this works for all of windows api functions), but I get a undefined function linker error. I believe I have to change the linker switches to import the .lib file, but I'm not sure how to do this. Any ideas?
Thanks
0
Comment
Question by:secondeff
[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
  • 3
  • 2
  • 2
7 Comments
 
LVL 40

Accepted Solution

by:
evilrix earned 125 total points
ID: 24341285
>> I declared it in my code using __declspec(dllimport)
And when you built the dll you used __declspec(export) right?

>> I believe I have to change the linker switches to import the .lib
You need to add the library stub generated when you built the DLL to your project as a static library. Alternativly, you can load the DLL at runtile using LoadLibrary but I doubt this is what you wan to do.
0
 
LVL 40

Assisted Solution

by:mrjoltcola
mrjoltcola earned 125 total points
ID: 24341299
You are on the right track. You need to link the import lib, assuming one was created when you compiled the DLL

I don't use Open Watcom, but from what I can read, you need to use the IMPORT directive on the comand line:

Assuming you need to import function func from myapi.dll

IMPORT func_ myapi

See: http://www.openwatcom.org/index.php/Writing_DLLs
0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24341302
Doh, I'm slow tonight...
0
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!

 
LVL 1

Author Comment

by:secondeff
ID: 24341433
Thanks for the feedback. I added the directive IMPORT func_ myapi to the linker. It finally linked without any problems. However, I get this error message when I run the program: "The procedure entry point func_ could not be located in the dynamic link library myapi." I'm using just a simple function to test loading a dll. Here is my dll source code:
__declspec(dllexport) void func()
{
}
0
 
LVL 1

Author Comment

by:secondeff
ID: 24341461
evilrix - A library file was generated when I compiled the dll. I copied both files into the project directory, and added the .lib file as a new source to my project. I still get the same linker error.
0
 
LVL 1

Author Comment

by:secondeff
ID: 24341466
Do you know how to add to my project as a static library?
0
 
LVL 40

Expert Comment

by:evilrix
ID: 24341481
Use dependency walker to confirm the entry point does exist in the DLL
http://www.dependencywalker.com/
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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
  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 …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

690 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