- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am porting a working program from Solaris to the PC. It is basically C++ with heavy numerics performed in Fortran. My PC uses VS2005 and IVF 10.1. I have mixed Fortran and C++ before, but for some reason I am not project settings right this time.
My first issue was my declarations of my Fortran functions not being understood. I fixed that by compiling the Fortran first, but I don't understand why that had to be done. Just curious on this issue.
After that I got about 20link errors similiar to the following:
Description File
error LNK2005: __amsg_exit already defined in MSVCRT.lib(MSVCR80.dll)LIBCMT.lib
I figured I needed to ignore either MSVCRT.lib or LIBCMT.lib. IfI set the linker to ignore MSVCRT.lib I get2 link errorsin my own functions:
error LNK2001: unresolved external symbol __imp__atof
error LNK2001: unresolved external symbol __imp__memmove_s
If I set the linker to ignore LIBCMT.lib, I get5 errors
1>libifcoremt.lib(for_diags_intel.obj) : error LNK2001: unresolved external symbol __iob
1>libifcoremt.lib(for_nt_open_proc.obj) : error LNK2001: unresolved external symbol __iob
1>libmmt.lib(libm_error.obj) : error LNK2001: unresolved external symbol __iob
1>libifcoremt.lib(for_init.obj) : error LNK2001: unresolved external symbol ___argv
1>libifcoremt.lib(for_init.obj) : error LNK2001: unresolved external symbol ___argc
I guess I just need to get my properties set right, but I am not sure what to do next. Thanks
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That seems to help (using /lib:noauto), but I still have link errors:
2>ftest.lib(ftest.obj) : error LNK2001: unresolved external symbol _for_write_seq_lis
2>ftest.lib(ftest.obj) : error LNK2001: unresolved external symbol _for_write_seq_lis_xmit
I have a test program as follows
C++ main:
#include
using namespace std;
extern "C" { void FTEST(double*); }
int main(int argc, char* argv[])
{
char *gub = new char[6];
gub = "54321";
cout << gub << endl;
double fgub = atof(gub);
cout << fgub << endl;
FTEST(&fgub);
return 0;
}
FORTRAN Library:
SUBROUTINE ftest(flub)
REAL*8 flub
PRINT *, 'From Fortran we have flub = ', flub
RETURN
END
This code seems to have all the same link problems as my real project.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1. In the Fortran project, right click on the project, select Properties, Fortran, Libraries.and change "Disable default library search rules" to "No".
2. Tools > Options > Projects > VC++ Directories > Library Files. Add the path to the Intel Fortran LIB folder for your architecture
If you don't do these things, then the Fortran run-time libraries won't be searched or found.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have made the changes that Steve suggested, but I was already using the Fortran library path in my C++ project, so it made little difference. Using my little test application, I found that the main problem seems to be the print statement. If I remove the print line, and tell the project to ignore LIBCMT.LIB, the programs compiles with no warnings and runs. If I leave the print statement in I get the following errors:
2>libifcoremt.lib(for_diags_intel.obj) : error LNK2001: unresolved external symbol __iob
2>libifcoremt.lib(for_nt_open_proc.obj) : error LNK2001: unresolved external symbol __iob
2>libifcoremt.lib(for_init.obj) : error LNK2001: unresolved external symbol ___argv
2>libifcoremt.lib(for_init.obj) : error LNK2001: unresolved external symbol ___argc
I would not normally associate these link errors with the existance of a print statement. Anyway, I will now check through my real application and remove any Fortran read/writes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Removing all the Fortran writes to stdout in my real application has improved things. I am left with 1 link error;
2>libmmt.lib(libm_error.obj) : error LNK2001: unresolved external symbol __iob
Unfortunately I am out of ideas on what to do next.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Make sure that both your C/C++ project and your Fortran projects are using the same type of libraries.
Examples:
Fortran uses "Debug Multithreaded (/libs:static /threads /dbglibs)"; then C/C++ should use "Multi-threaded Debug (/MTd)"
Fortran uses "Multithreaded"; then C/C++ should use "Multi-threaded (/MT)" - the VC default project option is "Multi-threaded DLL (/MD)" which when not changed give me similar errors that you encountered.
From an example that works for both configurations (debug, release) on my system (XP2, VS2005 SP1, IVF 10.1.21) I have copied the command lines.
My Fortran static library (flibstatic) uses:
debug configuration: /nologo /Zi /Od /module:"Debug/" /object:"Debug/" /traceback /check:bounds /libs:static /threads /dbglibs /c
Release configuration: /nologo /module:"Release/" /object:"Release/" /libs:static /threads /c
With both configurations I have turned on the "default library search rules": Disable Default Library Search Rules = No
The C/C++ project containing the main program uses:
Debug configuration: /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Gm /EHsc /RTC1 /MTd /Fo"Debug" /Fd"Debugvc80.pdb" /W3 /nologo /c /Wp64 /ZI /TP /errorReport:prompt
Release configuration: /O2 /GL /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /EHsc /MT /Yu"stdafx.h" /Fp"ReleaseEx01_C_calls_Fortran.pch" /Fo"Release" /Fd"Releasevc80.pdb" /W3 /nologo /c /Wp64 /Zi /TP /errorReport:prompt
The linker command lines:
Debug configuration: /OUT:"C:EProgrammierungMixedLanguageProgrammingDebugEx01_C_calls_Fortran.exe" /INCREMENTAL /NOLOGO /LIBPATH:"C:ProgrammeIntelCompilerFortran10.1.021IA32Lib" /MANIFEST /MANIFESTFILE:"DebugEx01_C_calls_Fortran.exe.intermediate.manifest" /DEBUG /PDB:"c:EProgrammierungMixedLanguageProgrammingdebugEx01_C_calls_Fortran.pdb" /SUBSYSTEM:CONSOLE /MACHINE:X86 /ERRORREPORT:PROMPT kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "..flibstatic eleaseflibstatic.lib"
Release configuration: /OUT:"C:EProgrammierungMixedLanguageProgrammingReleaseEx01_C_calls_Fortran.exe" /INCREMENTAL:NO /NOLOGO /LIBPATH:"C:ProgrammeIntelCompilerFortran10.1.021IA32Lib" /MANIFEST /MANIFESTFILE:"ReleaseEx01_C_calls_Fortran.exe.intermediate.manifest" /DEBUG /PDB:"c:eprogrammierungmixedlanguageprogramming eleaseEx01_C_calls_Fortran.pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /LTCG /MACHINE:X86 /ERRORREPORT:PROMPT kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "..flibstatic eleaseflibstatic.lib"
Here I have added the IVF library path (/LIBPATH:"C:ProgrammeIntelCompilerFortran10.1.021IA32Lib) that is probably different on your system. The IVF libraries to be linked in (like ifconsol.lib, libifcoremt.lib) don't have to be named explicitely since they are found due to turning on "default library search rules" when building the Fortran static library.
I hope this helps.
Jrg Kuthe
www.qtsoftware.de

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page