ld: symbol(s) not found when linking library containing no executable functions


Reference Number : dpd200045548

Version : 10.1  and higher

Product : Intel Fortran Compiler

Operating System : Mac OS X

Problem Description :  If a library built with ar contains objects with Fortran module data but no executable functions, the symbols corresponding to the module data may not be resolved when an object referencing them is linked against the library. The symbols are present: the compiler generates a common symbol (C), e.g.
0000000000000050 C _module_modname_mp_varname_
but the linker does not realize that it needs to link the corresponding object.

Resolution Status : This issue may be resolved by adding -fno-common to the compiler (not linker) options. This will cause symbols such as the above to be placed in the text section instead of the common section, and the linker will then pick them up.

[DISCLAIMER: The information on this web site is intended for hardware system manufacturers and software developers. Intel does not warrant the accuracy, completeness or utility of any information on this site. Intel may make changes to the information or the site at any time without notice. Intel makes no commitment to update the information at this site. ALL INFORMATION PROVIDED ON THIS WEBSITE IS PROVIDED "as is" without any express, implied, or statutory warranty of any kind including but not limited to warranties of merchantability, non-infringement of intellectual property, or fitness for any particular purpose. Independent companies manufacture the third-party products that are mentioned on this site. Intel is not responsible for the quality or performance of third-party products and makes no representation or warranty regarding such products. The third-party supplier remains solely responsible for the design, manufacture, sale and functionality of its products. Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries. *Other names and brands may be claimed as the property of others.]


For more complete information about compiler optimizations, see our Optimization Notice.


Martyn Corden (Intel)'s picture

The option -fcommon (and its opposite, -fno-common) is in the online help, but I agree this use is not obvious, to say the least. That was the motivation for this article.
In the forthcoming compiler version, -fcommon has been added to the user & reference guide, including the text below. Once the symbols are treated as globals, the linker will find them.

The compiler does not treat common symbols as global definitions.

This option determines whether the compiler treats common symbols as global definitions and to allocate memory for each symbol at compile time.

Option -fno-common tells the compiler to treat common symbols as global definitions. When using this option, you can only have a common variable declared in one module; otherwise, a link time error will occur for multiple defined symbols.

luisa_urgias's picture

Thank you very much for this tip. I was fighting for about two weeks in trying to install ifort in my new Mac Lion for compiling successfully my code (v. 11.1 and 12.1 now both working).
The problem was that this ''magic'' option -fno-common is not even referenced in the on line manual of ifort.
Also I know by sure that other friends were able to run my code without problems (and without using this option) with
an older Mac-Lion (same version of ifort 11.1).
I wander wether there may be some randomness in the initialization of environment variables used by ifort for Mac-Lion.

Add a Comment

Have a technical question? Visit our forums. Have site or software product issues? Contact support.