<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hi,<br>
<br>
I am trying to link a fortran/c++ executable. main() is in the fortran file. cmake is choosing to "Link CXX executable" rather than fortran executable?<br>
<br>
Based upon my current CMakeLists.txt file, cmake is choosing the wrong linker. <br>
<br>
I can in fact cut and paste the cmake link line and replace 'mpicxx' with the correct compiler/linker ('mpif77') and it works just fine.<br>
<br>
Here is the relevant CMakeLists.txt piece; main is in the file demo_cf_pointer.F90; I_Fortran is a c++ library; I am using the intel compilers.<br>
<br>
# CMakeLists.txt file<br>
add_executable(demo_cf_pointer demo_cf_pointer.F90)<br>
target_link_libraries(demo_cf_pointer I_Fortran -lstdc++)<br>
<br>
<br>
<br>
Here is the output from the linker; It is using my mpicxx compiler; Also note that the link line contains demo_cf_pointer.F90.o which indicates to me that it successfully found the mpif77 compiler that I am using. I know it is because I can re-use this entire
command with mpicxx replace with mpif77 to produce a valid executable.<br>
<br>
<br>
CMAKE OUTPUT<br>
Linking CXX executable demo_cf_pointer<br>
cd /ascldap/users/jamitch/pditi_projects/pditi.build/i_fortran/demo && /projects/sierra/linux/install/cmake/2.8.1/bin/cmake -E cmake_link_script CMakeFiles/demo_cf_pointer.dir/link.txt --verbose=1<br>
/ascldap/users/jamitch/pditi_projects/TPL/mpich2-1.4.1p1_installed/bin/mpicxx -cxx=icpc -mkl -O0 -g -Wall CMakeFiles/demo_cf_pointer.dir/demo_cf_pointer.F90.o -o demo_cf_pointer -rdynamic -L/ascldap/users/jamitch/pditi_projects/TPL/trilinos_dev.installed/lib
-L/ascldap/users/jamitch/pditi_projects/TPL/vtk-5.8-installed/lib/vtk-5.8 -L/ascldap/users/jamitch/pditi_projects/TPL/boost_1_48_0_installed/lib ../libI_Fortran.a -lstdc++ -lifport -lifcore -lintlc -Wl,-rpath,/ascldap/users/jamitch/pditi_projects/TPL/trilinos_dev.installed/lib:/ascldap/users/jamitch/pditi_projects/TPL/vtk-5.8-installed/lib/vtk-5.8:/ascldap/users/jamitch/pditi_projects/TPL/boost_1_48_0_installed/lib
<br>
/usr/local/intel/parallel_studio_XE/composerxe-2011.4.191/compiler/lib/intel64/libimf.so: warning: warning: feupdateenv is not implemented and will always fail<br>
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crt1.o: In function `_start':<br>
(.text+0x20): undefined reference to `main'<br>
make[2]: *** [i_fortran/demo/demo_cf_pointer] Error 1<br>
<br>
<br>
Thanks,<br>
John<br>
<br>
<br>
</div>
</body>
</html>