CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: mfc and stl

  1. #1
    Join Date
    Jul 1999
    Posts
    1

    mfc and stl

    I have a Windows non-gui mfc program I need to port to Unix. I want to maintain a common source. I can't use MainWin or similar tools. I'm starting by changing the mfc containers to new classes that have different names, and implementing them using stl. I'll handle the other mfc classes later. I'm building now on NT, and will switch to Unix later. When I link I get:

    nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in libcpmtd.lib(delop.obj)
    Debug/xxx.exe : fatal error LNK1169: one or more multiply defined symbols found



    Now, libcpmtd.lib is multi-threaded, debug, static link version of the Standard C++ library, and nafxcwd.lib is the ANSI debug version of the mfc library. I need BOTH of these. So, is the problem that I just can't use stl and mfc together? I haven't seen any statements to that effect. Or am I doing something wrong?

    Any thoughts would be appreciated.


  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: mfc and stl

    I remember getting these errors if I specified both the MFC and standard libraries together. The problem was that a thread function (_beginthreadxxx or something like that) was giving trouble. I would specify only the MFC library and see what happens.

    Unless I'm mistaken, STL is just a bunch of sophisticated header files with the full source implemented in the templates. I wouldn't think that you would need to link in another library on top of what you already have (I may be wrong, though).

    Regards,

    Paul McKenzie


  3. #3
    Join Date
    Jul 1999
    Location
    UK
    Posts
    14

    Re: mfc and stl

    There are so many ways that libraries can be built that more often than not you'll trip up and cause the linker to get it's knickers in a twist. Make sure that you are compiling and linking a consistent set of objects/libraries (debug/release single/multithreaded CRT-DLL/static) - See the C++ tab/Code generation options in your Project Settings.

    As for STL it is indeed a set of header templates with all of the code effectively inline. There is no separate library. I prefer to use STL rather than MFC collections for the plain and simple fact that they provide iterators which are bloody useful!!

    Something else you might want to watch out for as well. The STL that comes with your Unix C++ compiler might differ from the one that comes with VC++ but that'll become immediately apparent when you get round to compiling it.

    Carl

  4. #4
    Join Date
    Oct 1999
    Location
    UK
    Posts
    81

    Re: mfc and stl

    Hi,

    I've been getting this error too. It happens when you include <iostream> and <afxwin.h>. I'm sure this is some horrible new iostream/stl/namespace issue but I'm not sure how to fix it.

    Like you, my app is non-GUI so I want to use "cout" et al so I'm snookered.

    Has anyone come up with a fix for this?

    Thanks.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured