0

I have a static C++ library. The code in the library uses STL containers internally. I want to link this library to a dynamic library. During the build I am getting errors:

error LNK2019: unresolved external symbol

related to objects (containers) from STL. I know that there are problems when exporting STL containers from the DLL; however, my library which contains STL is static, so no containers are exported.

Is it possible to link a static library with a dynamic library, if the static library contains STL containers?

Acorn
  • 24,970
  • 5
  • 40
  • 69
query
  • 329
  • 7
  • 18
  • ***Is it possible to link a static library with a dynamic library, if the static library contains STL containers?*** Yes, I have done that. Nothing special needed to make it work. – drescherjm Aug 11 '20 at 19:50
  • 1
    "*however, my library which contains STL is static, so no containers are exported.*" Linking statically does not mean symbols or "containers" aren't exported. Please clarify. – Acorn Aug 11 '20 at 19:55
  • 2
    Please add the full text of the error message to your question. – Paul Sanders Aug 11 '20 at 19:55
  • I assumed the OP meant that STL was not used in the public dll interface. – drescherjm Aug 11 '20 at 20:00
  • @drescherjm: that's, correct – query Aug 11 '20 at 20:03
  • 1
    Your unresolved external symbol error has absolutely nothing to do with potential problems of having STL (whatever it is) here or there. These problems, when they exist, do not manifest themselves as unresolved external symbols. – n. m. could be an AI Aug 11 '20 at 20:25
  • Presumably you've selected the static msvc runtime in your static library? That doesn't link in the runtime library symbols you need to do that when building your dll by selecting the static runtime there as well. You can't mix different runtimes within a single dll – Alan Birtles Aug 11 '20 at 21:03
  • @AlanBirtles: problem is with the Runtime Library. The Runtime library was Multi-threaded Debug DLL instead of Multi-threaded Debug. Thanks. – query Aug 11 '20 at 23:14
  • I am glad you have got your solution. I would appreciate it if you could write your solution as an answer and mark it. Because this will be beneficial to other community and help others. – Barrnet Chou Aug 12 '20 at 05:04

0 Answers0