error LNK2019

How do i interpret an error like this:

1>------ Build started: Project: Project2, Configuration: Debug Win32 ------
1>main.cpp
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall LinkedBag<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::LinkedBag<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(void)" (??0?$LinkedBag@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@QAE@XZ) referenced in function _main
1>C:\Users\James\source\repos\Project2\Debug\Project2.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "Project2.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


it seems to be a linking error to a function possibly? but is their a way to tell what function it can't link to from this output?
public: __thiscall LinkedBag<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::LinkedBag<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(void)

is the function in question, which is
LinkedBag<std::string>::LinkedBag<std::string>(void).

In other words, the default constructor for LinkedBag<std::string>.

EDIT: Changed T to std::string in case there's some template specialization in your code.

-Albatross
Last edited on
Hello JamesHelp,

I have come to look at this error message:

1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall LinkedBag<class ...

as:

When the file name ends in ".obj" The line number is usually always 1. The part in bold is what you are looking for. The rest is the compiler's way of defining the return type, if any, and the parameters, if any. All that part for the parameters is sometimes important, but usually not the problem.

Most times I find that there is a spelling problem. This could start in the class definition or at the function definition.

Another possibility is that you forward declared the function in the class, but did not define the function.

Without seeing the code it is hard to say where the problem is.

Andy

Edit:
Last edited on
Topic archived. No new replies allowed.