error LNK2001: unresolved external symbol _ConvertStringSidToSid

  • Thread starter Haral Tsitsivas
  • Start date
H

Haral Tsitsivas

I am compiling a C program that uses the ConvertStringSidToSid function and
I get the above undefined error at link time, even though I have specified
the correct include and lib directories in the MS Visual Studio, and I
include the advapi32.lib first on the list of libraries! Does anyone see
anything in the dsp file generated by VSC++, pasted below?:

# Microsoft Developer Studio Project File - Name="sqlacct" - Package
Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **

# TARGTYPE "Win32 (x86) Console Application" 0x0103

CFG=sqlacct - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "sqlacct.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "sqlacct.mak" CFG="sqlacct - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "sqlacct - Win32 Release" (based on "Win32 (x86) Console
Application")
!MESSAGE "sqlacct - Win32 Debug" (based on "Win32 (x86) Console
Application")
!MESSAGE

# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe

!IF "$(CFG)" == "sqlacct - Win32 Release"

# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "sqlacct___Win32_Release"
# PROP BASE Intermediate_Dir "sqlacct___Win32_Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "sqlacct___Win32_Release"
# PROP Intermediate_Dir "sqlacct___Win32_Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D
"_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D
"_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 advapi32.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
/out:"Release/sqlacct.exe"

!ELSEIF "$(CFG)" == "sqlacct - Win32 Debug"

# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "sqlacct___Win32_Debug"
# PROP BASE Intermediate_Dir "sqlacct___Win32_Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D
"_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE"
/D "_MBCS" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
/pdbtype:sept
# ADD LINK32 advapi32.lib netapi32.lib wsock32.lib kernel32.lib user32.lib
gdi32.lib winspool.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib
uuid.lib odbc32.lib odbccp32.lib winspool.lib comdlg32.lib /nologo
/subsystem:console /incremental:no /map /debug /machine:I386 /pdbtype:sept
# SUBTRACT LINK32 /pdb:none

!ENDIF

# Begin Target

# Name "sqlacct - Win32 Release"
# Name "sqlacct - Win32 Debug"
# Begin Group "Source Files"

# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File

SOURCE=.\sqlacct.c
# End Source File
# End Group
# Begin Group "Header Files"

# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"

# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

The link error again:

Linking...
LINK : warning LNK4075: ignoring /EDITANDCONTINUE due to /INCREMENTAL:NO
specification
sqlacct.obj : error LNK2001: unresolved external symbol
_ConvertStringSidToSid
Debug/sqlacct.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

sqlacct.exe - 2 error(s), 1 warning(s)
 
L

LiquidJ

ConvertStringSidToSid() works only on W2k and above. Therefore, you must
define _WIN32_WINNT=0x0500 before the compiler will recognize the definition
of that function. Read carefully the funtion declaration in Sddl.h.


{L}
 
H

Haral Tsitsivas

Thanks! After I defined that at the top of the file it worked!
But isn't that what windows.h should have been for?
 
L

LiquidJ

Hmm...not really. ConvertStringSidToSid() only works on W2k and above, so
you have to tell the compiler that you understand that. There aren't
separate Platform SDK header files for Windows 98, 2000, NT, etc., so this
is how Microsoft tries to make you realize the dependancies. You can
compile a program for Win98 on a Win2k machine using the same header files
as when you compile a program for WinXP, for example.

Put another way, since there is only one set of headers and libs for all
versions of Windows, Microsoft doesn't want to thinking that just because
you compiled a program using, for example, ConvertStringSidToSid(), that you
can run it on Win98. This is the way you acknowledge the version
requirement.

Cruddy explanation, I know, but I'm having trouble putting my thoughts to
paper (or screen) today :)


{L}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top