Skip to Content.
Sympa Menu

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

Subject: CGAL users discussion list

List archive

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


Chronological Thread 
  • From: stevepny <>
  • To:
  • Subject: [cgal-discuss] Re: Compile with C++ main and Fortran module
  • Date: Tue, 26 Oct 2010 21:32:42 -0700 (PDT)


Ok, here's the output. I changed the names of all fortran function calls from
C++ to the format that worked with my own make file (without CGAL),
{moduleName}_{functionName}_

make VERBOSE=1; output:

[100%] Building CXX object CMakeFiles/local_clib.dir/local_clib.cpp.o
/usr/bin/c++ -DMOM2_ELF -frounding-math -O3 -DNDEBUG
-I/homes/metogra/spenny/localization/../../include
-I/homes/metogra/spenny/localization -I/homes/metogra/spenny/mpfr/include
-I/homes/metogra/spenny/gmp/include -I/homes/metogra/spenny/boost_1_44_0
-I/homes/metogra/spenny/CGAL-3.6.1/include -o
CMakeFiles/local_clib.dir/local_clib.cpp.o -c
/homes/metogra/spenny/localization/local_clib.cpp
Linking CXX executable local_clib
/homes/metogra/spenny/cmake/bin/cmake -E cmake_link_script
CMakeFiles/local_clib.dir/link.txt --verbose=1
/usr/bin/c++ -frounding-math -O3 -DNDEBUG
CMakeFiles/local_clib.dir/local_clib.cpp.o -o local_clib -rdynamic
-L/homes/metogra/spenny/CGAL-3.6.1/lib
-L/homes/metogra/spenny/boost_1_44_0/libs
-L/homes/metogra/spenny/boost_1_44_0/stage/lib libmom2_elf.a libmom2_io.a
/homes/metogra/spenny/CGAL-3.6.1/lib/libCGAL_Core.so
/homes/metogra/spenny/CGAL-3.6.1/lib/libCGAL.so
/homes/metogra/spenny/mpfr/lib/libmpfr.so
/homes/metogra/spenny/gmp/lib/libgmp.so
/homes/metogra/spenny/boost_1_44_0/stage/lib/libboost_thread.so
/homes/metogra/spenny/CGAL-3.6.1/lib/libCGAL_Core.so
/homes/metogra/spenny/CGAL-3.6.1/lib/libCGAL.so
/homes/metogra/spenny/mpfr/lib/libmpfr.so
/homes/metogra/spenny/gmp/lib/libgmp.so
/homes/metogra/spenny/boost_1_44_0/stage/lib/libboost_thread.so
-lgfortranbegin -lgfortran
-Wl,-rpath,/homes/metogra/spenny/CGAL-3.6.1/lib:/homes/metogra/spenny/boost_1_44_0/libs:/homes/metogra/spenny/boost_1_44_0/stage/lib:/homes/metogra/spenny/mpfr/lib:/homes/metogra/spenny/gmp/lib

CMakeFiles/local_clib.dir/local_clib.cpp.o: In function `main':
local_clib.cpp:(.text+0xb1b): undefined reference to
`letkfio_get_nobs_letkf_'
local_clib.cpp:(.text+0x1323): undefined reference to
`letkfio_read_obs_letkf_'
local_clib.cpp:(.text+0x1f69): undefined reference to
`letkfio_write_obs_letkf_'
local_clib.cpp:(.text+0x20f7): undefined reference to
`letkfio_write_obs_letkf_'
collect2: ld returned 1 exit status
make[2]: *** [local_clib] Error 1
make[2]: Leaving directory `/homes/metogra/spenny/localization'
make[1]: *** [CMakeFiles/local_clib.dir/all] Error 2
make[1]: Leaving directory `/homes/metogra/spenny/localization'
make: *** [all] Error 2

===================================================
The "undefined references" occur when the main program local_clib.cpp tries
to call the fortran 90 subroutines.

===================================================
Just for reference, here's my Makefile that worked cross compiling C++ and
Fortran90 using boost libraries, but without CGAL:

# Linker:
LN = g++
# F90 compiler
#F90 = pgf90
F90 = gfortran
# C++ compiler
CPP = g++

# Boost libraries:
CPPLIB = -L/homes/metogra/spenny/boost_1_44_0/stage/lib -lboost_date_time
# Fortran run time libraries:
F90LIB = -L/misc/local64/pgi-9.0.2/linux86-64/9.0-2/lib -lpgf90 -lpgf90_rpm1
-lpgf902 -lpgf90rtl -lpgftnrtl -lnspgc -lpgc -lrt -lpthread -lm -lgcc -lc
-lgcc
CPPINC = -I/homes/metogra/spenny/boost_1_44_0
F90INC =

local_exe.x : letkfio.o local_clib.o
$(LN) $? -o $@ $(F90LIB) $(CPPLIB) $(CPPINC)

clean :
rm *.o *.x *.mod

local_clib.o : letkfio.o local_clib.cpp
$(CPP) $(CPPLIB) $? -c $(CPPINC)
letkfio.o : letkfio.f90
$(F90) $(F90LIB) $? -c $(F90INC)

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



Archive powered by MHonArc 2.6.16.

Top of Page