locked
Help compiling sample adsi code from MSPress RRS feed

  • Question

  • 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 at http://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 available http://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

    Wednesday, June 28, 2006 10:20 AM

Answers

  • You need to link ADSIid.lib and ActiveDS.lib.  Project + properties, Linker, Input, Additional Dependencies = adsiid.lib activeds.lib

    Wednesday, June 28, 2006 10:31 AM

All replies

  • You need to link ADSIid.lib and ActiveDS.lib.  Project + properties, Linker, Input, Additional Dependencies = adsiid.lib activeds.lib

    Wednesday, June 28, 2006 10:31 AM

  • 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

     

    Wednesday, June 28, 2006 11:03 AM
  • 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

    Wednesday, June 28, 2006 11:37 AM
  • I just search through the lib files, looking for the string...

    Wednesday, June 28, 2006 11:44 AM
  • Hmm... findstr /m /i something c:\pathtolibs eh?

    Thanks for the tip. Your help is much appreciated.

    Wednesday, June 28, 2006 12:03 PM