Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Just how reusable is fortran?

rahzan
New Contributor I
805 Views
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?

TimH
0 Kudos
3 Replies
Steven_L_Intel1
Employee
805 Views
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.

Steve
0 Kudos
rahzan
New Contributor I
805 Views
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.

Tim
0 Kudos
Steven_L_Intel1
Employee
805 Views
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!)

Steve
0 Kudos
Reply