Solved

Open Watcom IDE - Import DLL

Posted on 2009-05-08
7
708 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
Comment Utility
>> 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
Comment Utility
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
Comment Utility
Doh, I'm slow tonight...
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 1

Author Comment

by:secondeff
Comment Utility
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
Comment Utility
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
Comment Utility
Do you know how to add to my project as a static library?
0
 
LVL 40

Expert Comment

by:evilrix
Comment Utility
Use dependency walker to confirm the entry point does exist in the DLL
http://www.dependencywalker.com/
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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…
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 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.

771 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

12 Experts available now in Live!

Get 1:1 Help Now