Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

LNK2001

Deleted_U_Intel
Employee
613 Views
I am trying to write a simple dll file which calls a routine from Nag's Fortran Library mark 17. Unfortunately I am not meeting with much success. My code is as follows:

DOUBLE PRECISION FUNCTION TEST(X)
! Expose subroutine nagdll to users of this DLL
!
!DEC$ ATTRIBUTES DLLEXPORT::TEST
* .. Local Scalars ..
DOUBLE PRECISION X
* .. External Functions ..
DOUBLE PRECISION G05CAF
EXTERNAL G05CAF
* .. External Subroutines ..required to initialize Function
EXTERNAL G05CBF
* .. Executable Statements ..
CALL G05CBF(3)
*
TEST = G05CAF(X)
*
*
END

The idea here is just to confirm that this can be done. The code compiles
fine but the build stage returns the following errors:

NAGLIB.LIB(x02ajft.obj) : error LNK2001: unresolved external symbol __FFljj
NAGLIB.LIB(g05cbft.obj) : error LNK2001: unresolved external symbol __FFljj
NAGLIB.LIB(g05caft.obj) : error LNK2001: unresolved external symbol __FFljj
NAGLIB.LIB(g05cazt.obj) : error LNK2001: unresolved external symbol __FFljj
NAGLIB.LIB(g05cayt.obj) : error LNK2001: unresolved external symbol __FFljj
Debug/nagdll.dll : fatal error LNK1120: 1 unresolved externals

If I append a little main program which calls the function and compile it as
a console application then everything works fine and it builds and runs as
expected. I've played about with this for a while trying to follow some
suggestions from the help but I haven't met with any success. I suspect it
is a simple enough option change or a missing line of code or two and would appreciate any help in informing me of what action to take.

Thanks,
Don.
0 Kudos
2 Replies
Jugoslav_Dujic
Valued Contributor II
613 Views
It seems that the error you get has little or nothing to do with your code. LNK2001s you get indicate that Naglib.lib links to missing imports. Now, I don't know anything about that library; however, you should check "Link/Object-library modules" on project settings to ensure that all necessary libraries are there. Possibly these settings differ for the dll in question and console app you mention.

Jugoslav
0 Kudos
Intel_C_Intel
Employee
613 Views
Thanks for your help guys. I sorted the problem out by just arbitrarily varying the options. The library was correctly referenced in the linker options so I didn't need to change that. What I did change were the options in the Fortran/Libraries/Fortran Libraries section to the following:

I ticked Use Multi Threaded Library
Reentrancy Support: Threaded
Use Run-time libraries: Static*

This did the job. Thanks again for the help....it was the comparison of options between the console project and the dll project that set me off.

Don.
0 Kudos
Reply