Friday, July 10, 2009

Unresolved external NS_NewGenericModule2...resolved

Today I tryed to build my first XPCOM module using this link. It's a great tutorial and you can make a XPCOM component in no time, but when I tryed to build it in windows I got this error:

Error 1 error LNK2001: unresolved external symbol "unsigned int __cdecl NS_NewGenericModule2(struct nsModuleInfo const *,class nsIModule * *)" (?NS_NewGenericModule2@@YAIPBUnsModuleInfo@@PAPAVnsIModule@@@Z)

I've searched and found out that I wasn't the only one having this issue. Some suggested you have to change the Gecko SDK version, but the real solution to the problem is this.
To solve the problem and set the flag in MVS you should go to Project > Properties > Configuration properties > Linker > Command line and then just paste "-LIBPATH:C:\...\gecko-sdk\lib xpcomglue_s.lib xpcom.lib nspr4.lib" in the Additional options textbox and voila!
Hope this helps!

P.S. I did't came with a new solution to the problem, but made it clear how to add linker flags to your MVS project.