FORTRAN question when compiling undefined reference to `cyg_profile_func_enter'
I am trying to call 2 seperate 'C' program from a FORTRAN program and I am getting the following error.
gfortran tcookbwtestm3.f95 -o tookbwtestx.exe tcookbwtestm3.f95:92.39: subroutine cyg_profile_func_enter(dest,n) bind(C) 1 Warning: Variable 'dest' at (1) is a parameter to the BIND(C) procedure 'cyg_profile_func_enter' but may not be C interoperable tcookbwtestm3.f95:92.41: subroutine cyg_profile_func_enter(dest,n) bind(C) 1 Warning: Variable 'n' at (1) is a parameter to the BIND(C) procedure 'cyg_profile_func_enter' but may not be C interoperable tcookbwtestm3.f95:99.38: subroutine cyg_profile_func_exit(dest,n) bind(C) 1 Warning: Variable 'dest' at (1) is a parameter to the BIND(C) procedure 'cyg_profile_func_exit' but may not be C interoperable tcookbwtestm3.f95:99.40: subroutine cyg_profile_func_exit(dest,n) bind(C) 1 Warning: Variable 'n' at (1) is a parameter to the BIND(C) procedure 'cyg_profile_func_exit' but may not be C interoperable /tmp/ccJa3pbB.o: In function `MAIN__': tcookbwtestm3.f95.text+0xc1): undefined reference to `cyg_profile_func_enter' tcookbwtestm3.f95.text+0x3d0): undefined reference to `cyg_profile_func_exit' collect2: ld returned 1 exit status Now the 'C' routines are in a library somewhere and making that part work will be passed off to another.There still seems to be some issues with the Parse/Unparse routines that the other team are working on. I am simply trying to create a 'manual' program that can be used by the other team so that they can add the 'C' calls to all FORTRAN compiles automatically. The Fortran code is: cat tcookbwtestm3.f95 !>>######################################################################## !>> !>> This routine will be used in testing the BlackWhitelistSelector as !>> part of the ROSE TU-Darmstadt modification. !>> !>> This is a MANUAL version; meaning that all changed necessary for testing !>> this within the BlackWhitelistSelector modifier have been included !>> within this program. !>> !>> The point is to use this as the template of what BlackWhitelistSelector !>> needs to insert within existing Fortran code !>> !>> Thanks Thomas G Cook !>> !>>######################################################################## !>> Add ! IMPLICIT NONE module c_func IMPLICIT NONE !>> We need to add the following variables; they are used when !>> FORTRAN calls C and are needed to keep the variables alligned !>> ============================================================= !>> !>> This SHOULD BE REPLACED by using the use, intrinsic :: iso_c_binding !>> !>> Unfortunately within the current environment the above value is !>> WRONG !>> !>>######################################################################## ! use, intrinsic :: ISO_C_BINDING !>> The supplied variables in ISC_C_BINDING.f03 are incorrect !>> ========================================================= !>> Here are the correct values integer :: c_ptr integer :: c_funptr integer, parameter :: c_int = 4 integer, parameter :: c_short = 2 integer, parameter :: c_long = 4 integer, parameter :: c_long_long = 8 integer, parameter :: c_signed_char = 1 integer, parameter :: c_size_t = 4 integer, parameter :: c_intmax_t = 7 integer, parameter :: c_intptr_t = 8 integer, parameter :: c_int8_t = 1 integer, parameter :: c_int16_t = 2 integer, parameter :: c_int32_t = 4 integer, parameter :: c_int64_t = 8 integer, parameter :: c_int_least8_t = 1 integer, parameter :: c_int_least16_t = 2 integer, parameter :: c_int_least32_t = 4 integer, parameter :: c_int_least64_t = 8 integer, parameter :: c_int_fast8_t = 1 integer, parameter :: c_int_fast16_t = 2 integer, parameter :: c_int_fast32_t = 4 integer, parameter :: c_int_fast64_t = 8 real, parameter :: c_float = 4 real, parameter :: c_double = 8 real, parameter :: c_long_double = 16 integer, parameter :: c_float_complex = c_float integer, parameter :: c_double_complex = c_double integer, parameter :: c_long_double_complex = c_long_double integer, parameter :: c_bool = 24 integer, parameter :: c_char = 1 character, parameter :: c_null_char = char(0) !C’\0’ character, parameter :: c_alert = achar(7) !C’\a’ character, parameter :: c_backspace = achar(8) !C’\b’ character, parameter :: c_form_feed = achar(12)!C’\f’ character, parameter :: c_new_line = achar(10)!C’\n’ character, parameter :: c_carriage_return = achar(13) !C’\r’ character, parameter :: c_horizontal_tab = achar(9) !C’\t’ character, parameter :: c_vertical_tab = achar(11) !C’\v’ !>> 'C' library function being invoked. !>> =================================== character (30) :: str_1 integer, parameter :: call_site = 4 integer, parameter :: n = 30 INTERFACE subroutine cyg_profile_func_enter(dest,n) bind(C) ! use iso_c_binding, only: c_char, c_size_t import character (kind=c_char), intent(out) :: dest(*) integer (c_size_t), value, intent(in) :: n end subroutine cyg_profile_func_enter subroutine cyg_profile_func_exit(dest,n) bind(C) ! use iso_c_binding, only: c_char, c_size_t import character (kind=c_char), intent(out) :: dest(*) integer (c_size_t), value, intent(in) :: n end subroutine cyg_profile_func_exit end INTERFACE end module c_func !>> add program tcookbwtestm !>> Add use c_func !>> Initialize str to blanks !>> ======================== str_1 = repeat(' ',30) str_1 = 'this_fn' call cyg_profile_func_enter(str_1, call_site) print *, ' ' print *, ' cyg_profile_func_enter ' print *, '============' print *, ' ' !>> ADD print *, ' ' print *, ' This is test code for BlackWhitelistSelector Fortran ' print *, ' ==================================================== ' print *, ' ' !>> add call cyg_profile_func_exit(str_1,call_site) print *, ' ' print *, ' cyg_profile_func_exit ' print *, '============' print *, ' ' !>> ADD END PROGRAM tcookbwtestm Yes, I know I should be using an ISO_C_BINDIN>G statement but you cannot use what you do not have. Thank you to everyone |
Nonetheless, you should use [code] and [/code] tags.
What information to include in a post and how to use code tags |
All times are GMT -5. The time now is 05:48 PM. |