Simple question about dllimport  
Author Message
agraymngmailcom





PostPosted: Fri Apr 28 09:09:28 CDT 2006 Top

Visual Studio C++ >> Simple question about dllimport I've got a h file for a usb device that has definitions of function exported
from a dll. An example would be (with #defines translated):

extern "C" __declspec(dllimport) int __stdcall FT_Open(int deviceNumber, int
*pHandle);

but where is the actual dll filename specified so my program knows where to
find it?

Thanks,
Michael

Visual Studio227  
 
 
Victor





PostPosted: Fri Apr 28 09:09:28 CDT 2006 Top

Visual Studio C++ >> Simple question about dllimport Michael C wrote:
> I've got a h file for a usb device that has definitions

declarations

> of function
> exported

imported (apparently)

> from a dll. An example would be (with #defines translated):
>
> extern "C" __declspec(dllimport) int __stdcall FT_Open(int
> deviceNumber, int *pHandle);
>
> but where is the actual dll filename specified so my program knows
> where to find it?

That should be resolved during linking. Your project needs to have
the "export library" of that DLL supplied in the linker inputs.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


 
 
Bruno





PostPosted: Fri Apr 28 09:13:49 CDT 2006 Top

Visual Studio C++ >> Simple question about dllimport > I've got a h file for a usb device that has definitions of function
> exported
> from a dll. An example would be (with #defines translated):
>
> extern "C" __declspec(dllimport) int __stdcall FT_Open(int deviceNumber,
> int
> *pHandle);
>
> but where is the actual dll filename specified so my program knows where
> to
> find it?

it does not have to be specified at all.

the normal course of action is to add the dll's corresponding .lib file to
your linker input.
if your code references the function, the linker will search the import
directive in the lib file and add it
to your executable. that way your exe will load the dll ar runtime.

your exe will search the dll alongside your exe, in the current folder, in
the windows folders or in the folders that are specified in the path
variable.

--

Kind regards,
Bruno van Dooren
EMail@HideDomain.com
Remove only "_nos_pam"


 
 
Michael





PostPosted: Fri Apr 28 09:42:54 CDT 2006 Top

Visual Studio C++ >> Simple question about dllimport "Bruno van Dooren" <EMail@HideDomain.com> wrote in message
> it does not have to be specified at all.
>
> the normal course of action is to add the dll's corresponding .lib file to
> your linker input.
> if your code references the function, the linker will search the import
> directive in the lib file and add it
> to your executable. that way your exe will load the dll ar runtime.
>
> your exe will search the dll alongside your exe, in the current folder, in
> the windows folders or in the folders that are specified in the path
> variable.

Thanks for the reply bruno. What happens if I don't have a lib file? All I
got was a h file in a pdf doc.

Cheers,
Michael


 
 
Michael





PostPosted: Fri Apr 28 09:43:45 CDT 2006 Top

Visual Studio C++ >> Simple question about dllimport "Victor Bazarov" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> Michael C wrote:
>> I've got a h file for a usb device that has definitions
>
> declarations
>
>> of function
>> exported
>
> imported (apparently)

Exported from the dll, imported by my code I presume?

Michael


 
 
Victor





PostPosted: Fri Apr 28 10:19:20 CDT 2006 Top

Visual Studio C++ >> Simple question about dllimport Michael C wrote:
> "Victor Bazarov" <EMail@HideDomain.com> wrote in message
> news:EMail@HideDomain.com...
>> Michael C wrote:
>>> I've got a h file for a usb device that has definitions
>>
>> declarations
>>
>>> of function
>>> exported
>>
>> imported (apparently)
>
> Exported from the dll, imported by my code I presume?

Right, but you were showing us _your_ code, weren't you? :-)


 
 
Igor





PostPosted: Fri Apr 28 10:22:31 CDT 2006 Top

Visual Studio C++ >> Simple question about dllimport Michael C <EMail@HideDomain.com> wrote:
> Thanks for the reply bruno. What happens if I don't have a lib file?
> All I got was a h file in a pdf doc.

Presumably, you also have the DLL itself. See KB Article KB131313 "How
To Create 32-bit Import Libraries Without .OBJs or Source".
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


 
 
Michael





PostPosted: Fri Apr 28 18:41:58 CDT 2006 Top

Visual Studio C++ >> Simple question about dllimport "Victor Bazarov" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> Right, but you were showing us _your_ code, weren't you? :-)

Read my post again, I what I wrote was technically correct. When I said "a
dll" I meant the dll for the usb device. Not that it's that important :-)

"I've got a h file for a usb device that has definitions of function
exported
from a dll."

Michael


 
 
Michael





PostPosted: Fri Apr 28 19:33:21 CDT 2006 Top

Visual Studio C++ >> Simple question about dllimport "Igor Tandetnik" <EMail@HideDomain.com> wrote in message
news:%EMail@HideDomain.com...
> Michael C <EMail@HideDomain.com> wrote:
>> Thanks for the reply bruno. What happens if I don't have a lib file?
>> All I got was a h file in a pdf doc.
>
> Presumably, you also have the DLL itself. See KB Article KB131313 "How To
> Create 32-bit Import Libraries Without .OBJs or Source".

Thanks Igor, after reading the article it sounded like a lot of work so I
managed to hunt down the lib file. It was packaged with the drivers instead
of the developer info for some reason. Everything is working good now.

Michael