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

LNK2001, static fortran, c .dll linking, help

bsoplinger
Beginner
738 Views
I'm attempting to link a static Fortran libray into a .dll to produce a shared library to be run by a third party product. Win2000, VF 6.6, VS 6.5+SP4.

I get an error:
dfor.lib(DFORMAIN.OBJ) : error LNK2001: unresolved external symbol _MAIN__

which completely baffles me as I don't have a MAIN declared within any of either the Fortran that makes up the static library I'm using, nor the C source files that make up the .dll I'm producing.

I tried adding an ignore library switch to my build for the dfor.lib but then my .dll won't execute and I don't even rate a useful error as to why it won't load/execute.

Any help would be appreciated.
0 Kudos
5 Replies
Steven_L_Intel1
Employee
738 Views
Something is referencing the symbol _main - but if your C code is using MFC, you may not see this directly. A link map would be helpful.

If you can't resolve this, please send a ZIP file of a project that demonstrates the problem to vf-support@compaq.com and we'll be glad to take a look.

Steve
0 Kudos
bsoplinger
Beginner
738 Views
I clicked the checkbox in project->settings->link->debug for a mapfile and I get a zero length file. I doubt sending that anywhere would do me any good.

Any other suggestions on what I can do?
0 Kudos
Steven_L_Intel1
Employee
738 Views
What is the setting for Project..Settings..Fortran..Libraries..Use Run-Time Libraries, and the C++..Code Generation..Libraries?

You can check the "Force" option in the Linker tab to force the DLL to be built, but I realize that the map may not help.

Can you search your .lib and .obj files for _main and see what turns up?

Steve
0 Kudos
bsoplinger
Beginner
738 Views
Thanks Steve, the hint to look at the project settings led me to a number of different runtime library settings between the C/C++ and Fortran and the library vs project I was in. Once I set them all to be threaded dll I was golden.
0 Kudos
Steven_L_Intel1
Employee
738 Views
Glad to hear it.

Steve
0 Kudos
Reply