Hi All,

I'm trying to use CheckFortranFunctionExists? to test for getarg which is 
failing on an Ubuntu 16.04 test machine and OS X test machine.  The test I have 
put together is provided below in text form.


The test for getarg fails, the executable 'bob' fails to link but the 
executable 'dave' links and runs as expected.


The error from 'bob' is


[ 75%] Linking Fortran executable bob
Undefined symbols for architecture x86_64:
  "_getarg_", referenced from:
      _MAIN__ in src.f.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [bob] Error 1
make[1]: *** [CMakeFiles/bob.dir/all] Error 2
make: *** [all] Error 2?



The files used in text form:


================== CMakeLists.txt =====================

cmake_minimum_required(VERSION 3.4)


project(getarg_prog VERSION 1.0.0 LANGUAGES Fortran)

include(CheckFortranFunctionExists)

check_fortran_function_exists(getarg HAVE_GETARG)

add_executable(bob src.f)

add_executable(dave dave.f)

======================================================



=================== src.f =========================

      program TESTFortran
      external getarg
      call getarg()
      end program TESTFortran

================================================


======================== dave.f ==========================

       PROGRAM test_getarg
         INTEGER :: i
         CHARACTER(len=32) :: arg

         DO i = 1, iargc()
           CALL getarg(i, arg)
           WRITE (*,*) arg
         END DO

========================================================


Can anyone explain why this is happening and how I would go about testing for 
the getarg function if I am doing it wrong.


Thanks,

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to