Mixted C++/Fortran library on Windows [resolved]

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Mixted C++/Fortran library on Windows [resolved]

Francis Giraldeau
I just wanted to share a solution for mixing C++ and Fortran programs
on Windows using Visual Studio and Intel Fortran. The build was
failing at link time with undefined symbols comming from fortran code.
Actually, none of the fortran sources were compiled, even though it
was working fine on Linux using Makefiles.

When generating a shared library with both fortran and c++ sources like this:

    add_library(mix foo.f bar.cpp)

It produces the following .vcxproj (snippet):

    <ClCompile Include="C:\path\to\foo.f" />
    <None Include="C:\path\to\bar.cpp" />

The None compiler, well, does nothing.

The trick is to create two libraries, one for C++ code and the other
for the fortran code:

    add_library(foo foo.f)
    add_library(bar bar.cpp)

Then, both .vcxproj and .vfproj gets created and the fortran code is compiled.

It might be useful to document it somewhere. Perhaps it is already
documented and I haven't found it?



Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe: