As i am pretty much out of ideas and the google results by now have reached the point where they hit ~10 and less, i now turn here in hope of seeing the answer or at least a clue that leads me to the actual solution.
I am creating a project that can be distributed as executable, non-static library and static library. I want to use the library in a WPF project (C#) which is why i created a simple CLR wrapper.
It all worked very well up until the most recent change introduced into the base-library. Now, i get linkage errors (5 in total) on all calls to the "main" class in the library project:
1>wrapper.obj : error LNK2028: unresolved token (0A0016EB) "public: class std::vector<struct sqf::diagnostics::stackdump,class std::allocator<struct sqf::diagnostics::stackdump> > __thiscall sqf::vmstack::dump_callstack_diff(class std::shared_ptr<class sqf::callstack>)" (?dump_callstack_diff@vmstack@sqf@@$$FQAE?AV?$vector@Ustackdump@diagnostics@sqf@@V?$allocator@Ustackdump@diagnostics@sqf@@@std@@@std@@V?$shared_ptr@Vcallstack@sqf@@@4@@Z) referenced in function "public: class std::vector<struct sqf::diagnostics::stackdump,class std::allocator<struct sqf::diagnostics::stackdump> > __thiscall SqfVm::wrapper::get_stackdump(void)" (?get_stackdump@wrapper@SqfVm@@$$FQAE?AV?$vector@Ustackdump@diagnostics@sqf@@V?$allocator@Ustackdump@diagnostics@sqf@@@std@@@std@@XZ)
1>wrapper.obj : error LNK2028: unresolved token (0A0016F5) "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall sqf::virtualmachine::preprocess(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,bool &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?preprocess@virtualmachine@sqf@@$$FQAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V34@AA_N0@Z) referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall SqfVm::wrapper::preprocess(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,bool &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?preprocess@wrapper@SqfVm@@$$FQAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V34@AA_N0@Z)
1>wrapper.obj : error LNK2028: unresolved token (0A0016F6) "public: struct sqf::parse::astnode __thiscall sqf::virtualmachine::parse_sqf_cst(class std::basic_string_view<char,struct std::char_traits<char> >,bool &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?parse_sqf_cst@virtualmachine@sqf@@$$FQAE?AUastnode@parse@2@V?$basic_string_view@DU?$char_traits@D@std@@@std@@AA_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@6@@Z) referenced in function "public: struct sqf::parse::astnode __thiscall sqf::virtualmachine::parse_sqf_cst(class std::basic_string_view<char,struct std::char_traits<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?parse_sqf_cst@virtualmachine@sqf@@$$FQAE?AUastnode@parse@2@V?$basic_string_view@DU?$char_traits@D@std@@@std@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@6@@Z)
1>wrapper.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall sqf::virtualmachine::preprocess(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,bool &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?preprocess@virtualmachine@sqf@@$$FQAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V34@AA_N0@Z) referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall SqfVm::wrapper::preprocess(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,bool &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?preprocess@wrapper@SqfVm@@$$FQAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V34@AA_N0@Z)
1>wrapper.obj : error LNK2019: unresolved external symbol "public: struct sqf::parse::astnode __thiscall sqf::virtualmachine::parse_sqf_cst(class std::basic_string_view<char,struct std::char_traits<char> >,bool &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?parse_sqf_cst@virtualmachine@sqf@@$$FQAE?AUastnode@parse@2@V?$basic_string_view@DU?$char_traits@D@std@@@std@@AA_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@6@@Z) referenced in function "public: struct sqf::parse::astnode __thiscall sqf::virtualmachine::parse_sqf_cst(class std::basic_string_view<char,struct std::char_traits<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?parse_sqf_cst@virtualmachine@sqf@@$$FQAE?AUastnode@parse@2@V?$basic_string_view@DU?$char_traits@D@std@@@std@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@6@@Z)
1>wrapper.obj : error LNK2019: unresolved external symbol "public: class std::vector<struct sqf::diagnostics::stackdump,class std::allocator<struct sqf::diagnostics::stackdump> > __thiscall sqf::vmstack::dump_callstack_diff(class std::shared_ptr<class sqf::callstack>)" (?dump_callstack_diff@vmstack@sqf@@$$FQAE?AV?$vector@Ustackdump@diagnostics@sqf@@V?$allocator@Ustackdump@diagnostics@sqf@@@std@@@std@@V?$shared_ptr@Vcallstack@sqf@@@4@@Z) referenced in function "public: class std::vector<struct sqf::diagnostics::stackdump,class std::allocator<struct sqf::diagnostics::stackdump> > __thiscall SqfVm::wrapper::get_stackdump(void)" (?get_stackdump@wrapper@SqfVm@@$$FQAE?AV?$vector@Ustackdump@diagnostics@sqf@@V?$allocator@Ustackdump@diagnostics@sqf@@@std@@@std@@XZ)
1>wrapper.obj : error LNK2019: unresolved external symbol "public: __thiscall sqf::virtualmachine::virtualmachine(class Logger &,unsigned __int64)" (??0virtualmachine@sqf@@QAE@AAVLogger@@_K@Z) referenced in function "public: __thiscall sqf::virtualmachine::virtualmachine(class Logger &)" (??0virtualmachine@sqf@@QAE@AAVLogger@@@Z)
1>D:\Git\SQFvm\clrBridge\Release\clrBridge.dll : fatal error LNK1120: 7 unresolved externals
The projects, can both be found here:
Was able to get rid of the LNK2028 issues by adding another separation layer (wrapper.cpp & wrapper.h) and then putting a #pragma unmanaged
at the top of the cpp file.
Only the LNK2019 issues are left now
For those users who may find this question in the future, here is what helped me:
#pragma managed
to the an unmanaged wrapper for the actual class (got rid of the LNK2028)One of the following commits:
Hope this helps you.