- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I am working on a project with C++, and there is a old ordinary equation integrator named lsode written in fortran, I'd like to call its subrutine in C++.
I followed the instruction on this link to Configue Microsoft Visual Studio 2010.(vv=12 for me.)
http://software.intel.com/en-us/articles/configuring-visual-studio-for-mixed-language-applications
And then creat a solution with one C++ project and one fortran static library projbec, as in:
Set the dependency and start up project. Also explicitly provide the path to the Fortran library, in the C/C++ project's Linker > Additional Dependencies property, or as a "source file" in the project, like Steve said!
I test a "hello world! " program written in fortran and called in C++, it works perfectly!
But when I follow the procedure above and incorporate the old fortran code(a simple test), I got the error:
1>lsode_init.obj : error LNK2001: unresolved external symbol _ckstrt_
1>main.obj : error LNK2019: unresolved external symbol _chemkininitialize_ referenced in function _main
Below is my source codes:
I upload every source file, global_extern_vars.h contains the extern "C" stuff, use_chemkin.f is a wrapper to the old fortran codes.
Hope someone could help me.(I have worked on this problem for one week, my boss got unhappy with me as He bought VS2010 and intel fortran complier but I don't know how to use...). It would be really appreciated if u could help to fix it.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your program was written assuming common defaults for Fortran on Linux. The C++ code assumes that Fortran routine names are downcased and have an underscore at the end, neither of which are the defaults of Intel Visual Fortran.
Perhaps the easiest solution is to change the names of the Fortran entities in the C++ code to have uppercase names and remove the trailing underscore. Another option is to add BIND(C) attributes where appropriate, with a NAME= value that is the lowercase name with the underscore at the end. I see you have a COMMON block, so that's slightly trickier (need a BIND statement), but doable.
- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a million!!! I try all your solutions and Steve's idea works better! I simply migrate linux codes to windows which is not correct!
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page