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.
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()?
Related
We are getting strange unresolved symbols linking errors since we updated to Visual Studio 2015 update 3. Anyone else encountered the same kind of issues ?
What is really weird is that boost::get_pointer is a template method, defined in a boost header. I do not understand how we can get an undefined external symbol in that case :(.
Here is a reproducer, with boost 1.61 and Python 3.5.1:
#include <vector>
#include <boost/python.hpp>
using namespace boost::python;
class Canard {
public:
Canard() {}
virtual ~Canard() {}
};
BOOST_PYTHON_MODULE(coin)
{
register_ptr_to_python< std::shared_ptr<Canard> >();
}
And the error:
Severity Code Description Project File Line
Error LNK2019 unresolved external symbol "class Canard const volatile * __cdecl boost::get_pointer<class Canard const volatile >(class Canard const volatile *)" (??$get_pointer#$$CDVCanard###boost##YAPEDVCanard##PEDV1##Z) referenced in function "private: static struct _typeobject * __cdecl boost::python::objects::make_ptr_instance<class Canard,struct boost::python::objects::pointer_holder<class std::shared_ptr<class Canard>,class Canard> >::get_derived_class_object<class Canard>(struct boost::mpl::bool_<1>,class Canard const volatile *)" (??$get_derived_class_object#VCanard###?$make_ptr_instance#VCanard##U?$pointer_holder#V?$shared_ptr#VCanard###std##VCanard###objects#python#boost###objects#python#boost##CAPEAU_typeobject##U?$bool_#$00#mpl#3#PEDVCanard###Z) CCMasterKernelPyPy C:\work\dev\builds\internal\Master\SDK\MasterKernelPyPy\main.obj 1
But as soon as I remove the virtual in front of the destructor of the Canard class, then it starts working.... Does anyone have a clue ? Is it a Visual Studio bug ?
Visual Studio 2015 update 3 has added lots of features and improvements (see the release notes https://www.visualstudio.com/news/releasenotes/vs2015-update3-vs#visualcpp).
It also have some known issues (https://msdn.microsoft.com/vs-knownissues/vs2015-update3 see the Passing non-pointer-like types to uninitialized_copy section).
To fix your problem you need to explicitly specify the conversion to pointer of your class, explicitly:
namespace boost
{
template <>
Canard const volatile * get_pointer<class Canard const volatile >(
class Canard const volatile *c)
{
return c;
}
}
Good luck,
Ohad
I statically link fw.lib in my C++/CLI project, and get these errors:
Error 1 error LNK2028: unresolved token (0A00001B) "extern "C" unsigned int __cdecl func(unsigned int,unsigned char *)" (?func##$$J0YAIIPAE#Z) referenced in function "public: static void __clrcall Sdk::Native::Method(void)" (?Method#Native#Sdk##$$FSMXXZ) C:\project\Sdk.obj Sdk
Error 2 error LNK2019: unresolved external symbol "extern "C" unsigned int __cdecl func(unsigned int,unsigned char *)" (?func##$$J0YAIIPAE#Z) referenced in function "public: static void __clrcall Sdk::Native::Method(void)" (?Method#Native#Sdk##$$FSMXXZ) C:\project\Sdk.obj Sdk
What do I do wrong ? I did this:
Added the lib path in [project properties -> Library Directories]
Added fw.lib file under [project properties -> Additional Dependencies]
Wrapped all functions in fw.h with extern "C" {...}
Any idea ?
Problem solved...
Apparently when you link, for instance, x64 bit into x32 project (and vice versa ??), the linker produces a very general link-error.
FYI :-)
I trying to compile some OpenCv functions and I included the cvhaartraining.h from the directory C:\OpenCV2.2\modules\haartraining.
I put on Project > 'Your Project Name' Properties... > Configuration Properties > Linker > Input >
all the .lib files in the opencv library:
"C:\OpenCV2.2\lib\opencv_highgui220d.lib" "C:\OpenCV2.2\lib\opencv_core220d.lib" "C:\OpenCV2.2\lib\opencv_ml220d.lib" "C:\OpenCV2.2\lib\opencv_video220d.lib" "C:\OpenCV2.2\lib\opencv_legacy220d.lib" "C:\OpenCV2.2\lib\opencv_imgproc220d.lib" "C:\OpenCV2.2\lib\opencv_objdetect220d.lib" "C:\OpenCV2.2\lib\opencv_ts220.lib" "C:\OpenCV2.2\lib\opencv_calib3d220d.lib" "C:\OpenCV2.2\lib\opencv_contrib220d.lib" "C:\OpenCV2.2\lib\opencv_features2d220d.lib"
"C:\OpenCV2.2\lib\opencv_ffmpeg220d.lib" "C:\OpenCV2.2\lib\opencv_flann220d.lib" "C:\OpenCV2.2\lib\opencv_gpu220d.lib"
but it still won't link.
The error I get is:
vecToFiles.obj : error LNK2019: unresolved external symbol "void __cdecl cvShowVecSamples(char const *,int,int,double)" (?cvShowVecSamples##YAXPBDHHN#Z) referenced in function _main
vecToFiles.obj : error LNK2019: unresolved external symbol "int __cdecl cvCreateTrainingSamplesFromInfo(char const *,char const *,int,int,int,int)" (?cvCreateTrainingSamplesFromInfo##YAHPBD0HHHH#Z) referenced in function _main
vecToFiles.obj : error LNK2019: unresolved external symbol "void __cdecl cvCreateTestSamples(char const *,char const *,int,int,char const *,int,int,int,double,double,double,int,int,int)" (?cvCreateTestSamples##YAXPBD0HH0HHHNNNHHH#Z) referenced in function _main
vecToFiles.obj : error LNK2019: unresolved external symbol "void __cdecl cvCreateTrainingSamples(char const *,char const *,int,int,char const *,int,int,int,double,double,double,int,int,int)" (?cvCreateTrainingSamples##YAXPBD0HH0HHHNNNHHH#Z) referenced in function _main
vecToFiles\Debug\vecToFiles.exe : fatal error LNK1120: 4 unresolved externals
I think Im missing some .lib file, but I dont know which file.
Ill appreciate any help.
What extra lib files do you have? From googling it looks like it's compiled into a file called cvhaartraining.lib.
I don't want to compile dynamic libs, so this question was not useful.
I downloaded taglib and compiled it using:
cmake -DENABLE_STATIC=ON -DENABLE_STATIC_RUNTIME=ON -DWITH_MP4=ON -G "Visual Studio 10"
That generates the Visual Studio solutions and I can compile the "tag" project which produces tag.lib in taglib/Release.
The problem comes when I try to use the library in a test application - nothing much, just a simple test:
#include "stdafx.h"
#include "fileref.h"
int _tmain(int argc, _TCHAR* argv[])
{
TagLib::FileRef d("");
return 0;
}
I get the following Linker errors:
Error 1 error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall TagLib::FileRef::~FileRef(void)" (__imp_??1FileRef#TagLib##UAE#XZ) C:\...\taglib_test\taglib_test\taglib_test.obj taglib_test
Error 2 error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall TagLib::FileRef::FileRef(class TagLib::FileName,bool,enum TagLib::AudioProperties::ReadStyle)" (__imp_??0FileRef#TagLib##QAE#VFileName#1#_NW4ReadStyle#AudioProperties#1##Z) C:\...\taglib_test\taglib_test\taglib_test.obj taglib_test
Error 4 error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall TagLib::FileName::FileName(char const *)" (__imp_??0FileName#TagLib##QAE#PBD#Z) C:\...\taglib_test\taglib_test\taglib_test.obj taglib_test
Error 3 error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall TagLib::FileName::~FileName(void)" (__imp_??1FileName#TagLib##QAE#XZ) C:\...\taglib_test\taglib_test\taglib_test.obj taglib_test
Error 5 error LNK1120: 4 unresolved externals C:\...\taglib_test\Release\taglib_test.exe taglib_test
Can somebody please give me an idea as to what's going on here?
The following are the preprocessor defines in the tag project:
WIN32
_WINDOWS
NDEBUG
HAVE_CONFIG_H
_CRT_SECURE_NO_DEPRECATE
_CRT_NONSTDC_NO_DEPRECATE
TAGLIB_STATIC
CMAKE_INTDIR="Release"
For those who have had this problem:
I fixed it by defining TAGLIB_STATIC in the test project:
#include "stdafx.h"
//This should have been generated by the build system in taglib_config.h
//but was not.
#define TAGLIB_STATIC
#include "fileref.h"
int _tmain(int argc, _TCHAR* argv[])
{
TagLib::FileRef d("");
return 0;
}
I have a solution with multiple projects. I have a "main" project, which acts as a menu and from there, the user can access any of the other projects. On this main project, I get linker errors for every function called. How do I avoid these linker errors? I set the project dependencies already in the "Project Dependencies..." dialog.
Thanks
EDIT -- I did as suggested and added the output folder to the linker's additional directories. Now, however, I get a million errors as follows:
3>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: void __thiscall std::basic_ios >::setstate(int,bool)" (?setstate#?$basic_ios#DU?$char_traits#D#std###std##QAEXH_N#Z) already defined in panels.lib(panel_main.obj)
3>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: int __thiscall std::ios_base::width(int)" (?width#ios_base#std##QAEHH#Z) already defined in panels.lib(panel_main.obj)
3>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: int __thiscall std::basic_streambuf >::sputn(char const *,int)" (?sputn#?$basic_streambuf#DU?$char_traits#D#std###std##QAEHPBDH#Z) already defined in panels.lib(panel_main.obj)
3>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: static bool __cdecl std::char_traits::eq_int_type(int const &,int const &)" (?eq_int_type#?$char_traits#D#std##SA_NABH0#Z) already defined in panels.lib(panel_main.obj)
3>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: static int __cdecl std::char_traits::eof(void)" (?eof#?$char_traits#D#std##SAHXZ) already defined in panels.lib(panel_main.obj)
3>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: int __thiscall std::basic_streambuf >::sputc(char)" (?sputc#?$basic_streambuf#DU?$char_traits#D#std###std##QAEHD#Z) already defined in panels.lib(panel_main.obj)
3>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_streambuf > * __thiscall std::basic_ios >::rdbuf(void)const " (?rdbuf#?$basic_ios#DU?$char_traits#D#std###std##QBEPAV?$basic_streambuf#DU?$char_traits#D#std###2#XZ) already defined in panels.lib(panel_main.obj)
3>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: char __thiscall std::basic_ios >::fill(void)const " (?fill#?$basic_ios#DU?$char_traits#D#std###std##QBEDXZ) already defined in panels.lib(panel_main.obj)
3>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: int __thiscall std::ios_base::flags(void)const " (?flags#ios_base#std##QBEHXZ) already defined in panels.lib(panel_main.obj)
3>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: int __thiscall std::ios_base::width(void)const " (?width#ios_base#std##QBEHXZ) already defined in panels.lib(panel_main.obj)
3>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: static unsigned int __cdecl std::char_traits::length(char const *)" (?length#?$char_traits#D#std##SAIPBD#Z) already defined in panels.lib(panel_main.obj)
3>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_ostream > & __thiscall std::basic_ostream >::flush(void)" (?flush#?$basic_ostream#DU?$char_traits#D#std###std##QAEAAV12#XZ) already defined in panels.lib(panel_main.obj)
3>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_ostream > * __thiscall std::basic_ios >::tie(void)const " (?tie#?$basic_ios#DU?$char_traits#D#std###std##QBEPAV?$basic_ostream#DU?$char_traits#D#std###2#XZ) already defined in panels.lib(panel_main.obj)
3>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: bool __thiscall std::ios_base::good(void)const " (?good#ios_base#std##QBE_NXZ) already defined in panels.lib(panel_main.obj)
3>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: void __thiscall std::basic_ostream >::_Osfx(void)" (?_Osfx#?$basic_ostream#DU?$char_traits#D#std###std##QAEXXZ) already defined in panels.lib(panel_main.obj)
3>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: void __thiscall std::basic_streambuf >::_Lock(void)" (?_Lock#?$basic_streambuf#DU?$char_traits#D#std###std##QAEXXZ) already defined in panels.lib(panel_main.obj)
3>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: void __thiscall std::basic_streambuf >::_Unlock(void)" (?_Unlock#?$basic_streambuf#DU?$char_traits#D#std###std##QAEXXZ) already defined in panels.lib(panel_main.obj)
3>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::locale::facet * __thiscall std::locale::facet::_Decref(void)" (?_Decref#facet#locale#std##QAEPAV123#XZ) already defined in panels.lib(panel_main.obj)
3>libcpmtd.lib(ios.obj) : error LNK2005: "private: static void __cdecl std::ios_base::_Ios_base_dtor(class std::ios_base *)" (?_Ios_base_dtor#ios_base#std##CAXPAV12##Z) already defined in msvcprtd.lib(MSVCP90D.dll)
3>libcpmtd.lib(ios.obj) : error LNK2005: "public: static void __cdecl std::ios_base::_Addstd(class std::ios_base *)" (?_Addstd#ios_base#std##SAXPAV12##Z) already defined in msvcprtd.lib(MSVCP90D.dll)
3>libcpmtd.lib(locale0.obj) : error LNK2005: "void __cdecl _AtModuleExit(void (__cdecl*)(void))" (?_AtModuleExit##YAXP6AXXZ#Z) already defined in msvcprtd.lib(locale0_implib.obj)
3>libcpmtd.lib(locale0.obj) : error LNK2005: __Fac_tidy already defined in msvcprtd.lib(locale0_implib.obj)
3>libcpmtd.lib(locale0.obj) : error LNK2005: "private: static void __cdecl std::locale::facet::facet_Register(class std::locale::facet *)" (?facet_Register#facet#locale#std##CAXPAV123##Z) already defined in msvcprtd.lib(locale0_implib.obj)
3>libcpmtd.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Getgloballocale(void)" (?_Getgloballocale#locale#std##CAPAV_Locimp#12#XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
3>libcpmtd.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Init(void)" (?_Init#locale#std##CAPAV_Locimp#12#XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
3>libcpmtd.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_ctor(class std::_Locinfo *,class std::basic_string,class std::allocator > const &)" (?_Locinfo_ctor#_Locinfo#std##SAXPAV12#ABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##2##Z) already defined in msvcprtd.lib(MSVCP90D.dll)
3>libcpmtd.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_dtor(class std::_Locinfo *)" (?_Locinfo_dtor#_Locinfo#std##SAXPAV12##Z) already defined in msvcprtd.lib(MSVCP90D.dll)
3>libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit#std##QAE#H#Z) already defined in msvcprtd.lib(MSVCP90D.dll)
3>libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit#std##QAE#XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
It is difficult to answer without knowing all the details about your solution, but I will assume your "other" project are set up to produce a .lib file, and the main project then links all these lib files. If that is the case then a possible cause for the errors you are getting is that your projects link to different versions of the runtime library.
From Microsoft's documentation, "All modules passed to a given invocation of the linker must have been compiled with the same run-time library compiler option (/MD, /MT, /LD)."
Try to change all the projects to use the same version of the runtime library. In Visual Studio 2010, this is in the Project's Properties | Configuration Properties | C/C++ | Code Generation | Runtime Library. Choose either Multi-threaded Debug DLL or Multi-threaded Debug (for your debug configuration).
Without knowing any other detail about your solution it is hard to tell, however Rebuild All, might be helpful. This situation can sometimes occur when there are mixed object files for different architectures.
You might also want to consider using "References" instead of "Dependencies"
EDIT:
After what you have posted it seems that your linkage to standard libraries is inconsistent. Could it be that one of the project links standard libraries statically while others dynamically? (See project properties->linker) Or one to the release runtime, while others to debug? (though the last one should be possible, with caveats)
Are the functions in your other projects exported? If they aren't exported, then there is nothing to link to from the main exe, so that would cause the errors. See Exporting from a DLL Using __declspec(export) for more information.
The errors you are getting are 'error LNK2005' where a symbol in the library you are linking (msvcprtd.lib) has already been defined in another library (for example panels.lib). If you add panels.lib to the 'ignore specific library' field (in VS2008 Configuration Properties--> Linker--> Input -->Ignore specific libraries), the errors will stop.
I presume the linker errors you are getting are for "unresolved symbols"?
If using static libraries (i.e. .lib file), you will need to add the library to the linker input, so that at linkage time the symbols can be linked against. If you don't do this, you'll get an unresolved symbol:
Right-click on the project, and select Properties.
Select Configuration Properties->Linker->Input
Enter the library name (e.g. filename.lib) under Additional Dependencies.
I had a very similar issue to this which turned out to be because one of my libraries had the option 'Treat wchar_t as built-in type' set to a different value to the others. This setting is false by default on new projects. Changing them all to true fixed the problem.
Exactly, at least one of your projects is compiled with a different "Runtime Library" then the others. Maybe you added a new one using the default which is different. Check properties of your project(s) for equal value of "Configuration Properties" -> "C/C++" -> "Code Generation" -> "Runtime Library".
In my case, the problem was because I had kept the function prototypes, the class definitions and the function implementation and the class implementation in a single cpp file. Only when I shifted the declarations and prototypes to a separate header file did these errors disappear. Really weird!
In my case, I have two methods:
Project Properties -> C/C++ -> Code Generation -> Runtime Library. change it to MT.
Add your lack library to: Linker-> Input -> Additional Dependencies. If it doesn't work, try to add a full path instead of a library name.
For example: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\amd64\libvcruntime.lib;
That works for me.Answer this question for anyone needs help.