PDA

View Full Version : Using from a DLL



Klaus M.
February 10, 2003, 14:49:11
I have some troubles using the classlib inside a non MFC-DLL.

1. The compiler gives me warnings like this:
d:\win\stline02\stgrabif01\include1394\videoformat item.h(132) : warning C4251: 'm_VideoFormatString' : class 'std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' needs to have dll-interface to be used by clients of cla
ss 'DShowLib::VideoFormatItem'

2. If I use any of the following functions:
DShowLib::Grabber::tVidNrmListPtr pVidNrmList = m_pGrabber->getAvailableVideoNorms();

I get an error message "Debug assertion failed in dbgheap.c" and I cannot continue.
Yes I use the debug libraries.
If I use: m_pGrabber->openDev( "Video to 1394 Converter" ) instead of
m_pGrabber->openDev( (*pVidCapDevList)[0] )
I get no errors.

Klaus

Stefan Geissler
February 19, 2003, 14:52:11
Klaus,

You need to specify "_DLL" in the preprocessor settings. Also your DLL must be a debug multithreaded DLL.

ray@frontier
December 20, 2006, 03:41:39
Hello, I encounter similiar problem as Klaus M stated, after following the instruction of specifying "_DLL" in the preprocessor settings and choosing debug multithreaded DLL mode, the warning has disappeared, but it then results in link error as following:

GrabberIC warning LNK4098: defaultlib 'msvcrtd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
GrabberIC error LNK2005: ___xc_a already defined in msvcrtd.lib(cinitexe.obj)
GrabberIC error LNK2005: ___xc_z already defined in msvcrtd.lib(cinitexe.obj)
GrabberIC error LNK2005: ___xi_a already defined in msvcrtd.lib(cinitexe.obj)
GrabberIC error LNK2005: ___xi_z already defined in msvcrtd.lib(cinitexe.obj)
GrabberIC error LNK2005: __CrtCheckMemory already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2005: __CrtDoForAllClientObjects already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2005: __CrtDumpMemoryLeaks already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2005: __CrtIsMemoryBlock already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2005: __CrtMemCheckpoint already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2005: __CrtMemDifference already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2005: __CrtMemDumpAllObjectsSince already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2005: __CrtMemDumpStatistics already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2005: __CrtReportBlockType already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2005: __CrtSetAllocHook already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2005: __CrtSetBreakAlloc already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2005: __CrtSetDbgFlag already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2005: __CrtSetDumpClient already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2005: __expand already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2005: __free_dbg already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2005: __malloc_dbg already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2005: __msize already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2005: _atoi already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2005: _calloc already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2005: _free already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2005: _malloc already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2005: _realloc already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup
GrabberIC fatal error LNK1120: 1 unresolved externals
GrabberIC warning LNK4006: ___CppXcptFilter already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4006: ___doserrno already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4006: ___xc_a already defined in msvcrtd.lib(cinitexe.obj); second definition ignored
GrabberIC warning LNK4006: ___xc_z already defined in msvcrtd.lib(cinitexe.obj); second definition ignored
GrabberIC warning LNK4006: ___xi_a already defined in msvcrtd.lib(cinitexe.obj); second definition ignored
GrabberIC warning LNK4006: ___xi_z already defined in msvcrtd.lib(cinitexe.obj); second definition ignored
GrabberIC warning LNK4006: __CrtCheckMemory already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4006: __CrtDoForAllClientObjects already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4006: __CrtDumpMemoryLeaks already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4006: __CrtIsMemoryBlock already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4006: __CrtMemCheckpoint already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4006: __CrtMemDifference already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4006: __CrtMemDumpAllObjectsSince already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4006: __CrtMemDumpStatistics already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4006: __CrtReportBlockType already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4006: __CrtSetAllocHook already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4006: __CrtSetBreakAlloc already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4006: __CrtSetDbgFlag already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4006: __CrtSetDumpClient already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4006: __expand already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4006: __free_dbg already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4006: __malloc_dbg already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4006: __msize already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4006: _atoi already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
Creating library .\TestGrabberIC\GrabberIC.lib and object .\TestGrabberIC\GrabberIC.exp
GrabberIC warning LNK4006: _calloc already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4006: _free already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4006: _malloc already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4006: _realloc already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
GrabberIC warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
GrabberIC error LNK2005: ___CppXcptFilter already defined in msvcrtd.lib(MSVCR71D.dll)
GrabberIC error LNK2005: ___doserrno already defined in msvcrtd.lib(MSVCR71D.dll)

Stefan Geissler
December 20, 2006, 09:14:53
Hi,

This error messages may occur, because the project is not linked as Multithreaded DLL.

ray@frontier
January 9, 2007, 08:32:31
As seen from MSDN,the C-run time configuration should be like that:

1) Debug, shared library MFC applications - "Debug Multithreaded Dll."
2) Release, shared library MFC applications - "Multithread Dll."
3) Debug, static library MFC applications - "Debug Multithreaded."
4) Release, static library MFC applications - "Multithreaded."

If I follow your instruction, using above no.1 configuration, the warning really disappear as expected, however, I would like to ask if there is a way to avoid those warning in "static" library MFC applications?

Stefan Geissler
January 9, 2007, 15:09:41
Ray,

I am very sorry, but I do not an answer to your question.

ray@frontier
March 19, 2007, 09:47:30
Never mind.

I can simply disable the warning by using "#pragma warning(disable: XXXX)" method

Stefan Geissler
March 19, 2007, 10:13:18
Hi Ray,

I just saw, that there is a "have" missing in my post. Please excuse this!

I suppose you can use the pragma thing. I guess, the DLL that encapsulates the IC class library is built with non static use of the C++ runtime libraries. In this case, the warnings should be away too. You may have a look, whether there are some of these runtime libraries are referenced in your linker settings.