- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have not posted in a while and am not sure that I am in the correct location to pose this question.
Regardless, I have been provided a DLL from which I want to invoke a function that is within the DLL.
I know the function name and the argument list.
I have declared the function.
No mater what I do, set DLL as a resource or go to TOOLS COMPILERS and add the directory to the list of places to look, I am constantly getting UNRESOLVED LINK.
Any help?
How can I get access to this DLL and the functions within this DLL?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If all you have is a DLL, you can't link to it. Linking requires a .LIB - for DLLs an "export .LIB" is created when the DLL is linked.
Since you don't have that, you have to dynamically load the DLL, get the address of the procedure and then call it. This is illustrated in the compiler_f\DLL\DynamicLoad sample that is part of the Intel Parallel Studio XE for Windows Sample Bundle (make sure you get the one for Windows.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Turns out that I do have the .LIB.
So, should I just put the .LIB in the same directory as the DLL?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I did put the appropriate .LIB in the folder and then through the TOOLS COMPILERS put the path into the X64 tab for Libraries and it still did not work. I am confused here why it cannot see the DLL nor the embedded function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just putting the .LIB in the folder doesn't do anything. You have to tell the linker to look in the .LIB. The easiest way to do that is to add the .LIB to your project as if it were a source file. An alternative is to give the name of the .LIB in the project property Linker > Input > Additional Dependencies.
I would not recommend modifying the Tools ... Compilers tab unless this is a location you want to use for all projects. Linker > General > Additional Library Directories is a place you can add project-specific paths.
The DLL itself needs to be in a place Windows will look for it. In the same folder as the EXE will work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
The static library .lib associated with a dynamic library .dll contains for each function the necessary code to call to each of them.
It must be linked with the application and the .dll file is not required at this step.
At runtime, the .dll file must be in a location where the application can find it, in the same directory as the .exe is a common place. See Windows documentation to get information of search mechanism for .dll.
If you don't have the .lib file, call to .dll functions can be done using the loadlibray and getprocaddress functions. refer to the documentation of these functions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve, thanks as always. I did end up adding as a dependency and the error has changed. Now, instead of saying it cannot find the function name, it is throwing that it cannot open an input file C:\PROGRAM.obj
Any clues?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Perhaps, you needed to put the full filename of your external library in quotes due to embedded spaces?
This looks suspiciously like the linker was passed this:
link foo.obj c:\program files (x86)\SomeDirectory\SomeOther\mylib.lib
and parsed the command line as having these files:
foo.obj
c:\program.obj
files.obj
(X86)\SomeDirectory\SomeOther\mylib.lib
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Enclose the path in ""
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks for the different input.
i have looked at the tips at the bottom of the properties as i move through the lists.
finally, or maybe not, i have the following error: unresolved...cannot open 'JHJHJH.lib'
any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is not possible to tell you what to do if you report only the error messages without also reporting what steps you took earlier that may have caused those messages to be given.
For instance, the file name 'JHJHJH.lib' is not a random name. You must have typed it in into some Visual Studio setting, perhaps by mistake.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Attach a ZIP file with your .vfproj file and the buildlog.htm, from the Debug or Release folder after a failed build. This will let us see what you are doing.
![](/skins/images/92C5BEB64AD8DB80DE2B33716453E265/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page