Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Machine Module Conflict

sarma_amras
New Contributor I
1,933 Views

Hi,

I am getting the following error when trying make C calling a Fortran in VS2008 with IVF 11.0 whereas the same code is working fine in VS2005 with IVF 11.0

LIBCMTD.lib(ctype.obj) : fatal error LNK1112: module machine type 'SH4' conflicts with target machine type 'X86'

this is the error I am facing for the past two days...I have taken care regarding the libraries that are being used and also the settings in the IDE.

some please suggest.

Thanks

Kameswara Sarma

0 Kudos
15 Replies
TimP
Honored Contributor III
1,933 Views

If you are serious about generating code for sh4 (cross compiling), you won't be able to use ifort. This would not be different between VS2005 and 2008.

0 Kudos
Steven_L_Intel1
Employee
1,933 Views

I think that your installation of IVF 11 is corrupted. Please uninstall it and then reinstall.

0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,933 Views
Quoting - sarma_amras

LIBCMTD.lib(ctype.obj) : fatal error LNK1112: module machine type 'SH4' conflicts with target machine type 'X86'

The error message is telling you that your C++ project links with run-time library for the exotic microprocessor Renesas SH-4A.

Somehow, your C++ project got screwed -- check out Build/Configuration manager. Either that, or you got your Tools/Options/Projects and Solutions/VC++ directories somehow screwed up -- please verify that directories for Platform:Win32 library files include $(VCInstallDir)lib on the first place.

{the IDE options I listed above are for VS2005 -- I assume they're called similarly for VS2008, which I don't have}

0 Kudos
Steven_L_Intel1
Employee
1,933 Views

Ignore my suggestion to reinstall Fortran. It is indeed possible, as Jugoslav suggests, that the Tools > Options... settings are wrong.

0 Kudos
sarma_amras
New Contributor I
1,933 Views

Ignore my suggestion to reinstall Fortran. It is indeed possible, as Jugoslav suggests, that the Tools > Options... settings are wrong.


But I don't have any libraries relate to the SH4 module type.

I am not sure from where VS2008 is finding these libraries related to SH4.

Please suggest some other possible solution.

0 Kudos
Steven_L_Intel1
Employee
1,933 Views

Indeed, I had never heard of machine type SH4 before this thread... As an experiment, change the run-time library setting under C++ > Code Generation and Fortran > Libraries to "Multithreaded DLL (/MD)" and rebuild the solution. What happens?

0 Kudos
sarma_amras
New Contributor I
1,933 Views

Indeed, I had never heard of machine type SH4 before this thread... As an experiment, change the run-time library setting under C++ > Code Generation and Fortran > Libraries to "Multithreaded DLL (/MD)" and rebuild the solution. What happens?


I have tried every option available in the the aforesaid properties. But still I face the same error. Please suggest...I am not able to get along with it.

0 Kudos
Steven_L_Intel1
Employee
1,933 Views

Please attach a ZIP of your solution folder. See here for attachment instructions. Be sure to include the .vfproj file and the buildlog.htm from the Debug and/or Release folder.

0 Kudos
sarma_amras
New Contributor I
1,933 Views

Please attach a ZIP of your solution folder. See here for attachment instructions. Be sure to include the .vfproj file and the buildlog.htm from the Debug and/or Release folder.

Please find the attached solution file.

C is the main function and is called a Fortran routine. I am using VS2008 with IVF 11.0

I have attached the files but I doubt whether they are attached or not ..please let me know.

0 Kudos
Steven_L_Intel1
Employee
1,933 Views

Thanks for the files.

In your C++ project, you have, under Linker > Additional Dependencies, this:

"C:Program FilesMicrosoft Visual C++ Toolkit 2003liblibcpmt.lib"

Why? Does removing that make the error go away?

I also noticed that your C++ project included two ARM target configurations, though that might be harmless in this case It does seem as if you had installed Microsoft C++ support for ARM development in the past.

