- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Igot stuck with the following problem: I have a library with C and Fortran routines and that needs
to be turned into a DLL. Visual Studio does not allow me to combine sources in different languages
in one project, whereas Developer Studio did. So, I have created two projects, one for the C part
and one for the Fortran part.
However, the C part contains some routines that are also used in the Fortran part, so I have
a sort of cyclic dependency that is relevant at link time.
I thought I could avoid splitting off these common routines into a third part, by compiling the
Fortran routines into a static library and linking that library together with the C routines into
a DLL.
That does not work, however: libifcoremt.lib is missing a MAIN__ routine. So, unless I can
persuade the linker that that is not necessary (under Linux I need to specify -nofor_main
to do that, but Windows has no such option)I have to goto the other solution.
My question: Is that indeed the _only_ way?
(Hopefully I have described the problem clear enough ;))
Regards,
Arjen
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Fortran routines. So they are common to both sets.
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
(To be clear - you've got a fortran project that builds a static library and then a C project that builds a DLL that references the fortran project? If so - make sure the run time library settings are consistent between the two and let the C project know where the Fortran runtime libraries directory is and all should be merry. The cyclic dependency thing shouldn't matter at link time.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have changed the following (apart from macros that are used by the C code):
- Additional library path to find the Fortran runtime libraries
- Additional library ifconsol.lib, because otherwise I got a message that it could not find that library
(this is due to the Fortran source being compiled as a static library, I guess)
- The option /force, as otherwise the linker trips over multiply defined symbols
The Fortran project uses defaults only (except for a path to some include files).
The error message is:
LIBCMT.lib(crt0init.obj) : warning LNK4006: ___xc_a already defined in MSVCRT.lib(cinitexe.obj); second definition ignored
LIBCMT.lib(crt0init.obj) : warning LNK4006: ___xc_z already defined in MSVCRT.lib(cinitexe.obj); second definition ignored
LIBCMT.lib(tolower.obj) : warning LNK4006: _tolower already defined in MSVCRT.lib(MSVCR90.dll); second definition ignored
LIBCMT.lib(_file.obj) : warning LNK4006: ___iob_func already defined in MSVCRT.lib(MSVCR90.dll); second definition ignored
LIBCMT.lib(osfinfo.obj) : warning LNK4006: __get_osfhandle already defined in MSVCRT.lib(MSVCR90.dll); second definition ignored
LIBCMT.lib(osfinfo.obj) : warning LNK4006: __open_osfhandle already defined in MSVCRT.lib(MSVCR90.dll); second definition ignored
libifcoremt.lib(for_main.obj) : error LNK2019: unresolved external symbol _MAIN__ referenced in function _main
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
(It is probably easier to yield and split up the C sources into two projects, but it feels like
defeat - one simple library becoming three interdependent DLLs)
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a mixed C/Fortran solution which builds a dll
The Fortran project creates a lib in $(Outdir)($(ProjectName).lib
where Outdir is $(Configuration) which would be debug or release
Fortran -> Libraries -> Runtime Library Multithread DLL
The C Project has :
C/C++ -> Code Generation -> Runtime library Multi-threaded DLL
The linker step has output file
Link Library Dependencies = Yes
Additional Library Directories =
Input-> Additional dependencies -- here I added the fortran lib from above plus other used libs
So it should work ok for you
Les
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maybe I should try this first with a smaller example.
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
multithreaded DLL.
I can not find any object file that references "libcmt" ... that is, the reference was in another C library
that I needed to include (that was already available as aDLL, but I had chosen the wrong dependency
so ended up with the static library instead).
Solved! Thanks for all the replies. This was a real puzzle, but of course, if you look in the wrong place
it is unlikely that you find the cause of the problem.
Regards,
Arjen
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page