MFC Link Error - Help/Advice - Emergency $$ will bonus $$ for fast help
$100-500 USD
Closed
Posted over 15 years ago
$100-500 USD
Paid on delivery
We have a statically linkable client library that utilizes MFC. We delivered this library to one of our customers. Our customer requires in their application to over load new and delete operators. For example, see below:
void* operator new( size_t size ) { /* some alloc code */ }
void* operator new[](size_t size) { /* some alloc code */ }
void operator delete( void *ptr ) { /* some dealloc code */ }
void operator delete[](void* ptr) { /* some dealloc code */ }
Because it seems MFC also does this, there seems to be a conflict with the new/delete operators for MFC and the new/delete operators that are defined in the customers application. When the customer builds it yields the following linker errors:
[login to view URL](afxmem obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2YAPAXIZ) already defined in [login to view URL]
[login to view URL](afxmem o bj) : error LNK2005: "void __cdecl operator delete(void *)" (??3YAXPAXZ) already defined in [login to view URL]
[login to view URL](afxmem ob j) : error LNK2005: "void * __cdecl operator new[](unsigned int)" (??_UYAPAXIZ) already defined in [login to view URL]
[login to view URL](afxmem obj ) : error LNK2005: "void __cdecl operator delete[](void *)" (??_VYAXPAXZ) already defined in [login to view URL]
We need some advice fast. What can we do to change in our lib code (we cannot remove MFC) to avoid this problem for our customers? We considered building the lib as a dll and telling them to use it that way but it is not ideal. Is there anything we can do with namespaces to avoid this conflict?
Fast response will get bonus!
## Deliverables
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.
2) Deliverables must be in ready-to-run condition, as follows (depending on the nature of the deliverables):
a) For web sites or other server-side deliverables intended to only ever exist in one place in the Buyer's environment--Deliverables must be installed by the Seller in ready-to-run condition in the Buyer's environment.
b) For all others including desktop software or software the buyer intends to distribute: A software installation package that will install the software in ready-to-run condition on the platform(s) specified in this bid request.
3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement).
## Platform
Visual Studio 2005 C/C++