/MD & _AFXDLL build problem

/MD & _AFXDLL build problem

Hello, I'm trying to build Win32 MFC application with IADP integration. I have linker errors which are similar with what was discussed, but different. Here they are: 1>Linking... 1>adpcored.lib(ADPXmlWriter.obj) : error LNK2005: "public: __thiscall std::vector,class std::allocator >,class std::allocator,class std::allocator > > >::vector,class std::allocator >,class std::allocator,class std::allocator > > >(void)" (??0?$vector@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@V?$allocator@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@2@@std@@QAE@XZ) already defined in dataengine.lib(DataEngine.dll) 1>adpcored.lib(ADPXmlWriter.obj) : error LNK2005: "public: __thiscall std::vector,class std::allocator >,class std::allocator,class std::allocator > > >::~vector,class std::allocator >,class std::allocator,class std::allocator > > >(void)" (??1?$vector@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@V?$allocator@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@2@@std@@QAE@XZ) already defined in dataengine.lib(DataEngine.dll) etc. I have application compiled with the following options: /Od /I "." /I "..\include" /I "..\CJ60Lib\Include" /I "..\..\Lang\UI\Turboorg" /I ".\Report" /I ".\Grid\BoxItem" /I ".\Grid\ThumbNailView" /I ".\StandardToolbar" /I ".\Grid" /I ".\ShapeProp" /I ".\ChartWizard" /I "..\XMLBuilder\Source" /I "..\Imports" /I "..\DataEngine" /I "..\DrawMe" /I "..\Utility" /I ".\FolderTabs" /I ".\PublishWizard" /I ".\ItemBoxCtrl" /I "..\DocumentSupport" /I "..\CryptoPP" /I "..\UpdateChecker" /I "..\AdoDbConnector" /I "..\IADP\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "UNICODE" /D "INTEL_ATOM" /D "_VC80_UPGRADE=0x0710" /D "_UNICODE" /D "_AFXDLL" /Gm /EHsc /MD /Yu"StdAfx.h" /Fp"D:\Work\VC.NET\OrgChart\5.01\Project\temp (Intel-Atom(Debug))\OCP\OCP.pch" /Fo"D:\Work\VC.NET\OrgChart\5.01\Project\temp (Intel-Atom(Debug))\OCP\\" /Fd"D:\Work\VC.NET\OrgChart\5.01\Project\temp (Intel-Atom(Debug))\OCP\vc90.pdb" /W3 /nologo /c /Zi /TP /wd4786 /wd4503 /wd4018 /wd4244 /wd4355 /wd4800 /wd4101 /wd4250 /errorReport:prompt Linker: /OUT:"D:\Work\VC.NET\OrgChart\5.01\Project\bin (Intel-Atom(Debug))\\OCP.exe" /INCREMENTAL /NOLOGO /LIBPATH:"D:\Work\VC.NET\OrgChart\5.01\Project\bin (Intel-Atom(Debug))" /LIBPATH:"../IADP/lib" /MANIFEST /MANIFESTFILE:"D:\Work\VC.NET\OrgChart\5.01\Project\temp (Intel-Atom(Debug))\OCP\OCP.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"D:\Work\VC.NET\OrgChart\5.01\Project\bin (Intel-Atom(Debug))\OCP.pdb" /SUBSYSTEM:WINDOWS /ENTRY:"wWinMainCRTStartup" /DYNAMICBASE:NO /MACHINE:X86 /ERRORREPORT:PROMPT gdiplus.lib ActiveDS.lib Adsiid.lib shlwapi.lib wininet.lib adpcored.lib adpcppfd.lib psapi.lib "..\bin (intel-atom(debug))\cj60lib.lib" "..\bin (intel-atom(debug))\drawme.lib" "..\bin (intel-atom(debug))\pdfbuilder.lib" "..\bin (intel-atom(debug))\documentsupport.lib" "..\bin (intel-atom(debug))\updatechecker.lib" "..\bin (intel-atom(debug))\xmlbuilder.lib" "..\bin (intel-atom(debug))\utility.lib" "..\bin (intel-atom(debug))\dataengine.lib" Change to /MTd does not work due to _AFXDLL & _MT definition conflict DataEngine.dll which is mentioned in error is extendion DLL with the follownig options /Od /I "." /I "..\..\Lang\UI\DataEngine" /I "..\Include" /I "..\Imports" /I "..\XMLBuilder\Source" /I "..\Utility" /I "..\AdoDbConnector" /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "_AFXEXT" /D "DATAENGINE_EXPORTS" /D "_VC80_UPGRADE=0x0710" /D "_WINDLL" /D "_AFXDLL" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Yu"stdafx.h" /Fp"D:\Work\VC.NET\OrgChart\5.01\Project\temp (Intel-Atom(Debug))\DataEngine\DataEngine.pch" /Fo"D:\Work\VC.NET\OrgChart\5.01\Project\temp (Intel-Atom(Debug))\DataEngine\\" /Fd"D:\Work\VC.NET\OrgChart\5.01\Project\temp (Intel-Atom(Debug))\DataEngine\vc90.pdb" /W3 /nologo /c /Wp64 /Zi /TP /errorReport:prompt Please help. Thanks!
12 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Yury,

