0

When working with an existing project, having made some modifications to some external libraries, I am encountering issues of the following kind when building a library dependent upon another dynamically-linked library:

error LNK2001: unresolved external symbol "public: virtual void * __cdecl Foo::`scalar deleting destructor'(unsigned int)

error LNK2001: unresolved external symbol "public: virtual void * __cdecl Foo::`vector deleting destructor'(unsigned int)

If I run dumpbin /symbols on the offending .obj file I can clearly see these symbols as UNDEF.

What is interesting to me is that there are no complaints of other undefined symbols, and the destructor for Foo is not referenced at all in the object file symbol dump. The main references to these synthesized functions that I can find on StackOverflow are from people who have not defined their destructor, however I can clearly see Foo::Foo being exported from the library where Foo is defined (by running dumpbin /exports on the .lib).

This brings me to the core of my question: When does Visual Studio (2015) choose to synthesize these functions, and when does it decide that they should be linked from another translation unit?

Community
  • 1
  • 1
Thomas Russell
  • 5,630
  • 3
  • 30
  • 64
  • Have you checked the [canonical answer](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix)? No guarantee that it helps but it exists for a reason... – Max Langhof Oct 11 '19 at 15:14
  • They are not synthesized functions. Seems that you declared Foo to have its own operator delete and operator delete[] but forgot to write them. – Hans Passant Oct 11 '19 at 15:26
  • I trust VS synthesizes those always when new Foo and/or new Foo[x] is somewhere in code. – Öö Tiib Oct 11 '19 at 15:32
  • @HansPassant `Foo` does not declare any user-defined `operator delete` or `operator delete[]`. Moreover, other libraries which use `Foo` (and indeed call `new Foo`/`delete Foo`) do not have any problem linking against the library containing Foo. – Thomas Russell Oct 11 '19 at 15:34
  • To the person who voted to close - I described my problem for background information. My question is not asking for "debugging help", I am simply asking when MSVC synthesizes these functions. :) – Thomas Russell Oct 11 '19 at 15:35

0 Answers0