- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think that your installation of IVF 11 is corrupted. Please uninstall it and then reinstall.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ignore my suggestion to reinstall Fortran. It is indeed possible, as Jugoslav suggests, that the Tools > Options... settings are wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page