Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29241 Discussions

Fortran/C: clock() function in msvcrt.lib

gib
New Contributor II
819 Views

I found that to build my Fortran program, which links to a C library, it was necessary to ignore msvcrt.lib, otherwise I get linker errors about functions being already defined in LIBCMT.lib.  Now I want to use clock() in the C code, but the linker says:

Error    1     error LNK2001: unresolved external symbol __imp__clock    cvReactDiff-lib.lib(cvReactDiff_bnd.obj)    

If I stop ignoring msvcrt.lib I don't get this error, but 10 others instead.  I don't understand why clock() is singled out - I'm using many other functions in the C runtime library.  Is there a way to get around this?

Thanks

Gib

0 Kudos
2 Replies
TimP
Honored Contributor III
819 Views
Did you check that your C and Fortran projects are set consistently to /MT (static link) or /MD (dynamic link)? The error checking may "single out" the first problem encountered.
0 Kudos
gib
New Contributor II
819 Views
That was easy! The library was /MD, should have been /MT. Now it works. I don't understand why it built successfully until I added the clock() call, since I'm using many other functions from the run-time library, but I will not lose sleep over it. Thanks Tim.
0 Kudos
Reply