PDA

View Full Version : Stumped by Link Error


kturok
01-08-2004, 04:57 PM
I have a large legacy fortran project that I have successfully ported to the latest version of Lahey Fortran. I have just added a new subroutine to the project, and I have added calls to it throughout the pre-existing subs. Now when I compile the project, I get two errors:

Error LNK2001: unresolved external symbol _writelog_
Fatal error LNK1120: 1 unresolved externals

The new subroutine is not exported, but I have tried importing it into the calling procedures with the same technique used when calling exported procedures to no avail. Any assistance is greatly appreciated.

Lahey Support
01-12-2004, 05:59 PM
This might require a little more information.
If the calling procedure and the called procedure are both in a DLL (as implied by the "import-export" comments), then if the called procedure is not exported, the calling procedure should not import it. If the called procedure is exported, the calling procedure should import it.
If the calling procedure is outside the DLL, you will have to export the called procedure.

kturok
01-12-2004, 06:22 PM
Both subroutines are in the same dll. Subroutine 1 is exported and Subroutine 2 is not. Subroutine 1 calls Subroutine 2 internally. Would it be better to try to remove Subroutine 2 and place it in its own dll and then import it into subroutine 1?

Lahey Support
01-12-2004, 06:37 PM
You don't need to remove subroutine 2, just remove the import statement for it in subroutine 1. When procedures are all inside a DLL, don't import anything that hasn't been exported. You can call a procedure that hasn't been exported using regular Fortran, without the import/export stuff.

kturok
01-12-2004, 06:58 PM
that is precisely my problem, there is no import statement for subroutine 2 in subroutine 1! There doesn't seem to be any reason for it not to work.

tzeis
01-13-2004, 09:56 PM
Can you post a small example that demonstrates the problem? That would make it a lot easier to zero in on the cause.