Re: linking g95-built library from VC++



I've done a little more experimenting, and gotten it to work by the simple
device of explicitly placing LIBC.lib on the command line in front of
msvcrt.lib:

cl caller.c fortlib.lib f95.lib gcc.lib LIBC.lib msvcrt.lib

That produces the warning messages:

LINK : warning LNK4089: all references to "dkxh.o" discarded by /OPT:REF
LINK : warning LNK4089: all references to "dkxs00060.o" discarded by
/OPT:REF

but the application appears to run correctly.

I noticed that msvcrt.lib can be found amoung the VC++ libraries, and that I
can omit copying it from the GNU libararies. Either seems to work, and both
result in the warning messages shown above.

I'd still be grateful for instruction from anyone who actually knows the
correct way to go about this.

"Matthew Halfant" <halfant@xxxxxxx> wrote in message
news:O90pg.363$cd3.193@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I've built a library of Fortran 95 functions using g95 on Win2k, and
my colleagues at work need to statically link to it from Microsoft
VC++. I seem to be making progress, but don't really know what I'm
doing, and am hoping that someone has worked through these issues and
can advise.

I'm building the library with

g95 -O3 -c foo_1.f90
g95 -O3 -c foo_2.f90
...
ren *.o *.obj
lib /out:fortlib.lib *.obj

The C interface is caller.c and I'm trying to use cl (VC++ C Compiler)
to build the final executable. Toward that end I copy libf95.a and
libgcc.a as .lib files:

copy libf95.a f95.lib
copy libgcc.a gcc.lib
cl caller.c fortlib.lib f95.lib gcc.lib

The link stage reports the following error:

f95.lib(environ.o) : error LNK2001: unresolved external symbol
___p__environ

I tried to remedy this by including also the GNU library libmsvcrt.a,
copied to the name msvcrt.lib:

cl caller.c fortlib.lib f95.lib gcc.lib msvcrt.lib

This now produces the complaint:

LIBC.lib(crt0dat.obj) : error LNK2005: _exit already defined in
msvcrt.lib(dkxs00554.o)
LIBC.lib(strchr.obj) : error LNK2005: _strchr already defined in
msvcrt.lib(dkxs00664.o)
caller.exe : fatal error LNK1169: one or more multiply defined symbols
found

Any suggestions?

Thanks,
Matthew




.



Relevant Pages

  • linking g95-built library from VC++
    ... my colleagues at work need to statically link to it from Microsoft ... lib /out:fortlib.lib *.obj ... libgcc.a as .lib files: ... f95.lib: error LNK2001: unresolved external symbol ...
    (comp.lang.fortran)
  • Link problem with Compaq Visual Fortran
    ... yet one of the source codes is a Fortran program. ... to compile the Fortran and C into a library. ... I first got some message saying some libraries are missing (ex: ... dfor.lib: error LNK2001: unresolved external symbol ...
    (comp.lang.fortran)
  • Run time library?
    ... I want to build a custom dll from Intel MKL dll's with Intel's ... The fortran compiler ... LINK: warning LNK4001: no object files specified; libraries used ... LINK: error LNK2001: unresolved external symbol __DllMainCRTStartup@12 ...
    (comp.lang.fortran)
  • Re: W2K Libraries are corrupted in the WS2008 and Vista RTM releases..
    ... Please do not send e-mail directly to this alias. ... the new WDK RTM releases? ... libraries into the W2K set ... ... error LNK2019: unresolved external symbol __imp_@InterlockedPushEntrySList@8 ...
    (microsoft.public.development.device.drivers)
  • Re: Problem with linker
    ... If I were you I'd look for the routines that are listed in the errors and see which libraries they are supposed to be in and ensure that the right versions of libraries are included and compiled with the same compiler. ... simwfp.lib: error LNK2001: unresolved external symbol ... program Unicode-aware everywhere, ...
    (microsoft.public.vc.mfc)