Hello Natalie,
the linkstep in your makefile tries to create a complete program
out of hello.o, but the main program is in test.o.
In the PLplot project (http://plplot.sf.net) we have a similar
configuration: different programming languages that need to
be combined. The approach we take is:
- create a library (static or dynamic) from the sources in one
programming language
- create programs using these separate libraries
While I can not come up right now with the ready made CMakeLists.txt
file, I think that is the way to do it:
- turn hello.f90 into a library (say libhello.a)
- create the program from test.cpp using that library as a dependency.
Regards,
Arjen
On 2009-06-10 15:31, Natalie Happenhofer wrote:
Hi!
I have run the commands:
$ nm test.o
U __gxx_personality_v0
U hello1_
0000000000000000 T main
$ nm hello.o
U _gfortran_st_write
U _gfortran_st_write_done
U _gfortran_transfer_character
0000000000000000 T hello1_
$ make VERBOSE=1
/usr/bin/cmake -H/home/happenhofer/versuche/CMake_tryout/Fortran
-B/home/happenhofer/versuche/CMake_tryout/Fortran --check-build-system
CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start
/home/happenhofer/versuche/CMake_tryout/Fortran/CMakeFiles
/home/happenhofer/versuche/CMake_tryout/Fortran/CMakeFiles/progress.make
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory
`/home/happenhofer/versuche/CMake_tryout/Fortran'
make -f CMakeFiles/hi.dir/build.make CMakeFiles/hi.dir/depend
make[2]: Entering directory
`/home/happenhofer/versuche/CMake_tryout/Fortran'
cd /home/happenhofer/versuche/CMake_tryout/Fortran && /usr/bin/cmake -E
cmake_depends "Unix Makefiles"
/home/happenhofer/versuche/CMake_tryout/Fortran
/home/happenhofer/versuche/CMake_tryout/Fortran
/home/happenhofer/versuche/CMake_tryout/Fortran
/home/happenhofer/versuche/CMake_tryout/Fortran
/home/happenhofer/versuche/CMake_tryout/Fortran/CMakeFiles/hi.dir/DependInfo.cmake
--color=
make[2]: Leaving directory `/home/happenhofer/versuche/CMake_tryout/Fortran'
make -f CMakeFiles/hi.dir/build.make CMakeFiles/hi.dir/requires
make[2]: Entering directory
`/home/happenhofer/versuche/CMake_tryout/Fortran'
make[2]: Nothing to be done for `CMakeFiles/hi.dir/requires'.
make[2]: Leaving directory `/home/happenhofer/versuche/CMake_tryout/Fortran'
make -f CMakeFiles/hi.dir/build.make CMakeFiles/hi.dir/build
make[2]: Entering directory
`/home/happenhofer/versuche/CMake_tryout/Fortran'
Linking Fortran executable hi
/usr/bin/cmake -E cmake_link_script CMakeFiles/hi.dir/link.txt --verbose=1
/usr/bin/gfortran -fPIC CMakeFiles/hi.dir/hello.o -o hi -rdynamic
-lgfortran
/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../lib64/crt1.o: In
function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
make[2]: *** [hi] Error 1
make[2]: Leaving directory `/home/happenhofer/versuche/CMake_tryout/Fortran'
make[1]: *** [CMakeFiles/hi.dir/all] Error 2
make[1]: Leaving directory `/home/happenhofer/versuche/CMake_tryout/Fortran'
make: *** [all] Error 2
Thanks a lot for your effort!
Natalie
> Date: Wed, 10 Jun 2009 05:50:11 -0700
> From: [email protected]
> Subject: Re: [CMake] FW: building a mixed language programm with CMake
> To: [email protected]; [email protected]
>
>
> > /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../lib64/crt1.o:
> > In function `_start':
> > (.text+0x20): undefined reference to `main'
>
> Try to compile with VERBOSE option:
>
> make VERBOSE=1
>
> this will show you, what GCC does.
>
> > The only library I tell CMake to link to is libgfortran.so.
> > What libraries does CMake usually link to, without
> > specifying?
>
> None. CMake is a Makefile generator it does not compile or link.
> Could you run "nm test.o" and "nm hello.o" and post the result?
> Also post verbose output.
>
> Denis
>
>
>
>
------------------------------------------------------------------------
¡Es hora que descubras quién eres! Alguien puede conocerte mejor que tu
mismo. <http://www.descubrewindowslive.com/>
------------------------------------------------------------------------
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake