Fortran calling C unresolved external symbol _memcpy

Fortran calling C unresolved external symbol _memcpy

Have seen lots of other posts that seem tantalizingly close, but am still missing something.

I'm converting an old mixed language CVF/VC 6.0 project  to IVF 11.1/VC 2005.  I let the dev environment separate the old combined project into the two separate C and F projects as requested, and both seem to compile fine.  The Fortran output is a DLL, and it calls a couple of C routines.  When the Fortran project attempts to link, the first errors I get are

1>libirc.lib(fastmemcpy.obj) : error LNK2001: unresolved external symbol _memcpy
1>libirc.lib(tbk_backtrace.obj) : error LNK2001: unresolved external symbol _memcpy
1>simrfio.obj : error LNK2019: unresolved external symbol _memcpy referenced in function _SETSIMOUT

SETSIMOUT is a Fortran subroutine that assigns common variables to members of a big structure for output.  The above errors go away if I comment out two lines that assign to members of an array.  There is nothing in this subroutine that explicitly calls any of my C routines, yet the assignment statement seems to be trying to use the C memcpy function.

I also get bunches of errors looking for __fltused, __chkstk, all from Fortran files, then start getting __RTC_Shutdown, __RTC_InitBase etc in the actual C files.

I've tried a couple of the library things mentioned in prior threads, to no avail. Probably something obvious in the settings, but any help would be appreciated.


4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Check if you are using consistent RTL options in the two projects. In other words, use /MD for both, or /MT for both, but not a mix of the two. Failing this, attach the build logs.

I agree with mecej4.   You seem to have a problem linking the Microsoft C run-time libraries.  Are you using Microsoft C for that part of your project?  If your C is defaulting to cdecl ABI, you should permit ifort to do the same (don't use /iface:cvf). (and be sure to rebuild all .obj).

Thanks so much guys!  The C project Configuration Properties\C/C++\Code Generation\RuntimeLibrary was set to Multi-threaded Debug (/MTd), and the Fortran\Libraries\Runtime Library was set to  Debug Multithreaded (/libs:static /threads/dbglibs), which seemed right to me.  But setting the Fortran Library to Debug Multithread DLL (/libs:dll /threads /dbglibs), maybe because the output is a DLL, did the trick!

Leave a Comment

Please sign in to add a comment. Not a member? Join today