[CMake] FW: building a mixed language programm with CMake
Natalie Happenhofer
nataliehapp at hotmail.com
Wed Jun 10 07:54:01 EDT 2009
The error has changed ;-) No seriously, I stll get an error buiding with CMake:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
Building from the command line works perfect, so I looked what libraries the executable is linked to:
linux-vdso.so.1 => (0x00007fff331ff000)
libgfortran.so.1 => /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/libgfortran.so.1 (0x00007ff22ac5e000)
libstdc++.so.6 => /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/libstdc++.so.6 (0x00007ff22a962000)
libm.so.6 => /lib/libm.so.6 (0x00007ff22a6e1000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007ff22a4d4000)
libc.so.6 => /lib/libc.so.6 (0x00007ff22a195000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff22aef7000)
The only library I tell CMake to link to is libgfortran.so. What libraries does CMake usually link to, without specifying?
greets,
Natalie
> Date: Wed, 10 Jun 2009 02:38:58 -0700
> From: denis_scherbakov at yahoo.com
> Subject: RE: [CMake] FW: building a mixed language programm with CMake
> To: nataliehapp at hotmail.com
> CC: cmake at cmake.org
>
>
> > Thanks, that helped, but I still have troubles to set the
> > options right:
> > Compiling my code "manually", it takes the
> > following commands:
> >
> > gfortran -c hello.f90
> > g++ -lgfortran hello.o test.cxx -o test
>
> Actually this should look like:
> gfortran -c hello.f90
> g++ -c test.cxx
> g++ -lgfortran hello.o test.o -o test
>
> > Well, that´s my CMakeLists.txt for now:
> >
> > cmake_minimum_required(VERSION 2.4)
> > project(TEST Fortran)
> >
> > SET(TEST_SRCS test.cxx)
> > SET(OBJECTS hello.f90)
>
> You need to work only with sources. Forget about object files.
> Here is your CMakeLists.txt:
>
> CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
> PROJECT(TEST Fortran)
>
> SET(TEST_SRCS test.cxx hello.f90)
>
> ADD_EXECUTABLE(test ${TEST_SRCS})
> TARGET_LINK_LIBRARIES(test gfortran)
>
>
> # NOT NEDDED: SET_TARGET_PROPERTIES(hi PROPERTIES LINKER_LANGUAGE C)
> # NOT NEEDED: CMAKE_EXE_LINKER_FLAGS: -lgfortran -o
> # Only if you have one more fortran compiler: CMAKE_Fortran_COMPILER: /usr/bin/gfortran
> # NOT NEEDED: CMAKE_Fortran_FLAGS: -c
>
> > which looks fine, but if my executable is build, where does
> > it go? I set the EXECUTABLE_OUTPUT_PATH to the directory
> > I´m working in,
> > but the executable "hi" does not show up..
>
> Compiled executable now is in build directory. In your case it should
> be in current directory.
>
> Please, reply to all, so CMake mailing list gets also included.
>
> Denis
>
>
>
>
_________________________________________________________________
Prueba los mejores juegos online en MSN
http://juegos.latam.msn.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090610/0a686bca/attachment.htm>
More information about the CMake
mailing list