Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Cannot Link some code using LM api due to unresolved symbols

149 views
Skip to first unread message

Vincent Demers

unread,
Oct 30, 2001, 10:54:17 PM10/30/01
to
Hi, whenever I try to link the object from the code below I get this:

Linking...
NetSmple.obj : error LNK2001: unresolved external symbol
_NetLocalGroupAddMembers@20
NetSmple.obj : error LNK2001: unresolved external symbol
_NetLocalGroupAdd@16
NetSmple.obj : error LNK2001: unresolved external symbol _NetApiBufferFree@4
NetSmple.obj : error LNK2001: unresolved external symbol _NetUserAdd@16
NetSmple.obj : error LNK2001: unresolved external symbol _NetGetDCName@12
Debug/NetSmple.exe : fatal error LNK1120: 5 unresolved externals
Error executing link.exe.

NetSmple.exe - 6 error(s), 0 warning(s)

Can you help??

TIA

Vincent Demers

Here's the beginning of the code (from Microsoft Platform SDK samples):

#define UNICODE 1
#include <windows.h>
#include <lm.h>
#include <stdio.h>
#include <stdlib.h>

int __cdecl main( int cArgs, char *pArgs[] );

NET_API_STATUS NetSample( LPWSTR lpszDomain,
LPWSTR lpszUser,
LPWSTR lpszPassword,
LPWSTR lpszLocalGroup )
{

USER_INFO_1 user_info;
LOCALGROUP_INFO_1 localgroup_info;
LOCALGROUP_MEMBERS_INFO_3 localgroup_members;
LPWSTR lpszPrimaryDC = NULL;
NET_API_STATUS err = 0;
DWORD parm_err = 0;

/* First get the name of the Primary Domain Controller. */
/* Be sure to free the returned buffer */

err = NetGetDCName( NULL, /* Local Machine */
lpszDomain, /* Domain Name */
(LPBYTE *)&lpszPrimaryDC ); /* returned PDC */

if ( err != 0 )
{
printf( "Error getting DC name: %d\n", err );
return( err );
}


/* Set up the USER_INFO_1 struct */

user_info.usri1_name = lpszUser;
user_info.usri1_password = lpszPassword;
user_info.usri1_priv = USER_PRIV_USER;
user_info.usri1_home_dir = TEXT("");
user_info.usri1_comment = TEXT("Sample User");
user_info.usri1_flags = UF_SCRIPT;
user_info.usri1_script_path = TEXT("");

err = NetUserAdd( lpszPrimaryDC, /* PDC name */
1, /* level */
(LPBYTE)&user_info, /* input buffer */
&parm_err ); /* parameter in error */


and so on...

Ted Ferenc

unread,
Oct 31, 2001, 3:51:30 AM10/31/01
to
look at the MSDN

Header: Declared in Lmaccess.h; include Lm.h.
Library: Use Netapi32.lib.


--

Ted Ferenc (just remove the garbage to email)
"Vincent Demers" <spamv...@vincentdemers.com> wrote in message
news:e5Kn8#bYBHA.1644@tkmsftngp03...

Vincent Demers

unread,
Oct 31, 2001, 7:36:59 AM10/31/01
to
Thanks this solved my problem ,

I am new to c/c++ windows programming.

I put Netapi32.lib in the objecy/Library section of the project settings.

Thanks again

Vincent.

"Ted Ferenc" <tedf...@hotmail.com> wrote in message
news:9roe3d$un9o0$1...@ID-27390.news.dfncis.de...

0 new messages