Solved

Open Watcom IDE - Import DLL

Posted on 2009-05-08
7
720 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

776 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