This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gfortran + cygwin: shared librairies?


[I'm forwarding this request that I received by private mail to the fortran list]

Hello,

You always get more replies when you post to the list, instead of mailing people privately, especially when you're not asking the right guy :) Therefore, I copy the list so that the people who can give you more help than I currently can.

Thanks for the report anyway!
FX


Hello,

I am currently ensuring the cygwin support of the software I am working on, but I have a trouble with gfortran. I attach all this as a small example:
- open.f provides a routine which opens the file foo.txt and associates it to a logical unit. The library libopen.dll is created from the single file open.o.
- read.f provides a routine which reads the first line of file foo.txt, by reading the logical unit opened by the above 'opening' routine. The library libread.dll is created from the single file read.o.
- The main program test opens and reads the file. It is linked against these 2 dlls. And actually, it does not work and returns and EOF signal at the first read call.
There is no problem if the open and read statements are called from the same dll.


From our side, we suspect that it is a shared/static librairies trouble. The gfortran binaries distributed for cygwin only provide the static librairies:

dhcp-bardeau READ/2-libs> gfortran -v
Using built-in specs.
Target: i686-pc-cygwin
Configured with: ../gcc43/configure --prefix=/usr/local/gfortran -- enable-languages=c,fortran --enable-bootstrap --enable- threads=posix --enable-sjlj-exceptions --enable-version-specific- runtime-libs --enable-nls --disable-libmudflap --disable-shared -- disable-win32-registry --with-system-zlib --enable-checking=release --enable-werror --without-included-gettext --without-x --enable- libgomp
Thread model: posix
gcc version 4.3.0 20070512 (experimental)


It seems that you are in charge to provide the cygwin binaries, and my request does not concern a bug, so that's why I email you. Is it possible that you activate the shared librairies creation (--enable- shared) ? I tried to recompile myself the gfortran executable and libraires, but I have other troubles in the gcc make processes...

Thanks for your help,

Sebastien Bardeau


PROGRAM TEST


INTEGER ERR, MY_OPEN
!
ERR = MY_OPEN("./foo.txt")
IF (ERR.NE.0) THEN
print *,"Test: error opening file", FILE
RETURN
ENDIF
!
CALL MY_READ
!
print *,"End of program"
END PROGRAM TEST
define logical VERIFY
sic\let VERIFY = SIC%VERIFY
sic veri &1
!
define double a[166]
define double b[16,4]
define double c[16,16,16]
define double d[16,16]
DEFINE CHARACTER GAG1*20
DEFINE CHARACTER GAG2*20
define logical log1
define logical log2
!
sic\FOR prec 1 TO 3
IF (prec.EQ.1) THEN
SIC PRECISION DOUBLE
ELSE IF (prec.EQ.2) THEN
SIC PRECISION SINGLE
ELSE IF (prec.EQ.3) THEN
SIC PRECISION AUTO
ENDIF
sic\let A = 2*ASIN(1)
sic\let B = ACOS(-1.0)
sic\let GAG1 = "C'est tout bon"
sic\let GAG2 = "C'est pas ca"
IF (GAG1.EQ.GAG2) THEN
! BEEP 3
PAUSE "Error in Math Formula Evaluation"
ENDIF
IF (A[9].NE.PI.OR.B[3,2].NE.PI) THEN
! BEEP 3
PAUSE "Error in Math Formula Evaluation"
ENDIF
IF (ACOS(-1.0).NE.2*ASIN(1)) THEN
! BEEP 3
PAUSE "Error in Math Formula Evaluation"
ENDIF
sic\let A = -1
sic\let B = -1
IF (10**-A[1]+B[6,3].NE.9) THEN
PAUSE "Error in Math Formula Evaluation"
ENDIF
IF (GAG1.NE."C'est tout bon") THEN
PAUSE "GAG has been modified"
ENDIF
IF (A[1].NE.-1) THEN
PAUSE
ENDIF
IF (2*ASIN(MIN(MAX(A[1],2),ABS(B[3,3])))+EXP(1-0.).NE.PI+EXP(ABS (B[8,1])+2-1-1)) THEN
SAY '(2*ASIN(MIN(MAX(A,2),ABS(B))))' 'PI'
SAY '(2*ASIN(MIN(MAX(A,2),ABS(B))))-PI'
PAUSE "Error in Math Formula Evaluation"
ENDIF
sic\let log1 = yes
sic\let LOG1 = .FALSE.
sic\let LOG2 = .TRUE.
if (.NOT.(.not.(log1.and..not.log2))) then
say (log1.and..not.log2)
PAUSE "Error in Math Formula Evaluation"
endif
IF ((GAG1.EQ.GAG2.or.log1.eq.log2).and.pi.eq.(1+2-pi)) THEN
! BEEP 3
PAUSE "Error in Math Formula Evaluation"
ENDIF
sic\let A[I] = SIN(I*PI|3)
sic\let B[I,J] = MAX(I*PI,J)
!
! Check newly implemented implicit transposition
sic\let B[I,J] I
sic\let A[5:8] B[3,]
s\FOR I 5 TO 8
IF (A[I].NE.3) THEN
PAUSE "Error in implicit transposition"
ENDIF
NEXT
! Old bug. Now fixed...
exa b[,2]
!
sic\let C[I,J,K] J
sic\let B C[,8,13:16]
s\FOR I 1 TO 16
s\FOR J 1 to 4
IF (B[I,J].NE.8) THEN
PAUSE "Error in implicit transposition"
ENDIF
NEXT
NEXT
!
s\let c = 0
s\let c[8,,] = pi
s\for j 1 to 16
s\for k 1 to 16 by 5
if (c[8,j,k].ne.pi) then
say "s\let c[8,,] = pi"
pause "Error in left side implicit transposition"
endif
next
next
next
!
s\LET C = 0
s\LET C[I,J,K] = 1 /WHERE (I.EQ.J)
sic veri off
s\for i 1 to 16
s\for j 1 to 16
s\for k 1 to 16 by 5
if (i.eq.j.and.c[i,j,k].ne.1) then
pause "Error in LET/WHERE test"
endif
next
next
next
sic\let SIC%VERIFY = VERIFY
next
sic\let SIC%VERIFY = VERIFY
say " "
say "Successful demo! Bye."
say " "
# FC = g95
FC = gfortran


# EXTRA_ARGS = /usr/local/lib/gcc-lib/i686-pc-cygwin/4.0.3/ g95_dlltools/g95main.o

default: test.exe

%.o: %.f
	$(FC) -c $<

libopen.dll: open.o
	$(FC) -shared -o $@ $<

libread.dll: read.o
	$(FC) -shared -o $@ $<

test.exe: libopen.dll libread.dll test.o
	$(FC) test.o $(EXTRA_ARGS) -o test.exe -L. -lopen -lread

clean:
	rm -rf *~ *.o *.exe *.dll
      INTEGER FUNCTION MY_OPEN(FILE)
!
      CHARACTER*(*) FILE
      CHARACTER*64 STATUS
      INTEGER UNIT, SIC_OPEN
!
      UNIT   = 53
      STATUS = 'OLD'
!
      print *,"Opening file..."
      OPEN(UNIT=UNIT,FILE=FILE,STATUS=STATUS,FORM='FORMATTED'
     &      ,ACTION='READ',IOSTAT=SIC_OPEN)
      print *,"...done. Return code was: ", SIC_OPEN
!
      MY_OPEN = SIC_OPEN
!
      END FUNCTION MY_OPEN
      SUBROUTINE MY_READ

      CHARACTER*64 LIGNE
      INTEGER UNIT
!
      UNIT = 53
!
      print *,"Reading file..."
      READ (UNIT,'(A)',END=150,ERR=202) LIGNE
      print *,"...done. LINE = ", LIGNE
!
      RETURN
!
202   WRITE(6,1000) 'Read error on macro file, unit ', UNIT
1000  FORMAT(A,I2)
      RETURN
!
150   print *,"EOF: returning @ label 150"
      RETURN
!
      END SUBROUTINE MY_READ


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]