Unable to link a Win32 API function 
Author Message
 Unable to link a Win32 API function

Hello, I came across a problem I haven't experienced before, I'd need your
help...:

I compiled a program where I use the WNetAddConnection2 function. It
compiles fine (no errors), but when it comes to linking, I get the
(in)famous:


It does get to me. I use the default compiler and linker settings, and since
it did compile I figure the compiler & linker know where that function is
(it's in mpr.dll, by the way), but still....

I find it weird that somehow the linker can't find that function. This is
not my first Win32 function I use, but this sure is the first time I see
this.

I tried building a "release" version of the executable (the online help
suggested that it could be because I was referencing a function in a
"release" DLL while building a "debug" executable, it still doesn't work.

Any insight, anyone ? That'd be appreciated ! Thanks.

Jeff

PS: using VC++ 6 on Win98 & WinNT, won't work on both.



Sun, 22 Apr 2001 03:00:00 GMT  
 Unable to link a Win32 API function
These are just hints...

did you call using scope resolution for Win32 API?   ::WNetAddConnection2(...)
did you include this header file: winnetwk.h
at last try to insert to your project this file: mpr.lib

hope this helps anyhow.
Frank

Quote:

> Hello, I came across a problem I haven't experienced before, I'd need your
> help...:

> I compiled a program where I use the WNetAddConnection2 function. It
> compiles fine (no errors), but when it comes to linking, I get the
> (in)famous:


> It does get to me. I use the default compiler and linker settings, and since
> it did compile I figure the compiler & linker know where that function is
> (it's in mpr.dll, by the way), but still....

> I find it weird that somehow the linker can't find that function. This is
> not my first Win32 function I use, but this sure is the first time I see
> this.

> I tried building a "release" version of the executable (the online help
> suggested that it could be because I was referencing a function in a
> "release" DLL while building a "debug" executable, it still doesn't work.

> Any insight, anyone ? That'd be appreciated ! Thanks.

> Jeff

> PS: using VC++ 6 on Win98 & WinNT, won't work on both.



Sun, 22 Apr 2001 03:00:00 GMT  
 Unable to link a Win32 API function

Quote:

>It does get to me. I use the default compiler and linker settings, and
since
>it did compile I figure the compiler & linker know where that function is
>(it's in mpr.dll, by the way), but still....

Nope. It compiled most likely because you included a header file that
contained a prototype. The prototype does not mention a library at all. You
will need to add the import library (.lib file) to your project under linker
settings.

Regards,
Will



Sun, 22 Apr 2001 03:00:00 GMT  
 Unable to link a Win32 API function
Actually, no, the linker doesn't know where the function is.... mpr.lib
should be in the lib\ subdir of your VC++ installation.

To add this library to your project, add "mpr.lib" in the edit box at :
Project->Settings->Link->Object/library modules.  Be sure to add it for "All
configurations" of your project.

Thanks,
Andrew

From MSDN's help for WNetAddConnection2:

QuickInfo
  Windows NT: Use version 3.1 or later.
  Windows: Use Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in winnetwk.h.
  Import Library: Use mpr.lib.

Quote:

>Hello, I came across a problem I haven't experienced before, I'd need your
>help...:

>I compiled a program where I use the WNetAddConnection2 function. It
>compiles fine (no errors), but when it comes to linking, I get the
>(in)famous:


>It does get to me. I use the default compiler and linker settings, and
since
>it did compile I figure the compiler & linker know where that function is
>(it's in mpr.dll, by the way), but still....

>I find it weird that somehow the linker can't find that function. This is
>not my first Win32 function I use, but this sure is the first time I see
>this.

>I tried building a "release" version of the executable (the online help
>suggested that it could be because I was referencing a function in a
>"release" DLL while building a "debug" executable, it still doesn't work.

>Any insight, anyone ? That'd be appreciated ! Thanks.

>Jeff

>PS: using VC++ 6 on Win98 & WinNT, won't work on both.



Sun, 22 Apr 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Unable to link a Win32 API function

2. Unable to link a Win32 API function

3. VC++ typedef for a function pointer to Win32 API function

4. struct pointers, how? (importing functions from win32 api)

5. WinNT and Win32 API security functions

6. Win32 API functions caching data?

7. StdLib functions vs. Win32 API

8. How to use the Win32 API function----LogonUser?

9. Creating a thread function using Win32 API

10. problem with win32 Backup API functions

11. Need an API function to check for/map network drive under Win32

12. win32 api functions

 

 
Powered by phpBB® Forum Software