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

Naming convention of symbols in Object files

smk_009
Beginner
1,368 Views
hi,

I am using Intel fortran 9.1 EM64T compiler to compile fortran sources on Windows 64 bit XP machine. I am bit confused about the symbols that the are generated in the *.obj files. All the symbols are being generated without a leading underscore. For example if there is a subroutine test in the the test.f file, the corresponding naming convention symbol in the test.obj file compiled with EM64T ifort, is TEST without a leading underscore.

But If I use IA32, the symbols are like _TEST. I am callingthe C functions in Fortran, in Ccode I am using the default _cdecl calling convention so the symbols are being generated with a leading underscore. But using EM64T ifort the symbols are generated without a leading underscore.

For 64bit WINDOWS XP machine, which compiler do I need to use IA32 or EM64T?
If I should use EM64T what about the symbols i.e naming convention, I had reffered the intel documentation on Mixed language coding but not able to get any clue.

Looking for Help.

Regards,
Manoj
0 Kudos
5 Replies
TimP
Honored Contributor III
1,368 Views
If you are running 64-bit Windows, you can use either the ia32 or em64t compiler, but you can't mix them. Normally, you would prefer the 64-bit compiler, unless intending to run also on 32-bit Windows. Fortran, C, and C++ compilers which are interoperable will be consistent in their default use of leading underscores.
It's not a question of whether your hardware supports 64-bit; if you run 32-bit Windows on 64-bit hardward, you have the same limitations to ia32 compilers which you have on 32-bit hardware.
0 Kudos
smk_009
Beginner
1,368 Views
Quoting - tim18
If you are running 64-bit Windows, you can use either the ia32 or em64t compiler, but you can't mix them. Normally, you would prefer the 64-bit compiler, unless intending to run also on 32-bit Windows. Fortran, C, and C++ compilers which are interoperable will be consistent in their default use of leading underscores.
It's not a question of whether your hardware supports 64-bit; if you run 32-bit Windows on 64-bit hardward, you have the same limitations to ia32 compilers which you have on 32-bit hardware.


Hi Tim,

Thanks for your response. May be I am not clear in my question, Let me explain my issue correctly.

I am using EM64T ifort compiler on Windows XP 64 bit. I dont have any intentions to use the same executable or libraries on 32bit also.

My source codes have a Mixed Language C & Fortran. So some functions are need to called interchangbly either in Fortran or C. I am having Linking issues because all my fortran sources codes are not able to recognise the C functions.

When I checked the symbols in the fortran source codes, all the symbols in Obj files are generated with a leading underscore "_".

For example I have test.c file which had functiontest
test.c file

int test() {
/* Do something */
return;
}
This test.c file is compiled as library so _TEST symbol is available in that library (test.lib for suppose)
Now I have a fortran code

Program main
....
call test
...
end

To generate the executable I had linked test.lib, but in the fortran obj file the symbol is generated as TEST and linker give the error UNRESOLVED EXTERNAL TEST.

So my question why the em64t ifort is not generating the symbols as _TEST ( which is default convention in IA32 ifort and _cdecl for C).

Regards,

Manoj

0 Kudos
Steven_L_Intel1
Employee
1,368 Views
The underscore is missing because that's the correct convention as defined by Microsoft for 64-bit Windows. I'll comment that the ifort compiler sometimes applied this rule inconsistently in older versions, especially regarding module variables.
0 Kudos
smk_009
Beginner
1,368 Views
The underscore is missing because that's the correct convention as defined by Microsoft for 64-bit Windows. I'll comment that the ifort compiler sometimes applied this rule inconsistently in older versions, especially regarding module variables.

Hi Steve,

Thank you very much for your response.
Now I understand that for Microsoft Windows 64-bit, the underscore will not be there.
How can I do the Mixed language coding on 64bitusing Fortran & C, what calling conventions I should use. For C codes if I use the default (_cdecl) .NET 2005 is generating symbols with a leading underscore, but the em64t ifort is generating the symbols in obj files without a leading underscore. This is creating the unresolved Linker symbols.

Regards,
Manoj
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,368 Views
Quoting - smk_009
For C codes if I use the default (_cdecl) .NET 2005 is generating symbols with a leading underscore.

That should not/can not happen. I've just performed a small test with VC++ compiler in VS 2005, and the x64 .obj file does not contain the leading underscore, while Win32 does. Please double-check your settings or .obj file paths.
0 Kudos
Reply