Help compiling sample adsi code from MSPress

Hi

I am a complete newbie to programming and would like to try and learn VC++ with the intention of writing small speedy apps specifically for AD.

For kicks I tried compiling the code available athttp://www.microsoft.com/mspress/books/sampchap/4477d.asp.

Basically I created a new win32 console application project as an empty project. I then added a new .cpp file with the code copied from the above link. I have installed VC++ express and the R2 SDK and pointed VC++ at the SDK as per instructions availablehttp://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/default.aspx.

. However when I try to start debugging it fails with the errors below.

ad.obj : error LNK2019: unresolved external symbol _FreeADsMem@4 referenced in function _main

ad.obj : error LNK2019: unresolved external symbol _ADsGetObject@12

referenced in function _main

ad.obj : error LNK2001: unresolved external symbol _IID_IDirectoryObject

C:\Documents and Settings\go dasa\My Documents\Visual Studio

2005\Projects\test\Debug\test.exe : fatal error LNK1120: 3 unresolved externals

I would appreciate if you could explain why the code above doesnt compile.

TIA

Godasa

[2035 byte] By [Godasa] at [2007-12-21]
# 1
You need to link ADSIid.lib and ActiveDS.lib. Project + properties, Linker, Input, Additional Dependencies = adsiid.lib activeds.lib

nobugz at 2007-8-30 > top of Msdn Tech,Visual C++,Visual C++ General...
# 2


Thank you so much! I was wondering how I would know which libs I need to link the project to. So I looked up freeadsmem, adsgetobject and idirectoryobject. All of them are documented as require activeds.dll. So I just added activeds.lib and tried building and it fails with.

Build started: Project: test, Configuration: Debug Win32

Linking...

ad.obj : error LNK2001: unresolved external symbol _IID_IDirectoryObject

C:\Documents and Settings\go dasa\My Documents\Visual Studio 2005\Projects\test\Debug\test.exe : fatal error LNK1120: 1 unresolved externals

However if I add adsiid.lib it build correctly. Could you explain how one identifies which libs he needs to link to a project?

TIA

Godasa at 2007-8-30 > top of Msdn Tech,Visual C++,Visual C++ General...
# 3
I was wondering how I would know which libs I need to link the project to. So I looked up freeadsmem, adsgetobject and idirectoryobject. All of them are documented as require activeds.dll. So I just added activeds.lib and tried building and it fails with.

Build started: Project: test, Configuration: Debug Win32

Linking...

ad.obj : error LNK2001: unresolved external symbol _IID_IDirectoryObject

C:\Documents and Settings\go dasa\My Documents\Visual Studio 2005\Projects\test\Debug\test.exe : fatal error LNK1120: 1 unresolved externals

However if I add adsiid.lib it build correctly. Could you explain how one identifies which libs he needs to link to a project?

TIA

Godasa at 2007-8-30 > top of Msdn Tech,Visual C++,Visual C++ General...
# 4
I just search through the lib files, looking for the string...

nobugz at 2007-8-30 > top of Msdn Tech,Visual C++,Visual C++ General...
# 5

Hmm... findstr /m /i something c:\pathtolibs eh?

Thanks for the tip. Your help is much appreciated.

Godasa at 2007-8-30 > top of Msdn Tech,Visual C++,Visual C++ General...