Just how reusable is fortran?

Just how reusable is fortran?

I have recently discovered that if some simple module or function is placed in a library (ostensibly to facilitate code reuse) that the library must be produced in a large number of different versions.

According to the help topic "Specifying Consistent Library Types" One cannot just write a function that say, multiplies two numbers and be able to reuse the lib file in another project unless it is comiled with exactly the same run-time libraries as the client project. Never-mind that we are NOT doing anything fancy.

Just having to maintain 3 different workspaces (and a total of 6 versions= 3 types x 2 for debug and nondebug) for EACH library puts this out of the realm of reason.

I sure hope that I have misuderstood, but the annoying LNK4098 warning seems pretty definitive.

Any ideas?


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

The problem isn't Fortran, the language, it's more the way Microsoft does things, requiring the use of different C libraries (with different routine names) when compiling threaded or non, debug or non.

I think you can get around this by compiling your Fortran code with /libdir:noauto - this will prevent the compiler from inserting into the object modules linker directives to search specific libraries. It will then be required for the user of your code to specify the needed libraries - this will happen by default with Fortran code, but if the main program is in C, the libraries will have to be specified explicitly.


Retired 12/31/2016

Gosh darn it.
Your solution seems to work.

I wish I had known this long time ago. Every once in a while I come across this bugaboo and it is a big source of frustration. The setting should be more prominently listed under warning lnk4098.

In fact, I'd say that it should be the defualt setting for a static library project.


Well, this works for Fortran, but not for Visual C where the compiler actually emits different code depending on which library you're using! (A real pain, to be sure!)


Retired 12/31/2016

Leave a Comment

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