You should be able to solve this with a #ifndef block or #pragma once.

Examples:

#ifndef:

http://www.cplusplus.com/forum/beginner/7877/

#pragma once:

http://en.wikipedia.org/wiki/Pragma_once

Please let me know if you have any further issues.

Sorry, what I should place under ifndef?

Hello All,

I inadvertently deleted two posts under this one while deleting a duplicate. I believe one was a 2nd response from Brian and the other was probably another response from Yury. I cannot recover them. My apologies to all. Please repost if possible.

Regards

Hal G.

Technical Support Team
Intel® Atom™ Developer Program
Intel AppUp(SM) Center

Not a problem, Hal. I still can't realize the origin of my issue.

Brian, I understand what is the conditional compilation and how to use it.
But as far as I see, issue is that some STL portion is defined in adpcored.lib(ADPXmlWriter.obj)

and have duplicate in DLL which is used in my project.
Issue happens when linking, not when compiling.
8>Linking...
8>adpcored.lib(ADPXmlWriter.obj) : error LNK2005: "public: __thiscall std::vector,class std::allocator >,class std::allocator,class std::allocator > > >::vector,class std::allocator >,class std::allocator,class std::allocator > > >(void)" (??0?$vector@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@V?$allocator@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@2@@std@@QAE@XZ) already defined in dataengine.lib(DataEngine.dll)

Project was compiling/linking fine before I added the Atom's libs.
OCP.EXE - executable
DataEngine.DLL - MFC Extension DLL
...
Some other DLLs as MFC Extension DLLs

Please advice.

Regards,

PS. Can I simply use a bootstraper EXE which'd linked to Atom's libs and launches my EXE?

Yury,

I do not have all of your files to look at, however it seems to me one of your resources are statically linking to the CRT Runtime causing your application to contain two conflicting versions.

I would suggest that you review your other libraries to ensure they are using dynamically linking to the CRT Runtime, match your /MD flag

This link from MSDN described the /MD and /MT flags in detail:

http://msdn.microsoft.com/en-us/library/2kzt1wy3%28VS.80%29.aspx

This link describes the troubles and solutions to running two versions of the CRT Runtime in one assembly. The part about using the /nodefaultlib flag may apply to your case as well:

http://www.mail-archive.com/vim-dev@vim.org/msg04132.html

Please let me know if you have any further problem.

Nope... that's what I've checked first.
Everywhere is /MDd ( trying assemble debug first )

May be I can send you the vcproj(s)/sln for review?

Thanks for helping me.

Have you tried implementing /nodefaultlib?

If this is still an issue by tonight (EST) I would be happy to review those files for you.

well, if /Nodefaultlib used, I have plenty of unresolved externals.

What I should add instead?
libcd.lib, libcmtd.lib msvcrtd.lib

Yury,

Try libcmtd.lib for debug, libcmt.lib for release. If you get stuck on what library a dependency is related to a quick google of that error item will usually steer you in the correct direction. Please let me know how this turns out, happy to continue working on this one with you.

Hello Brian,

Still can't resolve. I tried to :
1. Link with /Nodefaultlib ( I used Verbose:lib option to determine the necessary libs )
2. Tried to compile/link with _STATIC_CPPLIB defined ( this would link with the static multithread Standard C++ Library (libcpmt.lib) instead of the dynamic version (msvcprt.lib) while still dynamically linking to the main CRT via msvcrt.lib.

I guess that issue is in the MFC Extension DLLs we use in the project. For example: in the DataEngine.dll we export some classes for use in exe, which contain some string ( wstring ) types like: _declspec(_dllexport) class A { public: wstring memberFunction(); }
This cause conflict, as dataengine.dll is linked dynamically, but adpcored.lib is statically linked.

When I try to link with the libcmtd.lib, i'm getting the errors on each file.... it conflicts with the adpcored as it uses msvcrt.dll and msvcprt.dll Standard C++ Library
So, Can I have dynamic versions ( DLLs) of your library? Is it possible?

If no, what else should I provide for you to resolve the issue?

Regards.
Yury

Yury,

There are several discussions regarding static versus dynamic linking here in the forums. Having you tried linking dynamically (MFC)?

This link may help as well:

http://appdeveloper.intel.com/en-us/node/1052#comment-2606

Login to leave a comment.