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

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

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?



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

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.

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.

Leave a Comment

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