Search code examples
firefoxxul

Symbols Missing for nsiCookieManager2 program


Please help me with the missing LIBs for this MOZILLA program. Trying to create cookie using nsICookieManager2 I have tried with all the existing libs in Mozilla SDK Regards

C:\Code>cl.exe FFCookie.cpp /I "C:\xulrunner-sdk\include" mozalloc.lib xpcomglue.lib /link /LIBPATH:"C:\xulrunner-sdk\lib"

Symbols Missing:

FFCookie.obj : error LNK2019: unresolved external symbol "public: void __thiscall nsCOMPtr_base::assign_from_gs_contractid_with_er ror(class nsGetServiceByContractIDWithError const &,struct nsID const &)" (?assign_from_gs_contractid_with_error@nsCOMPtr_base@@QA EXABVnsGetServiceByContractIDWithError@@ABUnsID@@@Z) referenced in function "public: __thiscall nsCOMPtr:: nsCOMPtr(class nsGetServiceByContractIDWithError const &)" (??0?$nsCOMPtr@VnsICookieManager@@@@QAE@ABVnsGe tServiceByContractIDWithError@@@Z)

FFCookie.obj : error LNK2019: unresolved external symbol "public: void __thiscall nsCOMPtr_base::assign_from_qi(class nsQueryInter face,struct nsID const &)" (?assign_from_qi@nsCOMPtr_base@@QAEXVnsQueryInterface@@ABUnsID@@@Z) referenced in function "public: __t hiscall nsCOMPtr::nsCOMPtr(class nsQueryInterface)" (??0?$nsCOMPtr@VnsICookieMan ager2@@@@QAE@VnsQueryInterface@@@Z) FFCookie.exe : fatal error LNK1120: 2 unresolved externals

#include "nsICookieManager.h"
#include "nsICookieManager2.h"
#include "nsServiceManagerUtils.h"
#include "nsComPtr.h"
#include "nsNetCID.h"
#include "nsStringAPI.h"
#include "mozilla-config.h"
int main()
{

    nsresult rv;
    nsCOMPtr<nsICookieManager> cookieManager = do_GetService (NS_COOKIEMANAGER_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);

    if (cookieManager)
    {
      nsCOMPtr<nsICookieManager2> cookieManager2 = do_QueryInterface(cookieManager);
      if (cookieManager2)
      {
        cookieManager2->Add(NS_LITERAL_CSTRING("ud.abc.com"),
                       NS_LITERAL_CSTRING("//"),
                       NS_LITERAL_CSTRING("TK"),
                       NS_LITERAL_CSTRING("abc"),  0x1, 0x1, 0, -1);

      }
    }
    return 0;
}

Questions:

I dont find any info with function documentation regarding which LIB to include (as I find on MSDN)

Any clue on how to figure out LIB corresponding to particular function for MOZILLA.


Solution

  • The problem isn't with the lib, the symbol missing is defined in the xpcomglue library. However, you seem to have some compile parameters that don't match the parameters used to compile XULRunner/Firefox. The symbols your compiler is looking for contain "QAEX" as parameter description whereas the library defines them with "QAIX". Looking at the name mangling table, your compiler expects unsigned char where Mozilla has unsigned int. I suspect that the reason is you compiling your application without Unicode support - change main() into wmain()?