About Store Forum Documentation Contact



Post Reply 
Suggestion on compiler's options
Author Message
Roman Offline
Member

Post: #1
Suggestion on compiler's options
Hello!

Today I have got linker error again. I use only wstring class. The cause is that the flag "Ignore All Default Libraries" in linker is set to "Yes". I also cannot use standard runtime functions (e.g. _CrtSetDbgFlag). I incline to think that the main cause of this problem is a compiler flag for the engine compiling "Runtime Library = Multi-threaded (/MT)", which force compiler to include runtime functions to library.
And here is my suggestion. Can you include in build .lib with "Runtime Library = Multi-threaded DLL (/MD)", please?

Thanks
10-12-2009 03:16 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
Re: Suggestion on compiler's options
could you paste your linker error?

I suggest to use "Str" class over wstring, it's also Unicode (16bit per character)
10-12-2009 05:51 PM
Find all posts by this user Quote this message in a reply
Roman Offline
Member

Post: #3
Re: Suggestion on compiler's options
Of course,
after I have used wstring:

1>MainMenuState.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >::~basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >(void)" (__imp_??1?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@XZ​) referenced in function "public: __thiscall Client::MainMenuWindow::MainMenuWindow(void)" (??0MainMenuWindow@Client@@QAE@XZ)

1>BaseWindow.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >::~basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >(void)" (__imp_??1?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@XZ​)


used std::map (not all linker errors below):

1>GameState.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base_secure::~_Container_base_secure(void)" (__imp_??1_Container_base_secure@std@@QAE@XZ) referenced in function "protected: __thiscall std::_Container_base_aux_alloc_empty<class std::allocator<struct std::pair<int const ,int> > >::~_Container_base_aux_alloc_empty<class std::allocator<struct std::pair<int const ,int> > >(void)" (??1?$_Container_base_aux_alloc_empty@V?$allocator@U?$pair@$$CBHH@std@@@std@@@st​d@@IAE@XZ)

1>GameState.obj : error LNK2019: unresolved external symbol __imp___CrtDbgReportW referenced in function "public: bool __thiscall std::_Tree<class std::_Tmap_traits<int,int,struct std::less<int>,class std::allocator<struct std::pair<int const ,int> >,0> >::const_iterator::operator==(class std::_Tree<class std::_Tmap_traits<int,int,struct std::less<int>,class std::allocator<struct std::pair<int const ,int> >,0> >::const_iterator const &)const " (??8const_iterator@?$_Tree@V?$_Tmap_traits@HHU?$less@H@std@@V?$allocator@U?$pair​@$$CBHH@std@@@2@$0A@@std@@@std@@QBE_NABV012@@Z)

1>GameState.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base_secure::_Container_base_secure(void)" (__imp_??0_Container_base_secure@std@@QAE@XZ) referenced in function "protected: __thiscall std::_Container_base_aux_alloc_empty<class std::allocator<struct std::pair<int const ,int> > >::_Container_base_aux_alloc_empty<class std::allocator<struct std::pair<int const ,int> > >(class std::allocator<struct std::pair<int const ,int> >)" (??0?$_Container_base_aux_alloc_empty@V?$allocator@U?$pair@$$CBHH@std@@@std@@@st​d@@IAE@V?$allocator@U?$pair@$$CBHH@std@@@1@@Z)


used function _CrtSetDbgFlag(flag) for leak detection:

1>Main.obj : error LNK2019: unresolved external symbol __imp___CrtSetDbgFlag referenced in function "void __cdecl InitPre(void)" (?InitPre@@YAXXZ)

I can continue list smile And this all is clear, we have disabled all standard libraries. Specifically, it need MSVCRTD.lib which is conflicted with libcmt.lb.
I hope the decision of this problem, STL is very important for my project.

Thanks
10-13-2009 05:12 AM
Find all posts by this user Quote this message in a reply
Roman Offline
Member

Post: #4
Re: Suggestion on compiler's options
Hey, guys!
Indeed anybody doesn't use STL? Maybe you know appropriate decision. Could you share with me, please smile

Some hours later....

OMG I resolved this problem, but the methods, which I have used, must infuriate all qualified programmers smile
First, I made the mistake - compile code in Debug-mode only. As it turned out, in Release-mode linking had finished successfully.
Then I noticed that in Debug-mode is used Release runtime libraries (libcmt.lib and libcpmt.lib). I changed them on libcmtd.lib and libcpmtd.lib.
And on magically way large part of errors had disappeared. Only one is stayed: "unresolved external symbol __invalid_parameter_noinfo".
"The hacker's decision" was found in MSDN social network (<!-- m --><a class="postlink" href="http://social.msdn.microsoft.com/forums/en-US/vclanguage/thread/7234ea2b-0042-42ed-b4e2-5d8644dfb57d">http://social.msdn.microsoft.com/forums ... 8644dfb57d</a><!-- m -->).
The author offer to resolve this function in the application, because this function doesn't matter. smile
Hack may be disabled, if we'll get EsenthelEngine.lib linked with libcmtd.lib and libcpmtd.lib or with DLL-based libraries.

Thanks for attention.
10-14-2009 08:36 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
Re: Suggestion on compiler's options
I will check this soon, please wait smile
but I strongly suggest using engine native methods, it has better integration with other functions.

wstring -> Str
std::map -> Cache<..> (when using objects loaded from files, sorted by names)
_CrtSetDbgFlag(flag) for leak detection -> App.flags|=APP_MEM_LEAKS;

(but still I'll try to enable native STL support)
10-14-2009 01:50 PM
Find all posts by this user Quote this message in a reply
Post Reply