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)
  • Missing Lib Files
    ... involve missing libraries. ... unresolved external symbol DisableThreadLibraryCalls referenced in function ... Can I copy the libraries to the paths they are missing from ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Missing Lib Files
    ... involve missing libraries. ... unresolved external symbol DisableThreadLibraryCalls referenced in function ...
    (microsoft.public.windowsce.platbuilder)
  • RE: Missing Lib Files
    ... I've found that strange errors tend to go away after a clean sysgen. ... Consider using a build window (if you're in Visual Studio right click your ... libraries and header files. ... unresolved external symbol DisableThreadLibraryCalls referenced in function ...
    (microsoft.public.windowsce.platbuilder)