Another minor thing - in your Fortran project, under Librarian, Additional Options, you have "-n". This is not a supported librarian switch and I suggest removing it.

0 Kudos
Steven_L_Intel1
Employee
1,933 Views

If the above suggestions don't help, please do this. In Visual Studio, select Tools > Options > Projects and Solutions > VC++ Directories. For Platform, select Win32 if not already selected, and for "Show directories for" select "Library Files". It should look like this:

$(VCInstallDir)lib
$(VCInstallDir)atlmfclib
$(VCInstallDir)atlmfclibi386
$(WindowsSdkDir)lib
$(WindowsSdkDir)commonlib
$(FrameworkSDKDir)lib
$(VSInstallDir)
$(VSInstallDir)lib
$(IFORT_COMPILER11)libia32

The order does not matter, but in general there should not be other entries in here. The last line you probably don't have but should add - this makes the Intel Fortran libraries available to C++ projects.

0 Kudos
sarma_amras
New Contributor I
1,933 Views

If the above suggestions don't help, please do this. In Visual Studio, select Tools > Options > Projects and Solutions > VC++ Directories. For Platform, select Win32 if not already selected, and for "Show directories for" select "Library Files". It should look like this:

$(VCInstallDir)lib
$(VCInstallDir)atlmfclib
$(VCInstallDir)atlmfclibi386
$(WindowsSdkDir)lib
$(WindowsSdkDir)commonlib
$(FrameworkSDKDir)lib
$(VSInstallDir)
$(VSInstallDir)lib
$(IFORT_COMPILER11)libia32

The order does not matter, but in general there should not be other entries in here. The last line you probably don't have but should add - this makes the Intel Fortran libraries available to C++ projects.


Still I am facing the same error. I am not able to get out of this.
0 Kudos
anthonyrichards
New Contributor III
1,933 Views
Quoting - sarma_amras

Still I am facing the same error. I am not able to get out of this.

Here is your C_main code:

#include
void fort_sub();
void main()
{
printf("Inside Main\n");
fort_sub();
printf("Back to Main\n");
}

It fails to build because it does not know that FORT_SUB (the case is important) is an external function held in a Fortran .LIB that you need to link to.

The code you supplied is therefore not enough or is wrong. The following C++ version of your slightly modified code compiles and executes OK as a console program:

// c_main.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
extern "C" void FORT_SUB();
int main(int argc, char* argv[])
{
printf("Inside Main\n");
FORT_SUB();
printf("Back to Main\n");
return 0;
}

The following is your Fortran code that compiled OK into a Fortran .LIB which was then included into the C++ project before the c_main program was built:

subroutine fort_sub()
write(*,*) 'Inside Fortran'
end

The following is the console output when the C_main program is run:

Inside Main
Inside Fortran
Back to Main
Press any key to continue

I suggest you try again with a clean C project. And read the mixed language guide in your Fortran compiler help.
Your particular problem appears not to be caused by the code itself, rather it is caused by or linked to thesettings you havegivenyour C project, or possibly your Fortran compiler installation.
0 Kudos
sarma_amras
New Contributor I
1,933 Views
Anthony,

Thanks for you kind reply and the time spent.
But for your kind information, it really doesn't matter how my function is fort_sub() whether in small or caps letters. We can handle the switch so that the function names are handled as small all the time and this is what I have done.
More so for your information, the code I have sent to you is working fine in Vs2005 and IVF 11.0 with out caps changes.
But it is failing with VS2008 and IVF 11.0 throwing the Machine Module Conflict.

Thanks
Kameswara Sarma
0 Kudos
Steven_L_Intel1
Employee
1,933 Views
Please do this. Right-click on the C++ project, select Properties, Linker, General. Change "Show Progress" to "Display All Progress Messages". Rebuild the application. In the Debug folder of the C++ project will be a Buildlog.htm. Add that as an attachment to a reply here following the instructions at this link. Be sure to complete all the steps listed, including clicking on the "Add as Attachment" button. This may provide a clue.
0 Kudos
Reply