Software Archive
Read-only legacy content

linking errors

Intel_C_Intel
Employee
763 Views
LINK : warning LNK4075: ignoring /EDITANDCONTINUE due to /INCREMENTAL:NO specification

MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _malloc already defined in libcmt.lib(malloc.obj)

MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _free already defined in libcmt.lib(free.obj)


I have set library :multithreaded, run-time:static

I wonder why both MSVCRTD.lib and libcmt.lib are included. Could someone enlight me how to resolve this?

Thank you.
Jackel
0 Kudos
6 Replies
Steven_L_Intel1
Employee
763 Views
I assume you have a mixed Fortran-C project. Go to Project..Settings..Fortran..Libraries and check the "Use debug C libraries" box.

See also the newsletter article Multiple C Library Syndrome.

Steve
0 Kudos
Intel_C_Intel
Employee
763 Views
Thank you, Steve
I call a mixed fortran-C dll library from a Fortran console application.
Does it mean I also have to set run-time library to DLL for this application ?
I tried what you said. now have some new problems.


"INK : error LNK2001: unresolved external symbol _mainCRTStartup
fortran.lib(fortran_API.obj) : error LNK2001: unresolved external symbol __imp__printf
fortran.lib(fortran_API.obj) : error LNK2001: unresolved external symbol __chkesp
fortran.lib(fortran_API.obj) : error LNK2001: unresolved external symbol __imp__malloc
fortran.lib(fortran_API.obj) : error LNK2001: unresolved external symbol __imp__free
fortran.lib(fortran_API.obj) : error LNK2001: unresolved external symbol __fltused
"



Jackel
0 Kudos
Steven_L_Intel1
Employee
763 Views
I can't tell you how to solve this without seeing the actual project. I have no idea what you ended up with. Please send a ZIP file of your project to us at vf-support@compaq.com and we'll straighten you out.

Steve
0 Kudos
sgibby
Beginner
763 Views
I am having similar problems; get the follow error messages:
-----------
Linking...
fileinfo.obj : warning LNK4044: unrecognized option "editandcontinue"; ignored
fileinfo.obj : error LNK2001: unresolved external symbol __chkesp
jobsum.obj : error LNK2001: unresolved external symbol _FILEINFO@28
Debug/pcburn01.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
pcburn01.exe - 3 error(s), 1 warning(s)
------------

I have VF 5.0D and VS C++ 6.0. FILEINFO.OBJ is a simple C source routine that I compiled with VS C++ 6.0 and added OBJ file to VF 5.0D project. I have tried many variances in Project Settings in both VF and VSC++ to no avail, as recommended on various web pages under www.compaq.com/fortran and Help pages in Developer Studio. For example, I have tried with and without C debug libraries (get same error messges).

The VF 5.0 project is a quckwin project with perhaps 20 - 30 FORTRAN source files. The VS C++ only compiles fileinfo.c to OBJ file. Please help.

Thanks,
Shawn
0 Kudos
Steven_L_Intel1
Employee
763 Views
Shawn,

Your problem is very different - it appears to be a simple mismatch of calling and naming conventions. Please read the chapter on mixed-language programming for details. By the way, I strongly recommend against trying to link a VC++ 6 object in the DVF 5.0 environment - this can cause all sorts of problems (though not the ones you're seeing.) Do the linking in the newer environment.

Steve
0 Kudos
sgibby
Beginner
763 Views
Thanks for your quick reply and advice. I had been studying mixed-languages documentation and by the time I got your reply, I practically had it figured out.

To hopefully benefit others, and see if you have problems with my approach, I want to identify the resolution to each issue.

1. error LNK2001: unresolved external symbol __chkesp
I had to remove the /GZ library from the Visual Studio C++ compiler options to preclude VF 5.0D giving this error message.

2. error LNK2001: unresolved external symbol _FILEINFO@28
Evidently, VF requires an INTERFACE block to use C routines. INTERFACE was discussed in mixed-language programming documentation, but I did not realize that it was REQUIRED. I am porting this code from an IBM RS/6000 with AIX (UNIX), which does not require the INTERFACE block. Once I added the INTERFACE block, I got more severe errors, where the linker terminated:

fileinfo.obj : warning LNK4044: unrecognized option "editandcontinue"; ignored
fileinfo.obj : error : Internal error during Pass2
Error executing link.exe.
Tool execution canceled by user.

3. warning LNK4044: unrecognized option "editandcontinue"; ignored
It turns out that Visual Studio C++ 6.0, Project Settings, C++ tab. Debug info: set to "Program Database for Edit and Continue" was causing the warning message and the "Internal error during Pass2". I set Debug info to NONE and re-compiled my C source. Back in VF 5.0D my project compiled and linked wiith no errors or warnings.

4. Although I now had my executable built, I took your advice and linked the project using the newer environment. So I added all my FORTRAN obj files to my Visual Studio C++ 6.0 project that contains only 1 C source file. I simply had to specify Additional Library path: c:program filesDevStudioDFlib under Project, Settings, Link tab to tell the C linker where the FORTRAN libraries where. By the way, I was able to add the /GZ library option back and the project linked fine under the VS C++ 6.0.

I hope this helps someone else. FYI, it has been very easy porting my IBM RS/6000 code to PC Visual Fortran. The syntax is very similar (very little changes required). VF automatically reads the source (text) files in UNIX format (it sometimes puts in a ^M DOS end-of-line marker which messes up my RS/6000 compiler). But, with a few directive statements (e.g. #ifdef) for times when the syntax is different, USE DFPORT or USE DFLIB, I have been able to easily create source that compiles on both the RS/6000 and the PC. And with CONVERT="BIG_ENDIAN" on the OPEN statement for unformatted (binary) files, the PC code can read UNIX binary files.

Furthermore, I have just got approval for the upgrades to VF 6.5A for programmers in my group.

Thanks,
Shawn
0 Kudos
Reply