Hi Guys,
I m with an error that a really do not understand. The code is really simple:
module grids
contains
subroutine get_conic_parameters(pts,fcl, X)
use lslrg_int, only: d_lslrg ! IMSL subroutine
implicit none
doublecomplex , intent(in) :: pts(4)
doubleprecision , intent(in) :: fcl(4)
doubleprecision , intent(out) :: X(4)
doubleprecision :: sme, A(4,4), B(4)
integer :: jk
do jk = 1, 4
sme = cdabs(pts(jk))*cdabs(pts(jk))
A(jk,1) = -dexp(-fcl(jk))
A(jk,2) = 2.0d0*dreal(pts(jk))
A(jk,3) = 2.0d0*dimag(pts(jk))
A(jk,4) = sme - 1.0d0
B(jk) = sme + 1.0d0
enddo
call d_lslrg(A,B,X)
return
end subroutine get_conic_parameters
module grids
Errors:
Error 1 error LNK2019: unresolved external symbol D_LSLRG referenced in function GRIDS_mp_GET_CONIC_PARAMETERS grids.obj
Error 2 fatal error LNK1120: 1 unresolved externals x64\Debug\OffsetShaper.exe
I use this instructions https://software.intel.com/en-us/articles/installing-and-using-the-imsl-libraries to config IMSL.
Thank you very much for help.
链接已复制
Rafael, you have two items to fix. One is to tell the the linker to search the IMSL libraries, as Steve pointed out. The second is that your call to D_LSLRG has the wrong calling sequence. The generic Fortran 90 interface has three required arguments plus more optional arguments. The Fortran 77 interface has six required arguments, whereas in your code you provide only three.
Make your choice between the F90 and F77 interfaces but, having done that, issue a call that is consistent with that choice. I suggest that you replace D_LSLRG by LSLRG in the CALL statement and the USE statement.
Dear Friends,
Thank you for answer. I made the changes suggested (change d_lslrg by lslrg), but the problem remains the same:
I don’t know if the problem is some config (I follow exactly the Steve tutorial for IMSL) or not. But, in another file solution, the same subroutine work with no problem.
Indeed, I was not using incluide 'link_fnl_shared.h' (neither in the orther solution where this subroutine works fine).
I tried put in header of main program but does not work. Is it the right place?
Thank you!
There are a number of ways of linking in the IMSL libraries, depending on whether you build at the command line or using Visual Studio. If building at the command line, adding the /Qimsl option is sufficient for most purposes.
If you are using Visual Studio, please retrieve and report the linker command line used (from the project/solution settings), or post the build log after a failed build.
Corrected code:
subroutine get_conic_parameters(pts,fcl, X)
use lslrg_int, only: lslrg
implicit none
doublecomplex , intent(in) :: pts(4)
doubleprecision , intent(in) :: fcl(4)
doubleprecision , intent(inout) :: X(4)
doubleprecision :: A(4,4), B(4)
doubleprecision :: sme, fa1, fa2, fa3, fa4, detA
integer :: jk
do jk = 1, 4
sme = cdabs(pts(jk))*cdabs(pts(jk))
A(jk,1) = -dexp(-fcl(jk))
A(jk,2) = 2.0d0*dreal(pts(jk))
A(jk,3) = 2.0d0*dimag(pts(jk))
A(jk,4) = sme - 1.0d0
B(jk) = sme + 1.0d0
enddo
call lslrg(A,B,X)
return
end subroutine get_conic_parameters
end module grids
Here the log:
Linking... Link /OUT:"x64\Debug\OffsetShaper.exe" /INCREMENTAL:NO /NOLOGO /MANIFEST /MANIFESTFILE:"x64\Debug\OffsetShaper.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\rafael.penchel\documents\visual studio 2010\Projects\OffsetShaper\OffsetShaper\x64\Debug\OffsetShaper.pdb" /SUBSYSTEM:CONSOLE /IMPLIB:"C:\Users\rafael.penchel\documents\visual studio 2010\Projects\OffsetShaper\OffsetShaper\x64\Debug\OffsetShaper.lib" "x64\Debug\quadrics.obj" "x64\Debug\grids.obj" "x64\Debug\main.obj" Link: executing 'link' grids.obj : error LNK2019: unresolved external symbol D_LSLRG referenced in function GRIDS_mp_GET_CONIC_PARAMETERS x64\Debug\OffsetShaper.exe : fatal error LNK1120: 1 unresolved externals OffsetShaper - 2 error(s), 0 warning(s) |
Thanky you very much!
I don't get errors when I build with your code, but you haven't shown the INCLUDE line for link_fnl_shared.h nor if there are any compiler errors.
Please set the project property Linker > General > Show Progress to "Display all progress messages" and rebuild. Create a ZIP of the buildlog,htm and attach it to a reply here.
You had said earlier that you put in the INCLUDE line, so I wondered why it didn't work. You have to tell the compiler/linker the names of the IMSL libraries to link to. This can be done by naming them individually in the Linker properties, or using the INCLUDE file.
Everything works now?
I think i find the problem:
In the solution where It was working corretly it was set in Linker> Input > additional dependencies imsl_dll.lib.
So, I Do this in the solution with problems and works fine without INCLUDE 'link_fnl_shared.h'.
That's it!.
Is there a best practice?
Thank you very much Steve and mecej4.
