LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


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

Rep: Reputation: Disabled
undefined reference to `cyg_profile_func_enter' in FORTRAN code


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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
error (undefined reference to `pow') while compiling a C code in terminal islam_assi Linux - Newbie 5 05-30-2013 09:43 AM
Yet another undefined reference CollieJim Linux - General 2 12-18-2010 12:08 AM
Undefined reference, why? george_mercury Programming 4 05-07-2009 01:15 AM
Undefined reference to: ashlesha Programming 5 11-08-2006 02:07 PM
undefined reference vkmgeek Programming 1 05-11-2006 07:37 AM


All times are GMT -5. The time now is 06:49 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration