Fortran from an MFC Application
-
I am attempting to reference some legacy Fortran code from an MFC application. I get a flood of library and include file redefinition errors when I compile the code. Is this a compatibility issue between MFC and Fortran? I can use the same code in a generic C++ application and there is no problem. Any information would be helpful. Thanks in advance! Dan Broomall GIS Programmer/Analyst Forest Technology Group 125 Crosscreek Drive Summerville, SC 29485 (843) 832-4169 - Phone (843) 873-6618 - Fax www.ftgrp.com mailto: dan.broomall@ftgrp.com The bearing of a child takes nine months, no matter how many women are assigned. - Frederick P. Brooks, Jr, The Mythical Man-Month
-
I am attempting to reference some legacy Fortran code from an MFC application. I get a flood of library and include file redefinition errors when I compile the code. Is this a compatibility issue between MFC and Fortran? I can use the same code in a generic C++ application and there is no problem. Any information would be helpful. Thanks in advance! Dan Broomall GIS Programmer/Analyst Forest Technology Group 125 Crosscreek Drive Summerville, SC 29485 (843) 832-4169 - Phone (843) 873-6618 - Fax www.ftgrp.com mailto: dan.broomall@ftgrp.com The bearing of a child takes nine months, no matter how many women are assigned. - Frederick P. Brooks, Jr, The Mythical Man-Month
MFC basically creates a bunch of types, such as UINT, DWORD, WORD, BYTE, etc., that can really conflict with how someone else defined the same things. This may be part of your include file redefinition errors. I've also encountered library redefinition errors when I link one module compiled with debug mode, and another module compiled with release mode. You might need to compile all the Fortran stuff as a generic C++ DLL and import it manually into your MFC app, and get the exported function pointers yourself. You'll have to resolve any global data too. Don't use the LIB file that the compiler generates when it creates the DLL--as soon as you do, you'll be screwed again. Does this help? Marc Help! I'm an AI running around in someone's f*cked up universe simulator.
-
I am attempting to reference some legacy Fortran code from an MFC application. I get a flood of library and include file redefinition errors when I compile the code. Is this a compatibility issue between MFC and Fortran? I can use the same code in a generic C++ application and there is no problem. Any information would be helpful. Thanks in advance! Dan Broomall GIS Programmer/Analyst Forest Technology Group 125 Crosscreek Drive Summerville, SC 29485 (843) 832-4169 - Phone (843) 873-6618 - Fax www.ftgrp.com mailto: dan.broomall@ftgrp.com The bearing of a child takes nine months, no matter how many women are assigned. - Frederick P. Brooks, Jr, The Mythical Man-Month
Yuck. We had something similar in my last job. How we got stuff to work: 1. All the FORTRAN stuff was self-contained in its own static library. 2. Any functions interfacing to C++ were clearly designated in a header/source file that wrapped around the Fortran. 3. Be really careful with strings, as they are encoded differently in Fortran and C++. It was still a pain in the butt, but that's how we did it. The suggestion somebody else mentioned to use a DLL would also work pretty well, we did that in some other cases. Even a broken clock is right twice a day.