Linker Errors About Non-Existent Functions?

Osman Zakir 101 Reputation points
2022-01-21T12:31:44.403+00:00

I have linker errors about functions don't even exist. I have no idea what's going on here. Code is in this GitHub repo.

I have these linker errors:

1>sort.ixx.obj : error LNK2019: unresolved external symbol "void __cdecl words::swap(class std::vector<class std::shared_ptr<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<class std::shared_ptr<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > &,unsigned __int64,unsigned __int64)" (?swap@Godherald"Words".CosmicTraveler @@YAXAEAV?$vector@V?$shared_ptr@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@V?$allocator@V?$shared_ptr@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@@2@@std@@_K1@Z::<!words>) referenced in function "void __cdecl words::sort(class std::vector<class std::shared_ptr<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<class std::shared_ptr<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > &,unsigned __int64,unsigned __int64)" (?sort@Godherald"Words".CosmicTraveler @@YAXAEAV?$vector@V?$shared_ptr@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@V?$allocator@V?$shared_ptr@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@@2@@std@@_K1@Z::<!words>)
1>utils.ixx.obj : error LNK2019: unresolved external symbol "unsigned __int64 __cdecl words::max_word_length(class std::vector<class std::shared_ptr<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<class std::shared_ptr<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > const &)" (?max_word_length@Godherald"Words".CosmicTraveler @@YA_KAEBV?$vector@V?$shared_ptr@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@V?$allocator@V?$shared_ptr@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@@2@@std@@@Z::<!words>) referenced in function "void __cdecl words::show_words(class std::vector<class std::shared_ptr<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<class std::shared_ptr<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > const &)" (?show_words@Godherald"Words".CosmicTraveler @@YAXAEBV?$vector@V?$shared_ptr@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@V?$allocator@V?$shared_ptr@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@@2@@std@@@Z::<!words>)
1>E:\programming\visual_studio_2019\Projects\beginningcpp20\chapter11ex5\x64\Debug\chapter11ex5.exe : fatal error LNK1120: 2 unresolved externals

I created an empty project and added the code to it. Would someone please help me with these errors? Thanks.

Edit for clarification and some more info: I'm using VS Community 2022.

And the functions words::max_word_length and words::swap weren't declared anywhere, since the functions I declared with those names are actually declared outside the words namespace rather than inside. The stupid thing is trying to look for definitions of functions that aren't even declared anywhere, hence me saying I have linker errors about functions that don't exist. I hope that clears things up.

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,519 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Minxin Yu 9,866 Reputation points Microsoft Vendor
    2022-01-24T02:08:03.117+00:00

    Hi, @Osman Zakir

    internals.cpp add module words:sort; in the first line.

    Best regards,

    Minxin Yu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.