LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-03-2014, 06:34 AM   #1
Thomas_G_Cook
LQ Newbie
 
Registered: Nov 2014
Posts: 2

Rep: Reputation: Disabled
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
 
Old 11-03-2014, 06:47 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Nonetheless, you should use [code] and [/code] tags.
What information to include in a post and how to use code tags
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
undefined reference to `cyg_profile_func_enter' in FORTRAN code Thomas_G_Cook Linux - Newbie 0 11-04-2014 02:46 PM
[SOLVED] compiling gcc undefined reference to orcaja Linux - Software 1 08-20-2013 08:48 AM
[SOLVED] Compiling Nitrogen: undefined reference to symbol Lennie Linux From Scratch 2 11-27-2012 01:06 PM
undefined reference to `yywrap' compiling PAM Mahonri Debian 5 12-30-2011 06:00 PM
undefined reference to `cfb_fillrect' and more when compiling kernel KR-data Linux - Software 0 09-03-2005 01:56 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration