Solved

Open Watcom IDE - Import DLL

Posted on 2009-05-08
7
726 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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 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…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

860 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