0

I have a visual studio solution (generated from a Qt project, but I don't know that it's relevant) that has the general form:

Application.exe (depends on):
Library A (which depends on):
Library B.

I use the Intel MKL libraries throughout all of the libraries, and let the visual studio MKL plugin handle linking those to my projects. I had been building the libraries as static libs, which worked, but was giving me probably thousands of duplicate definition warnings:

1>mkl_intel_thread_dll.lib(mkl_intel_thread.dll) : warning LNK4006: __NULL_IMPORT_DESCRIPTOR already defined in mkl_intel_lp64_dll.lib(libimalloc.dll); second definition ignored
1>mkl_intel_thread_dll.lib(mkl_intel_thread.dll) : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
1>mkl_core_dll.lib(mkl_core.dll) : warning LNK4006: sdttrsb_4dfl already defined in mkl_intel_lp64_dll.lib(_sdttrsb_4dfl_lp64.obj); second definition ignored
1>mkl_core_dll.lib(mkl_core.dll) : warning LNK4006: sdttrfb_4dfl already defined in mkl_intel_lp64_dll.lib(_sdttrfb_4dfl_lp64.obj); second definition ignored
etc...

I would just ignore these warnings, but there are so many of them that it dramatically slows down the build process.

So, I changed the libraries to build as .dlls, thinking that it would get rid of the duplicate definition warnings (which it did), but it raised linker errors between my libraries which look like this:

2>metricsmodel.obj : error LNK2019: unresolved external symbol "public: class QSharedPointer<class QVector<double> > __cdecl SpectralImage::GetWaveNumbers(void)" (?GetWaveNumbers@SpectralImage@@QEAA?AV?$QSharedPointer@V?$QVector@N@@@@XZ) referenced in function "public: void __cdecl MetricsModel::RunMetrics(class MetricsRunConfig *)" (?RunMetrics@MetricsModel@@QEAAXPEAVMetricsRunConfig@@@Z)
2>metricsmodel.obj : error LNK2019: unresolved external symbol "public: __cdecl Hyperslab::Hyperslab(class QVector<int>,class QVector<int>,class QObject *)" (??0Hyperslab@@QEAA@V?$QVector@H@@0PEAVQObject@@@Z) referenced in function "public: void __cdecl MetricsModel::RunMetrics(class MetricsRunConfig *)" (?RunMetrics@MetricsModel@@QEAAXPEAVMetricsRunConfig@@@Z)
2>metricsmodel.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl Hyperslab::~Hyperslab(void)" (??1Hyperslab@@UEAA@XZ) referenced in function "private: class QVector<class QString> __cdecl MetricsModel::ComputeMetrics(class QVector<class QSharedPointer<class Metric> >,class HDFDataset *,class Hyperslab *)" (?ComputeMetrics@MetricsModel@@AEAA?AV?$QVector@VQString@@@@V?$QVector@V?$QSharedPointer@VMetric@@@@@@PEAVHDFDataset@@PEAVHyperslab@@@Z)

Where metricsmodel.obj is from Library A, and the unresolved symbols are in Library B.

Is there a step that I missed when trying to transition my build from static libs to .dlls? All the other dependencies are met, so I'm unsure why Library A cannot find the symbols defined in Library B at link.

alayers2
  • 510
  • 5
  • 16
  • So this question has been downvoted twice in the first 5 minutes that it is up. Can someone please explain what's not satisfactory or appropriate in this question instead of downvoting and running away? – alayers2 Aug 23 '16 at 14:46
  • I did not downvote however I don't think the question is answerable with only the information posted. I expect it to be closed as a duplicate of the popular undefined reference linker error question. http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix – drescherjm Aug 23 '16 at 14:49
  • 1
    Post some of the linker errors in full. – Steve Aug 23 '16 at 14:49
  • @Steve, thanks for the feedback, post is edited. – alayers2 Aug 23 '16 at 15:01

1 Answers1

0

Sorry, this is answered other places. When changing from a static lib to a dll I need to add _declspec instructions on all of the symbols that I want to share from a DLL.

alayers2
  • 510
  • 5
  • 16