CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Visual C++ Programming
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Visual C++ Programming Ask questions about Windows programming with Visual C++ and help others by answering their questions.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old May 21st, 2001, 02:45 PM
    M J M J is offline
    Member
     
    Join Date: Feb 2001
    Location: Virginia, USA
    Posts: 170
    M J is an unknown quantity at this point (<10)
    Missing Ordinal From MFC42.DLL

    Hi there.

    I used Win98 to develop an application that should also run on NT. I tested it on an NT box and it said that the MFC42.DLL was missing an ordinal, and therefore refused to run. When I updated the MFC42.DLL file on the NT box, the app ran just fine.

    My question: how can I avoid making the user update the MFC42.DLL? I thought perhaps if I changed my compile option to use MFC in a static library this would fix things, but then I got the following link errors and couldn't compile:

    nafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMT.lib(new.obj)
    nafxcw.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMT.lib(delete.obj)
    Release/MyApp.exe : fatal error LNK1169: one or more multiply defined symbols found

    Is the solution to use static MFC? If so, how do I fix these link errors? Or is there a better solution to the problem? I've never used InstallShield, but should I package an updated version of MFC42.DLL with my program using this utility?

    Thanks in advance for your help!

    Mike

    Reply With Quote
      #2    
    Old May 21st, 2001, 02:45 PM
    M J M J is offline
    Member
     
    Join Date: Feb 2001
    Location: Virginia, USA
    Posts: 167
    M J is an unknown quantity at this point (<10)
    Missing Ordinal From MFC42.DLL

    Hi there.

    I used Win98 to develop an application that should also run on NT. I tested it on an NT box and it said that the MFC42.DLL was missing an ordinal, and therefore refused to run. When I updated the MFC42.DLL file on the NT box, the app ran just fine.

    My question: how can I avoid making the user update the MFC42.DLL? I thought perhaps if I changed my compile option to use MFC in a static library this would fix things, but then I got the following link errors and couldn't compile:

    nafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMT.lib(new.obj)
    nafxcw.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMT.lib(delete.obj)
    Release/MyApp.exe : fatal error LNK1169: one or more multiply defined symbols found

    Is the solution to use static MFC? If so, how do I fix these link errors? Or is there a better solution to the problem? I've never used InstallShield, but should I package an updated version of MFC42.DLL with my program using this utility?

    Thanks in advance for your help!

    Mike

    Reply With Quote
      #3    
    Old May 22nd, 2001, 04:36 PM
    M J M J is offline
    Member
     
    Join Date: Feb 2001
    Location: Virginia, USA
    Posts: 170
    M J is an unknown quantity at this point (<10)
    Re: Missing Ordinal From MFC42.DLL

    No ideas?

    Reply With Quote
      #4    
    Old May 22nd, 2001, 04:36 PM
    M J M J is offline
    Member
     
    Join Date: Feb 2001
    Location: Virginia, USA
    Posts: 167
    M J is an unknown quantity at this point (<10)
    Re: Missing Ordinal From MFC42.DLL

    No ideas?

    Reply With Quote
      #5    
    Old May 22nd, 2001, 04:50 PM
    WillCodeForMoney WillCodeForMoney is offline
    Member
     
    Join Date: Oct 1999
    Location: Alabama
    Posts: 80
    WillCodeForMoney is an unknown quantity at this point (<10)
    Re: Missing Ordinal From MFC42.DLL

    The problem is because of different versions of the DLLs. You executable links with an import library (.LIB) associated with each DLL. The import library that you executable links with must be of the same version as the associated DLL on the target machine that the exe will run on.

    The best solution is to link statically. The link errors can be due to a number of problems.

    The usual suspects:

    Different dependencies are built with different link options. That is, one lib or dll is linking to MFC and/or CRT dynamically while another lib or DLL is linking statically.

    You have to be careful when delivering DLLs to another system. If you deliver versions that are incompatible with other libs on the target system you can break other software.

    WillCodeForMoney
    Reply With Quote
      #6    
    Old May 22nd, 2001, 04:56 PM
    WillCodeForMoney WillCodeForMoney is offline
    Member
     
    Join Date: Oct 1999
    Location: Alabama
    Posts: 80
    WillCodeForMoney is an unknown quantity at this point (<10)
    Re: Missing Ordinal From MFC42.DLL

    By the way, you can deliver DLLs with InstallShield (as long as you deliver the correct ones that Microsoft ok's for redistribution). Just don't deliver them to their usual location. Make sure they are loaded from the app's directory.


    WillCodeForMoney
    Reply With Quote
      #7    
    Old May 22nd, 2001, 05:02 PM
    M J M J is offline
    Member
     
    Join Date: Feb 2001
    Location: Virginia, USA
    Posts: 170
    M J is an unknown quantity at this point (<10)
    Re: Missing Ordinal From MFC42.DLL

    Thank you, "Will". That gives me some ideas about how I can go about fixing my linking problem when compiling statically. I link some files that do not use MFC at all, and perhaps the problem is there. I appreciate the suggestions.

    Mike

    Reply With Quote
      #8    
    Old May 22nd, 2001, 05:02 PM
    M J M J is offline
    Member
     
    Join Date: Feb 2001
    Location: Virginia, USA
    Posts: 167
    M J is an unknown quantity at this point (<10)
    Re: Missing Ordinal From MFC42.DLL

    Thank you, "Will". That gives me some ideas about how I can go about fixing my linking problem when compiling statically. I link some files that do not use MFC at all, and perhaps the problem is there. I appreciate the suggestions.

    Mike

    Reply With Quote
      #9    
    Old May 22nd, 2001, 05:20 PM
    M J M J is offline
    Member
     
    Join Date: Feb 2001
    Location: Virginia, USA
    Posts: 170
    M J is an unknown quantity at this point (<10)
    Re: Missing Ordinal From MFC42.DLL

    Well, I thought that I had some ideas for how to fix the statically-linked-version errors. But it looks like my project settings force me to use MFC exclusively as a shared dll or as a statically linked library for the entire project, so there's no way that my non-MFC classes can be controlled individually on that level. Also, it appears that both debug and release versions use only the multithreaded DLL for runtime library and not some mixture of runtime libraries. I'm not sure how to proceed, but I guess I'll keep plugging away at changing the project settings until the link errors go away.

    Reply With Quote
      #10    
    Old May 22nd, 2001, 05:20 PM
    M J M J is offline
    Member
     
    Join Date: Feb 2001
    Location: Virginia, USA
    Posts: 167
    M J is an unknown quantity at this point (<10)
    Re: Missing Ordinal From MFC42.DLL

    Well, I thought that I had some ideas for how to fix the statically-linked-version errors. But it looks like my project settings force me to use MFC exclusively as a shared dll or as a statically linked library for the entire project, so there's no way that my non-MFC classes can be controlled individually on that level. Also, it appears that both debug and release versions use only the multithreaded DLL for runtime library and not some mixture of runtime libraries. I'm not sure how to proceed, but I guess I'll keep plugging away at changing the project settings until the link errors go away.

    Reply With Quote
      #11    
    Old May 22nd, 2001, 05:29 PM
    M J M J is offline
    Member
     
    Join Date: Feb 2001
    Location: Virginia, USA
    Posts: 170
    M J is an unknown quantity at this point (<10)
    Re: Missing Ordinal From MFC42.DLL

    Because I want to change my project that was AppWizarded as a "Use MFC as a Shared DLL" to static MFC link, should I just be able to change that in the Project Settings for All Configurations? Or is it much more involved than that? Starting over from AppWizard may be a daunting task as I've used ClassWizard to make many customizations.

    Reply With Quote
      #12    
    Old May 22nd, 2001, 05:29 PM
    M J M J is offline
    Member
     
    Join Date: Feb 2001
    Location: Virginia, USA
    Posts: 167
    M J is an unknown quantity at this point (<10)
    Re: Missing Ordinal From MFC42.DLL

    Because I want to change my project that was AppWizarded as a "Use MFC as a Shared DLL" to static MFC link, should I just be able to change that in the Project Settings for All Configurations? Or is it much more involved than that? Starting over from AppWizard may be a daunting task as I've used ClassWizard to make many customizations.

    Reply With Quote
      #13    
    Old May 22nd, 2001, 06:02 PM
    Paul McKenzie Paul McKenzie is offline
    Elite Member
    Power Poster
     
    Join Date: Apr 1999
    Posts: 20,397
    Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)
    Re: Missing Ordinal From MFC42.DLL

    There is a bug in VC++ when attempting to build a static library version that crops up from time to time.

    Before doing anything, make sure that all of your modules are linked using the same run-time library. This includes all of your source files, as well as *any* external static or import libraries that you may have added from a third-party. I noticed that if you use a .LIB file that was built using a different run-time library, linking will fail.

    If you are OK with the above, the fix to this problem is a little drastic, but hopefully not too much. The bug in VC++ is that sometimes a build of a static library introduces components to the linker that use the incorrect run-time library. I found this out the hard way -- for a whole day I was trying to build a static version of a program, and the linker was giving me the same or similar errors to what you are seeing. All of the settings were OK, so I said to heck with this and just removed all the .CPP files from my project and compiled/linked one by one. Eventually, the linker cooperated when I added back the last file.

    So you need to rebuild from scratch. Not just do a "Rebuild All", but remove all of your .CPP files from your project. Next, you add them in one at a time, compiling and attempting to link each time. You will notice that you will not be getting the same linker errors -- instead you will be getting the more familiar "function not found" error, since all of your CPP files are not in the project.

    When you've added the last file, hopefully the linker will cooperate and link successfully.

    Regards,

    Paul McKenzie

    Reply With Quote
      #14    
    Old May 22nd, 2001, 06:50 PM
    M J M J is offline
    Member
     
    Join Date: Feb 2001
    Location: Virginia, USA
    Posts: 170
    M J is an unknown quantity at this point (<10)
    Re: Missing Ordinal From MFC42.DLL

    Thanks very much, Paul. I tried that technique and it worked -- no more link errors after converting to a static build. Your experience saved me a lot of time, as I probably never would've tried that route.

    Thanks again!

    Mike

    Reply With Quote
      #15    
    Old May 22nd, 2001, 06:50 PM
    M J M J is offline
    Member
     
    Join Date: Feb 2001
    Location: Virginia, USA
    Posts: 167
    M J is an unknown quantity at this point (<10)
    Re: Missing Ordinal From MFC42.DLL

    Thanks very much, Paul. I tried that technique and it worked -- no more link errors after converting to a static build. Your experience saved me a lot of time, as I probably never would've tried that route.

    Thanks again!

    Mike

    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Visual C++ Programming


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 08:38 PM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009