Click to See Complete Forum and Search --> : Compile error C4251...help


bond001
July 25th, 2003, 02:57 PM
I have an application which uses three MFC extenion dll's.This is workig fine if I dynamically link to MFC for all the dll's and the application.

I wanted to do static link to MFC as one of the Dll's using ADO and I dont want users to install ADO or MFC dlls on their machine.

I have careated a new configuration(same as release)for all the applications and all dll's build fine but I got compilation errors C4251 when I build the application.

I appreciate if some one help me in this.Any ideas or any hints will help me.

The following are the build settings for the projects.

DatebaseDLL
===========
/O2 /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "_AFXEXT" /D "_WINDLL" /D "_MBCS" /FD /EHsc /MD /GS /Zc:wchar_t /Yu"stdafx.h" /Fp"Release Static Link/BPDatabaseAccess.pch" /Fo"Release Static Link/" /Fd"Release Static Link/vc70.pdb" /W3 /nologo /c /Wp64 /Zi /TP

UtilitiesDll
========
/O2 /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "_AFXEXT" /D "_WINDLL" /D "_MBCS" /FD /EHsc /MD /GS /Zc:wchar_t /Yu"stdafx.h" /Fp"Release Static Link/BioUtilities.pch" /Fo"Release Static Link/" /Fd"Release Static Link/vc70.pdb" /W4 /nologo /c /Wp64 /Zi /TP

FunctionsDLL
=============
/O2 /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "_AFXEXT" /D "_WINDLL" /D "_MBCS" /FD /EHsc /MD /GS /Zc:wchar_t /GR /Yu"stdafx.h" /Fp"Release Static Link/BPMValidation40.pch" /Fo"Release Static Link/" /Fd"Release Static Link/vc70.pdb" /W3 /nologo /c /Wp64 /Zi /TP

Application
======
/O2 /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "_MBCS" /FD /EHsc /MD /GS /Zc:wchar_t /GR /Yu"stdafx.h" /Fp"Release Static Link/ValidationKitUtility.pch" /Fo"Release Static Link/" /Fd"Release Static Link/vc70.pdb" /W3 /nologo /c /Wp64 /Zi /TP


Thanks for your time

IUNKWN
July 25th, 2003, 04:01 PM
Post the compiler error string. I looked in MSDN and it says C4251 is a warning not a error.

Compiler Warning (level 1) C4251
'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'

A base class or structure must be declared with the __declspec(dllexport) keyword for a function in a derived class to be exported.

which is self explanatory.

bond001
July 25th, 2003, 04:57 PM
Thanks for reply.

I am also getting linker errors.

ActaullY these warnings and errors does not occur if I specify "dynamica;;y link to MFC" for the application.

I get these errors and warnings only if I specify "statically link to MFC"



anyway the warning looks like

warning C4251: 'CControlNumberData::m_cstrControlNumber' : class 'ATL::CStringT<BaseType,StringTraits>' needs to have dll-interface to be used by clients of class 'CControlNumberData'
with
[
BaseType=char,
StringTraits=StrTraitMFC<char>
]

IUNKWN
July 26th, 2003, 10:35 AM
I think you are using VC7 (.Net). I am sorry. I am not familiar with the CStringT class. May be somebody else will be able to help you.

bond001
July 28th, 2003, 12:52 PM
Reposting....

One more question:

Is this conceptually possible to have three MFC extension dlls ,which are linked statically and used by an exe which is also linked statically?

Thanks

Andreas Masur
July 28th, 2003, 01:09 PM
[Moved thread]