[SOLVED] f2c Fortran translation ?

Discussion about everything. New games, 3d math, development tips...
Post Reply
zillion42
Posts: 324
Joined: Wed Aug 29, 2007 12:32 am
Location: Hamburg, Germany

[SOLVED] f2c Fortran translation ?

Post by zillion42 »

Hi,

a classical off topic. I am trying to make a simulation of earths magnetosphere, for that reason I researched a lot. Now there is something called the Tsynagenko Model and its written in fortran.
http://geo.phys.spbu.ru/~tsyganenko/modeling.html
Also I found f2c a fortran to c translation app and library for linking.
http://www.netlib.org/f2c/
Now I have succeeded in translating the original fortran code but I have failed building the f2c lib for windows (called vcf2c.lib) using nmake and a makefile... I thought I post the console output here, but I just realized it's longer than 900 lines, so I try to explain. It builds all the objects and fails linking them.
LINK : fatal error LNK1181: Eingabedatei "Loading.obj" kann nicht geöffnet werde
n.
NMAKE : fatal error U1077: ".\comptry.bat": Rückgabe-Code "0x2"
Stop.
Since Loading.obj is not really referenced anywhere I guessed it must be either a minute mistake in the makefile or my messed up visual studio installation, not sure... So I downloaded a precompiled vcf2c.lib and included it for linking...
#pragma comment(lib,"vcf2c.lib")
Now I get other linker errors, which either come from a mismatch release/debug or because the version I downloaded was not compiled with visual studio or because there is some multithreaded / singlethreaded conflict... not sure...

Code: Select all

1>libcmt.lib(tidtable.obj) : error LNK2005: __encode_pointer ist bereits in MSVCRT.lib(MSVCR80.dll) definiert.
1>libcmt.lib(tidtable.obj) : error LNK2005: __decode_pointer ist bereits in MSVCRT.lib(MSVCR80.dll) definiert.
1>libcmt.lib(invarg.obj) : error LNK2005: __invoke_watson ist bereits in MSVCRT.lib(MSVCR80.dll) definiert.
1>libcmt.lib(crt0dat.obj) : error LNK2005: __initterm_e ist bereits in MSVCRT.lib(MSVCR80.dll) definiert.
1>libcmt.lib(crt0dat.obj) : error LNK2005: __amsg_exit ist bereits in MSVCRT.lib(MSVCR80.dll) definiert.
1>libcmt.lib(crt0dat.obj) : error LNK2005: _exit ist bereits in MSVCRT.lib(MSVCR80.dll) definiert.
1>libcmt.lib(crt0dat.obj) : error LNK2005: __exit ist bereits in MSVCRT.lib(MSVCR80.dll) definiert.
1>libcmt.lib(crt0dat.obj) : error LNK2005: __cexit ist bereits in MSVCRT.lib(MSVCR80.dll) definiert.
1>libcmt.lib(mlock.obj) : error LNK2005: __unlock ist bereits in MSVCRT.lib(MSVCR80.dll) definiert.
1>libcmt.lib(mlock.obj) : error LNK2005: __lock ist bereits in MSVCRT.lib(MSVCR80.dll) definiert.
1>libcmt.lib(setlocal.obj) : error LNK2005: __configthreadlocale ist bereits in MSVCRT.lib(MSVCR80.dll) definiert.
1>libcmt.lib(winxfltr.obj) : error LNK2005: __XcptFilter ist bereits in MSVCRT.lib(MSVCR80.dll) definiert.
1>libcmt.lib(crt0init.obj) : error LNK2005: ___xi_a ist bereits in MSVCRT.lib(cinitexe.obj) definiert.
1>libcmt.lib(crt0init.obj) : error LNK2005: ___xi_z ist bereits in MSVCRT.lib(cinitexe.obj) definiert.
1>libcmt.lib(crt0init.obj) : error LNK2005: ___xc_a ist bereits in MSVCRT.lib(cinitexe.obj) definiert.
1>libcmt.lib(crt0init.obj) : error LNK2005: ___xc_z ist bereits in MSVCRT.lib(cinitexe.obj) definiert.
1>libcmt.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) ist bereits in MSVCRT.lib(MSVCR80.dll) definiert.
1>libcmt.lib(crt0.obj) : error LNK2005: _mainCRTStartup ist bereits in MSVCRT.lib(crtexe.obj) definiert.
1>libcmt.lib(errmode.obj) : error LNK2005: ___set_app_type ist bereits in MSVCRT.lib(MSVCR80.dll) definiert.
1>LINK : warning LNK4098: Standardbibliothek "MSVCRT" steht in Konflikt mit anderen Bibliotheken; /NODEFAULTLIB:Bibliothek verwenden.
1>MSVCRT.lib(cinitexe.obj) : warning LNK4098: Standardbibliothek "libcmt.lib" steht in Konflikt mit anderen Bibliotheken; /NODEFAULTLIB:Bibliothek verwenden.
1>C:\Dokumente und Einstellungen\tobi\Eigene Dateien\Visual Studio 2005\Projects\irrSolarSystem\Release\irrSolarSystem.exe : fatal error LNK1169: Mindestens ein mehrfach definiertes Symbol gefunden.
1>Das Buildprotokoll wurde unter "file://c:\Dokumente und Einstellungen\tobi\Eigene Dateien\Visual Studio 2005\Projects\irrSolarSystem\irrSolarSystem\Release\BuildLog.htm" gespeichert.
1>irrSolarSystem - 20 Fehler, 2 Warnung(en)
Well my question would be if anyone feels like helping me out and try to compile the vcf2c.lib on his windows, telling if it worked or explaining a little about Linker Tools Warning LNK4098
http://msdn.microsoft.com/en-us/library ... S.71).aspx

thx in advance
Last edited by zillion42 on Mon Jul 13, 2009 3:37 pm, edited 1 time in total.
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

Code: Select all

1>libcmt.lib(tidtable.obj) : error LNK2005: __encode_pointer ist bereits in MSVCRT.lib(MSVCR80.dll) definiert. 
There's this variable called "__encode_pointer". It's defined in MSVCRT.lib which is the runtime dll. You've linked in a static MT lib that also defines this variable. The linker doesn't know which to use.

There's more than one way around this: link with whatever libs the vcf2c.lib is linked with; tell VC to ignore one of the libs when linking.
zillion42
Posts: 324
Joined: Wed Aug 29, 2007 12:32 am
Location: Hamburg, Germany

Post by zillion42 »

OK,

still unresolved even though lots of people in the net seem to be having the same trouble when using vcf2c with Visual Studio I couldn't really find a solution yet. I succeeded in compiling the vcf2c.lib using nmake on my Toshiba, must be my visual studio installation on the other machine that hindered me before.
I tried the the /NODEFAULTLIB:licmt.lib /NODEFAULTLIB:MSVCRT.lib with the result that I'm now presented with unresolved symbols for standart operations I use elsewhere in my code:
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__srand".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__printf".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp___time64".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__rand".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__sprintf_s".
Trying to figure what sio2 meant by:
There's more than one way around this: link with whatever libs the vcf2c.lib is linked with;
zillion42
Posts: 324
Joined: Wed Aug 29, 2007 12:32 am
Location: Hamburg, Germany

Post by zillion42 »

ooops....
just using

/NODEFAULTLIB:libcmt.lib without ignoring MSVCRT.lib worked !!!

And... :oops:
it's libcmt.lib not licmt.lib
my bad and thx to sio2
Post Reply