- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think you should rely on the ISO C binding and not on the ATTRIBUTES compiler directives. First of all, because the directives are not part of the Fortran standard, but more importantly because the combination might cause confusion.
Judging from the description you gave it could be something like (untested):
logical*4 function c_get_tiff_size( fullname, nrows, ncols ) bind(C, name="c_get_tiff_size")
character(len=1) :: fullname(*)
integer :: nrows, ncols
end function c_get_tiff_size
Notes:
- logical*4 and integer*4 are extensions
- the string fullname should be ending in a char(0) at the caller's side
- strings are passed as if they are character(len=1) arrays instead of strings.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the quick response @Arjen_Markus. I have tried the adjusted interface with no luck I'm afraid. Any other ideas happily received though!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you rebuild the C library as an x64 application? if not, you are probably correct that the 32bit .lib will not work with a x64 Fortran object or library.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks @Ron_Green for your reply. Yes I built the C lib in 64bit. Anything else I can try/test?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The external symbol c_get_tiff_size is available in the object file ReadTiff.obj. Therefore, check in your project settings and check the linker command to see if ReadTiff.obj is being included in the list of files to be linked. I do not see more than just one mention of ReadTiff.obj in your post, which raises my suspicion that the linker command is perhaps in need of correction.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your input @mecej4 .
The library containing c_get_tiff_size.obj is called FMIS.lib and I have placed a copy of the release version in the folder of the main project (called FMIS) and my linker settings for the main project are as follows (Visual Studio 2019) :
I am not that familiar with linker settings so maybe I may have made an error somewhere? I added the full path for the FMIS-C library in the Fortran settings but not sure if it is required (but seems to make no difference).
Thanks, Sonia
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>The library containing c_get_tiff_size.obj is called FMIS.lib and I have placed a copy of the release version in the folder of the main project
Did you move the 32-bit or 64-bit .obj?
And, if that is referencing a .dll, did you also move the .dll into the folder where the .exe was built? (or current directory of debug session).
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @jimdempseyatthecove , thanks for your input.
I just attempted to build the project with the x64\Debug folder containing:
the release version .obj files from the FMIS-C project,
the release version FMIS-C.lib,
the 4 x DLLs that the FMIS-C project references.
Unfortunately I am still getting the same errors. Presumably if there was a problem with the DLLs it would have appeared when I built the FMIS-C project.
I am running out of ideas...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
linker > general > show progress (/verbose) show a listing of what the linker is doing. That should illuminate matters.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks @andrew_4619 .
The additional output I received from changing the linker setting is telling me that the linker can find the the c routines, and 'references' them but does not load the FMIS-C library as it does for odbc.lib which follows it.
Any ideas on where this should point me?
Many thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your interface is questionable, for example on the C side nrows and ncols are pointers so it is expecting a memory address to be passed by value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@andrew_4619 I tried passing in loc(nrows) and loc(ncols) values etc but the error remained.
The error is received on all of the C routines (all have various items passed in - not all pointers) so I think my error is a broadscale one. The fact that all of my C code runs error free in 32bit also indicates that it is something generic to all of the c code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not the person to help with this my knowledge and usage of C is minimal. However create a new simple routine in your c file e with a void function that passes nothing, interface and call it on the Fortran side and see if that links....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the suggestion @andrew_4619 .
I added a simple void function that takes no parameters, and referenced it in my Fortran code. It's name (myVoidFunction) now appears in the Linker's error list along with all of the original C routines :
This seems to indicate that the issue is affecting all C code, regardless of referencing style or parameters being passed in or not (unless something else could be "muddying the waters")?
I will perhaps try creating a whole new C project with only the void function and see where that takes me as i seem to be running out of options
![](/skins/images/C4F7392A5C68ACA60290C9576F107044/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page