Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Compile with C++ main and Fortran module

Subject: CGAL users discussion list

List archive

[cgal-discuss] Compile with C++ main and Fortran module


Chronological Thread 
  • From: stevepny <>
  • To:
  • Subject: [cgal-discuss] Compile with C++ main and Fortran module
  • Date: Mon, 25 Oct 2010 00:23:08 -0700 (PDT)


Hi I'm a PhD student at the University of Maryland jointly working in the
Applied Mathematics and Scientific Computing department and the Atmospheric
and Oceanic Sciences department. I'm trying to utilize GCAL for data
assimilation (combining computer models of a dynamical system with physical
observations to generate more accurate initial conditions and better
forecasts).

Step 3 below is where I got stuck...

Step 1) I'm linking a main C++ routine with an F90 module to read and write
data. I've worked out the data transfer and can compile a C++ main program
calling a F90 module using a basic make file.
Step 2) I've loaded and installed the CGAL. It is compiled using cmake. My
test programs with CGAL compile and work ok.
*Step 3) I need to use cmake to compile and link the C++ main routine with
the F90 module and include the CGAL (and Boost) C++ libraries.

Step 4) I believe it would be more complicated, but I'd really like to be
able to call CGAL routines from inside my F90 main program. Right now I am
doing it externally in C++ and inputting the results via data files during
execution of the F90 main program.

=============
Here is my attempt:
(The CMakeList.txt file)
=============

# Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application.

# To indicate that this is mixed language project
PROJECT( mom2_elf CXX Fortran )

# C++ files
SET(CXX_TEST_SRCS local_clib.cpp)

# Fortran files
SET(FORT_TEST_SRCS letkfio.f90)

ADD_DEFINITIONS(-DMOM2_ELF)

ADD_LIBRARY(mom2_io ${FORT_TEST_SRCS} )
ADD_LIBRARY(mom2_elf ${CXX_TEST_SRCS} )

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0)

# Link the o files
target_link_libraries(mom2_elf mom2_io)

# To explicitly specify that your MAIN is C++'s main.
SET_TARGET_PROPERTIES(mom2_elf PROPERTIES LINKER_LANGUAGE CXX)

set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)

if ( COMMAND cmake_policy )
cmake_policy( SET CMP0003 NEW )
endif()

find_package(CGAL QUIET COMPONENTS Core )

if ( CGAL_FOUND )

include( ${CGAL_USE_FILE} )

include( CGAL_CreateSingleSourceCGALProgram )

include_directories (BEFORE ../../include)

create_single_source_cgal_program( "local_clib.cpp" )

else()

message(STATUS "This program requires the CGAL library, and will not be
compiled.")

endif()


=============
With the error upon running 'make':
=============

Linking CXX executable local_clib
CMakeFiles/local_clib.dir/local_clib.cpp.o: In function `main':
local_clib.cpp:(.text+0xb1b): undefined reference to `get_nobs_letkf'
local_clib.cpp:(.text+0x1323): undefined reference to `read_obs_letkf'
local_clib.cpp:(.text+0x1f69): undefined reference to `write_obs_letkf'
local_clib.cpp:(.text+0x20f7): undefined reference to `write_obs_letkf'
collect2: ld returned 1 exit status
make[2]: *** [local_clib] Error 1
make[1]: *** [CMakeFiles/local_clib.dir/all] Error 2
make: *** [all] Error 2

=============
NOTE:
The 'undefined reference's are all from the F90 module.
=============

I'd appreciate any assistance greatly.
Thanks,
Steve

--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Compile-with-C-main-and-Fortran-module-tp3009841p3009841.html
Sent from the cgal-discuss mailing list archive at Nabble.com.



Archive powered by MHonArc 2.6.16.

Top of Page