- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am trying to build a DLL using Intel Fortran 11.1 and MSVC 9.0 that combines
C and Fortran routines.
Since I can not put all the source files in the same project, I have aproject with
the C source files that will build into a DLL and a project with the Fortran files that
will deliver an ordinary library. This gets included in the DLL.
When I compile and link this, I get the error message that _MAIN__ is missing.
The DLL is still created because of the /force option. So far so good.
Using it in a small test program, however, causes the program to fail: it was not
initialised properly.
This has to do with the runtime libraries I have selected for the Fortran library:
Multithreaded, instead of "Multithreaded, DLL".
If I choose the latter, the program does work, but then I get dependencies on
a host ofIntel Fortran libraries, such as libifcoremd.dll. This is something I
want to prevent.
I can turn the Fortran library into a DLL, but then I have two DLLs to worry
about instead of one. I would like to keep both the C and the Fortran routines
in one single DLL.
Is that possible or am I doomed tocreate separate DLLs?
Regards,
Arjen
PS I hope I have described the problem clear enough. I could probably
create a small example of the problem, but I have nottaken the time yet.
I am trying to build a DLL using Intel Fortran 11.1 and MSVC 9.0 that combines
C and Fortran routines.
Since I can not put all the source files in the same project, I have aproject with
the C source files that will build into a DLL and a project with the Fortran files that
will deliver an ordinary library. This gets included in the DLL.
When I compile and link this, I get the error message that _MAIN__ is missing.
The DLL is still created because of the /force option. So far so good.
Using it in a small test program, however, causes the program to fail: it was not
initialised properly.
This has to do with the runtime libraries I have selected for the Fortran library:
Multithreaded, instead of "Multithreaded, DLL".
If I choose the latter, the program does work, but then I get dependencies on
a host ofIntel Fortran libraries, such as libifcoremd.dll. This is something I
want to prevent.
I can turn the Fortran library into a DLL, but then I have two DLLs to worry
about instead of one. I would like to keep both the C and the Fortran routines
in one single DLL.
Is that possible or am I doomed tocreate separate DLLs?
Regards,
Arjen
PS I hope I have described the problem clear enough. I could probably
create a small example of the problem, but I have nottaken the time yet.
Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If _MAIN__ is missing, clearly one or other of the projects you are trying to build must be set up as an .EXE (WIN32 application), so it is looking for a PROGRAM ...end PROGRAM section of code somewhere in your project files.
Does the C compiler produce COFF object files? If so, they should be no different from the ones produced by the Fortran compiler for a Windows application, and can therefore be included in the Fortran library project and they will then be linked in to the library.
Does the C compiler produce COFF object files? If so, they should be no different from the ones produced by the Fortran compiler for a Windows application, and can therefore be included in the Fortran library project and they will then be linked in to the library.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The main program is written in C, so it does not know anything about _MAIN__.
But the Fortran library refers to _MAIN__ via the runtime libraries it refers to.
Regards,
Arjen
But the Fortran library refers to _MAIN__ via the runtime libraries it refers to.
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What C compiler are you using? I can only echo this found in a C-programming forum
"The last bizarre type of linker error is a complain about an "undefined reference to main". This particular linker error differs from the other in that it may have nothing to do with including object files or having the correct paths to your libraries. Instead, it means that the linker tried to create an executable and couldn't figure out where the main() function was located. This can happen if you forget to include the main function at all, or if you attempt to compile code that was never meant to be a stand-alone executable (for instance, if you tried to compile a library)."
"The last bizarre type of linker error is a complain about an "undefined reference to main". This particular linker error differs from the other in that it may have nothing to do with including object files or having the correct paths to your libraries. Instead, it means that the linker tried to create an executable and couldn't figure out where the main() function was located. This can happen if you forget to include the main function at all, or if you attempt to compile code that was never meant to be a stand-alone executable (for instance, if you tried to compile a library)."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
MS Visual C/C++ 9.0
The only change froma successful build is the use of the multithreaded (static) libraries instead of
the DLL versions.
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If your Fortran project is the normal /MT, the companion C++ project should be set to that mode as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hm, I will try that - thanks
Regards,
Arjen
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tim,
this does indeed work! Thanks for the advice.
Regards,
Arjen
this does indeed work! Thanks for the advice.
Regards,
Arjen

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