Solved

Open Watcom IDE - Import DLL

Posted on 2009-05-08
7
712 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
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.

910 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now