Linking Error

Hi, I have created a new project(single document) and included the header file #include . It gives following error: ************************************************* Linking...

Creating library Debug/octest.lib and object Debug/octest.exp StdAfx.obj : error LNK2001: unresolved external symbol "public: static void * __cdecl Standard::MAllocate(int)" (?MAllocate@Standard@@SAPAXH@Z) StdAfx.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) void * * theFreeList" (__imp_?theFreeList@@3PAPAXA) StdAfx.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) int theFreeListSize" (__imp_?theFreeListSize@@3HA) StdAfx.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) unsigned int MMgt_Opt" (__imp_?MMgt_Opt@@3IA) StdAfx.obj : error LNK2001: unresolved external symbol "public: static void __cdecl Standard::MFree(void * &)" (?MFree@Standard@@SAXAAPAX@Z) StdAfx.obj : error LNK2001: unresolved external symbol "public: static void * __cdecl Standard::MReallocate(void * &,int)" (?MReallocate@Standard@@SAPAXAAPAXH@Z) StdAfx.obj : error LNK2001: unresolved external symbol "public: static void * __cdecl Standard::RReallocate(void * &,int,int)" (?RReallocate@Standard@@SAPAXAAPAXHH@Z) StdAfx.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall Standard_Storable::ShallowDump(class ostream &)const " (?ShallowDump@Standard_Storable@@UBEXAAVostream@@@Z) StdAfx.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall Standard_Storable::HashCode(int)const " (?HashCode@Standard_Storable@@UBEHH@Z) StdAfx.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall Standard_Storable::Delete(void)" (?Delete@Standard_Storable@@UAEXXZ) StdAfx.obj : error LNK2001: unresolved external symbol "public: void __thiscall Standard_Type::Print(class ostream &)const " (?Print@Standard_Type@@QBEXAAVostream@@@Z) StdAfx.obj : error LNK2001: unresolved external symbol "public: __thiscall AIS_DataMapOfIOStatus::AIS_DataMapOfIOStatus(int)" (??0AIS_DataMapOfIOStatus@@QAE@H@Z) StdAfx.obj : error LNK2001: unresolved external symbol "public: __thiscall AIS_DataMapOfILC::AIS_DataMapOfILC(int)" (??0AIS_DataMapOfILC@@QAE@H@Z) Debug/octest.exe : fatal error LNK1120: 13 unresolved externals Error executing link.exe.

octest.exe - 14 error(s), 0 warning(s) ************************************************ Am I missing any project settings or somethingelse? Expecting early reply, Regards Sonu Khan

Paolo Mosna's picture

I have a similar problem using MSVC 6.0:
error LNK2001: unresolved external symbol "public: virtual void __thiscall Standard_Storable::ShallowDump(class _STL::basic_ostream > &)const " (?ShallowDump@Standard_Storable@@UBEXAAV?$basic_ostr
eam@DV?$char_traits@D@_STL@@@_STL@@@Z)

I don't know if I'm missing some libraries (.lib) or what?

Could you help me?

Thanks.
Paolo

Lugi.C's picture

Hi,

you may not include the lib file, if you don't know which one is missing, here is a good trick:
your seach the XXX@@XXX?$XXX name in your lib directory of OCC in all *.dll file or *.lib file, the finding one your expected.

Best Regards.
Lugi.C

Paolo Mosna's picture

Thanks, that was a good idea.
I found that I don't have the symbol:
ShallowDump@Standard_Storable@@UBEXAAV?$basic_ostream@DV?$char_traits@D@_STL@@@_STL@@@Z

in any of the Opencascade libraries. Beside I have the symbol:

ShallowDump@Standard_Storable@@UBEXAAV?$ostream@DV?$char_traits@D@_STL@@@_STL@@@Z

where the "basic_ostream" is replaced with "ostraem".

There should be a problem with the strem library. I have seen that OC includes and if I compile the project, MSVC (Microsoft Visual Studio) throw an error, so I have installed the stlport version for the stl library and the compilation process is now OK but I still have the linking problems.
It should be a stl iostream library problem, but I don't have idea how to walk around to this problem.

Any help is welcome...
Paolo.

Paolo Mosna's picture

OK I solved the problem.
(1) do not use "using namespace std" anywhere in your code
(2) do not use the stlport version of the standard template library
(3) wherever an object of the stl library was used I prepose a std:: namespace

This solution allow the compilation of the OC library with the old version of the stl meanwhile the code that use the new version is compiled correctly.

Thanks.
Paolo.