I'm Getting A Linker Error Even Though I've Defined the Function In Question

Osman Zakir 121 Reputation points
2022-01-18T17:12:07.523+00:00

I have this exercise solution for a C++20 book I'm reading for which I have a linker error. Code Gist.

Linker error:

1>chapter11ex3.obj : error LNK2019: unresolved external symbol "void __cdecl words::sorting::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> > > > > &)" (?sort@sorting@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@@@Z::<!words.sorting>) referenced in function main
1>E:\programming\visual_studio_2019\Projects\beginningcpp20\chapter11ex3\x64\Debug\chapter11ex3.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "chapter11ex3.vcxproj" -- FAILED.

I have the function defined properly so why is this linker error here? Someone please help me out here. Thanks.

I haven't tried it with other IDEs and compilers yet, but could it be a problem with just VS? I'm using VS2022. There's also a notification in the "Output" on startup that says that IntelliSense support for C++20 Modules is experimental.

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,600 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Osman Zakir 121 Reputation points
    2022-01-19T17:14:20.127+00:00

    Yeah, thanks. It builds for me in VS2019 as well. So it really seems to be a problem with VS2022. I hope it gets addressed soon.

    I tried posting this as an answer, but for some reason it won't go through.

    0 comments No comments