- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying tocreate a DLL out of one of our programs and at link time I get a
message about libifcoremdd.dll missing a symbol _MAIN__:
libifcoremdd.lib(for_main.obj) : error LNK2019: unresolved external symbol _MAIN__ referenced in function _main
I have not been able to reproduce this ina smallerlibrary and I have no clue where the dependency
is coming from. My question, of course, is: how do I get rid of this message?
Right now, I use the/force option to the linker, as thereare also numerous doubly-defined symbols,
but if I use the DLL I get in the program that should use it,that program crashes at start-up - most probably
this missing symbol.
I hope this is enough information to get started with analysing the problem, as the project is rather large.
Regards,
Arjen
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The message about the missing _MAIN__ suggests that the linker is being called by the IFort compiler, and that it seems to think that an .EXE file has been requested rather than a DLL. The solution for that is to use the compiler switch /LD, or the linker switch /DLL.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a single name. The command-line showed that interpretation.
(The formatting of this option is different from the first onejust above it: for "Additional Dependencies" you do not need to insert commas between the names. There has got to be a good reason for it, but I am not
sure I like this type of seemingly arbitrary differences - just a long-standing grudge)
mecej4, thanks for pointing me to the command-line proper.
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For static libraries, I also recommend setting C++/Advanced/Libraries/Omit Default Library Names and Fortran/Libraries/Disable default Library Search Rules to "Yes" (/libdir:noauto). That basically says "don't embed information about RTL in the .lib; the final .exe/.dll will determine it". That reduces the possibility of the infamous "Multiple C library syndrome". However, if your final .exe/.dll is C++, you will have to explicitly spell your Fortran RTLs in the linker command line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I agree with Jugoslav that /IGNORE should be a last resort.
What is the value for the linker property Subsystem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I added the /force option because in the past I have noticed (but may have been wrong about the commas then too) that it was the only way to get the linker to do the job. If my memory serves me,one such occasionhad to do - among other things - with errno in a C program: this came in apparently from different libraries and no combination of ignored system libraries that I tried solved it.
Theprogram contains no QuickWin callswhatsoever.
I will see what happens without the /force option, but I can not control all the components that go into the DLL - some are external third-party libraries.
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, that's what I was afraid of. If they were built with /libdir:noauto (/Zl), you probably wouldn't have those conflicts. You can find out which libraries they pull by using
dumpbin /directives foo.lib
but I don't know of a way to strip them off, other than specifying /IGNORE or, better, /NODEFAULTLIB.
This thread has some useful stuff, though no particular cure. If you receive a badly compiled third-party library, you're probably stuck with adding linker switches.
You did not specify if it is all Fortran or there is some C++ code as well. To add salt to the wound, VC++ compiler in some cases emits different code with different RTL settings, so that even if you use /Zl there's no 100% guarantee that the .lib will play nice with code (of a different RTL setting) that uses it. Intel Fortran does not do that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I still do not completely understand how the problem arose, but I am gladwe found a cure.
My program is mainly Fortran, but it does have some Cmixed in (as well as OpenMP and MPI for
goodmeasure :)).
Regards,
Arjen

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page