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

Linker warnings LNK4006 and LNK4221

Martin_B_2
Beginner
3,561 Views

When I link my library I get many warnings LNK4006 "NULL_IMPORT_DESCRIPTOR already defined in kernel32.lib(KERNEL32.dll); will be ignored".

The warnings seem to come from user32.lib, gdi32.lib, winspool.lib, comdlg32.lib, advapi32.lib, shell32.lib ...

0 Kudos
6 Replies
mecej4
Honored Contributor III
3,561 Views

What do you mean by "When I link my library..."? Are you building a DLL? An EXE?

You need to provide, at a minimum, the linking command that produced the errors/warnings. You mention Error 4221 in the title but nowhere in the body of your post.

0 Kudos
Martin_B_2
Beginner
3,561 Views

I am building a .lib-file.

Each LNK4006 is followed by a LNK4221.

0 Kudos
Steven_L_Intel1
Employee
3,561 Views

Don't add DLL import libraries as inputs to your static library build.  You should not be "linking" a static library. What is happening is that you have the "Include dependent libraries" option on (I forget the exact spelling) and you have named various DLL import libraries as inputs for a static library build. Take those out.

0 Kudos
Martin_B_2
Beginner
3,561 Views

Do you mean, that I have to leave the field "librarian - general - additional dependencies" in the options empty?

0 Kudos
mecej4
Honored Contributor III
3,561 Views

Martin B. wrote:

Do you mean, that I have to leave the field "librarian - general - additional dependencies" in the options empty?

Yes, if you are referring to one of the umpteen panels of the project properties inside Visual studio. The problem with answering such questions is that there are plenty of other options and settings in those panels that you may have set and may affect the answer to your questions, and you have not stated anything about those options and settings.

The advice that Dr. Fortran most recently gave in the last paragraph of https://software.intel.com/en-us/forums/topic/560615#comment-1829821 is well worth following.

Usually, when a static library is built, it is simply an archive of all the input .OBJ files, plus a dictionary/directory of the symbols and archive members. It follows that there will be plenty of references to unresolved symbols. Those symbols may be from the Fortran runtime, or the system libraries such as MSVCRT.DLL, KERNEL32.DLL, etc., or from additional libraries such as MKL, IMSL, etc. These symbols will be resolved when you link an application with the static library that you are now building.

 

0 Kudos
Steven_L_Intel1
Employee
3,561 Views

Typically for a static library build, you have no additional dependencies. The exception would be when you are building multiple static libraries and want to have one include all the others. What you seem to have done is name several Windows DLL import libraries. While these do have the .lib file type, they are NOT static libraries and can't be included in yours. The user of your library would need to link to the appropriate libraries. By default in a static library build, the Fortran compiler adds "object comment directives" that name the Fortran run-time libraries to be linked against. The linker will process these when the executable program is linked.

0 Kudos
Reply