- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to use Sam Leffler's libtiff library to read/write tiff files from Fortran. I have built the library with icl, and the test programs work. I have also tested calling a C procedure from Fortran. Now I have some test C code (my_write.cpp) which I compile with icl to my_write.obj, and a Fortran program ftest.f90 which calls the C procedure. All seems OK until I try to link these two with libtiff.lib. I've tried it from the command line (in which case the linker complains about multiply defined symbols, and tells me to use /NODEFAULTLIB:MSVCRT, but that gives far more errors), and from within VS, but that gives a lot of "unresolved external symbol" errors.
It would be great if someone has already figured out how to link to libtiff.lib, otherwise I'd appreciate more general advice about linking to a C-created library.
Thanks
Gib
It would be great if someone has already figured out how to link to libtiff.lib, otherwise I'd appreciate more general advice about linking to a C-created library.
Thanks
Gib
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - gib
I'm trying to use Sam Leffler's libtiff library to read/write tiff files from Fortran. I have built the library with icl, and the test programs work. I have also tested calling a C procedure from Fortran. Now I have some test C code (my_write.cpp) which I compile with icl to my_write.obj, and a Fortran program ftest.f90 which calls the C procedure. All seems OK until I try to link these two with libtiff.lib. I've tried it from the command line (in which case the linker complains about multiply defined symbols, and tells me to use /NODEFAULTLIB:MSVCRT, but that gives far more errors), and from within VS, but that gives a lot of "unresolved external symbol" errors.
It would be great if someone has already figured out how to link to libtiff.lib, otherwise I'd appreciate more general advice about linking to a C-created library.
It would be great if someone has already figured out how to link to libtiff.lib, otherwise I'd appreciate more general advice about linking to a C-created library.
What does
/dumpbin:directives libtiff.lib
(ran from Ifort command prompt) say about defaultlibs?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Jugoslav Dujic
What does
/dumpbin:directives libtiff.lib
(ran from Ifort command prompt) say about defaultlibs?
dumpbin /directives libtiff.lib
and gives a great deal of info, most of it repeating the same thing many times. I've attached the output. Does this help?
Should I be trying to build my program at the command line or in VS?
Would it be easier to combine libtiff.lib and my_write.c as a DLL?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Jugoslav Dujic
What does
/dumpbin:directives libtiff.lib
(ran from Ifort command prompt) say about defaultlibs?
link ftest.obj my_write.obj libtiff.lib
Since libtiff uses -defaultlib:"MSVCRT" I thought I should look at the other object files:
Dump of file ftest.obj
File Type: COFF OBJECT
Linker Directives
-----------------
-defaultlib:"ifconsol"
-defaultlib:"libifcoremt"
-defaultlib:"libifport"
-defaultlib:"libmmt"
-defaultlib:"LIBCMT"
-defaultlib:"libirc"
-defaultlib:"svml_disp"
-defaultlib:"OLDNAMES"
-defaultlib:"ifconsol"
-defaultlib:"libifcoremt"
-defaultlib:"libifport"
-defaultlib:"libmmt"
-defaultlib:"LIBCMT"
-defaultlib:"libirc"
-defaultlib:"svml_disp"
-defaultlib:"OLDNAMES"
Dump of file my_write.obj
File Type: COFF OBJECT
Linker Directives
-----------------
-defaultlib:"libmmt"
-defaultlib:"LIBCMT"
-defaultlib:"libirc"
-defaultlib:"svml_disp"
-defaultlib:"OLDNAMES"
-defaultlib:"libmmt"
-defaultlib:"LIBCMT"
-defaultlib:"libirc"
-defaultlib:"svml_disp"
-defaultlib:"OLDNAMES"
It seems that while libtiff.lib uses msvcrt, the other object files both use libcmt. I'm guessing that I need to compile libtiff.lib so that it uses libcmt. Is this correct? I wonder how I can do that ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I changed the makefile for libtiff.lib to get icl to use /MT and lib to use /NODEFAULTLIB:"msvcrt". Now I see libcmt in the dumpbin output for libtiff.lib, and my code links and runs successfully.
Thanks for the pointer.
Thanks for the pointer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - gib
I changed the makefile for libtiff.lib to get icl to use /MT and lib to use /NODEFAULTLIB:"msvcrt". Now I see libcmt in the dumpbin output for libtiff.lib, and my code links and runs successfully.
Thanks for the pointer.
Thanks for the pointer.
You're welcome -- y'know, different time zones :-).
You found one solution to the problem, i.e. build the lib and exe with same C run-time library. I'd rather try building the library with /Zl (Omit Default Library Name) -- not to save space, but to strip those nasty references to libm*.lib from the library. Tentatively, in this way you should be able to build the library with any RTL setting of the exe (although MSVC++ has some ugly features which might prevent that).

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page