Foros del Web » Programación para mayores de 30 ;) » C/C++ »

[SOLUCIONADO] Compilando un fichero fortran en un proyecto de C++ con NetBeans

Estas en el tema de Compilando un fichero fortran en un proyecto de C++ con NetBeans en el foro de C/C++ en Foros del Web. Hola, Tengo un fichero llamado newfortranFreeFormatFile.f en un proyecto de C++ con el siguiente contenido: Código: PROGRAM CALCULO_FACT INTEGER N REAL FACT, FACTORIAL READ (*,*) ...
  #1 (permalink)  
Antiguo 25/06/2013, 15:37
 
Fecha de Ingreso: octubre-2008
Mensajes: 276
Antigüedad: 15 años, 6 meses
Puntos: 1
Compilando un fichero fortran en un proyecto de C++ con NetBeans

Hola,

Tengo un fichero llamado newfortranFreeFormatFile.f en un proyecto de C++ con el siguiente contenido:

Código:
PROGRAM  CALCULO_FACT
      INTEGER N
      REAL FACT, FACTORIAL
      READ (*,*) N
      FACT = FACTORIAL (N)
      PRINT *, FACT
      END

      FUNCTION FACTORIAL (N)
      INTEGER I, N
      REAL FACTORIAL,  PROD
      PROD = 1.0
      DO I = 2, N
             PROD = PROD * I
      END DO
      END
Fuente: http://www.uam.es/departamentos/cien...N/FORTRAN.html

Cuando trato de compilarlo con NetBeans obtengo este error:

Cita:
CLEAN SUCCESSFUL (total time: 880ms)

mkdir -p build/Debug/MinGW-Windows
gfortran -c -g -o build/Debug/MinGW-Windows/newfortranFreeFormatFile.o newfortranFreeFormatFile.f
newfortranFreeFormatFile.f:8.1:

PROGRAM CALCULO_FACT
1
Error: Car�cter no num�rico en la etiqueta de declaraci�n en (1)
newfortranFreeFormatFile.f:8.1:

PROGRAM CALCULO_FACT
1
Error: Declaraci�n inclasificable en (1)
make: *** [build/Debug/MinGW-Windows/newfortranFreeFormatFile.o] Error 1


BUILD FAILED (exit value 2, total time: 2s)
¿Qué es lo que está mal?

EDITO

Ya lo tengo, el problema era que la primera línea estaba sin tabular como el resto, ahora el código queda así:

Código:
      PROGRAM  CALCULO_FACT
      INTEGER N
      REAL FACT, FACTORIAL
      READ (*,*) N
      FACT = FACTORIAL (N)
      PRINT *, FACT
      END

      FUNCTION FACTORIAL (N)
      INTEGER I, N
      REAL FACTORIAL,  PROD
      PROD = 1.0
      DO I = 2, N
             PROD = PROD * I
      END DO
      END
y obtengo esta bonita salida:

Cita:
CLEAN SUCCESSFUL (total time: 1s)

mkdir -p build/Debug/MinGW-Windows
gfortran -c -g -o build/Debug/MinGW-Windows/newfortranFreeFormatFile.o newfortranFreeFormatFile.f


BUILD SUCCESSFUL (total time: 2s)
Antes de nada aseguraros que tenéis C:\MinGW\bin, que es donde debería estar gfortran.exe, en la variable del sistema 'Path'.

EDITO DE NUEVO

He tenido más problemas, he añadido la ruta de la librería dinámica de Fortran, libgfortran-3.dll, en 'Additional Library Directories' y también he añadido la librería libgfortran-3.dll en 'Libraries' en Properties --> Build --> Linker.

Me daba estos errores:

Cita:
"/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .clean-conf
make[1]: Entering directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
rm -f -r build/Debug
rm -f dist/Debug/MinGW-Windows/pruebafortran.exe
rm -f *.mod
make[1]: Leaving directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'


CLEAN SUCCESSFUL (total time: 2s)

"/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
"/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/pruebafortran.exe
make[2]: Entering directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
mkdir -p build/Debug/MinGW-Windows
rm -f build/Debug/MinGW-Windows/main.o.d
g++ -c -g -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp
mkdir -p build/Debug/MinGW-Windows
gfortran -c -g -o build/Debug/MinGW-Windows/newfortranFreeFormatFile.o newfortranFreeFormatFile.f
mkdir -p dist/Debug/MinGW-Windows
g++ -o dist/Debug/MinGW-Windows/pruebafortran build/Debug/MinGW-Windows/main.o build/Debug/MinGW-Windows/newfortranFreeFormatFile.o
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Offset (800) greater than or equal to (null) size (4954657).
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x120): multiple definition of `main'
build/Debug/MinGW-Windows/main.o:C:\Users\xxxx\Documents\NetBeansProjects\pr uebaFortran/main.cpp:15: first defined here
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '0', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x80): undefined reference to `_gfortran_st_read'
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '20039', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x9d): undefined reference to `_gfortran_transfer_integer'
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '28486', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0xab): undefined reference to `_gfortran_st_read_done'
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '24946', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0xef): undefined reference to `_gfortran_st_write'
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '11828', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x10c): undefined reference to `_gfortran_transfer_real_write'
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '50', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x11a): undefined reference to `_gfortran_st_write_done'
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '25966', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x13c): undefined reference to `_gfortran_set_args'
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '29295', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x150): undefined reference to `_gfortran_set_options'
collect2: ld devolvi� el estado de salida 1
make[2]: *** [dist/Debug/MinGW-Windows/pruebafortran.exe] Error 1
make[2]: Leaving directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
make: *** [.build-impl] Error 2


BUILD FAILED (exit value 2, total time: 5s)
Tras hacer esto me daba estos otros errores:

Cita:
"/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .clean-conf
make[1]: Entering directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
rm -f -r build/Debug
rm -f dist/Debug/MinGW-Windows/pruebafortran.exe
rm -f *.mod
make[1]: Leaving directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'


CLEAN SUCCESSFUL (total time: 2s)

"/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
"/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/pruebafortran.exe
make[2]: Entering directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
mkdir -p build/Debug/MinGW-Windows
rm -f build/Debug/MinGW-Windows/main.o.d
g++ -c -g -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp
mkdir -p build/Debug/MinGW-Windows
gfortran -c -g -o build/Debug/MinGW-Windows/newfortranFreeFormatFile.o newfortranFreeFormatFile.f
mkdir -p dist/Debug/MinGW-Windows
g++ -o dist/Debug/MinGW-Windows/pruebafortran build/Debug/MinGW-Windows/main.o build/Debug/MinGW-Windows/newfortranFreeFormatFile.o -L../../../../../MinGW/bin -lgfortran-3
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Offset (800) greater than or equal to (null) size (4954657).
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x120): multiple definition of `main'
build/Debug/MinGW-Windows/main.o:C:\Users\xxxx\Documents\NetBeansProjects\pr uebaFortran/main.cpp:15: first defined here
collect2: ld devolvi� el estado de salida 1
make[2]: *** [dist/Debug/MinGW-Windows/pruebafortran.exe] Error 1
make[2]: Leaving directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
make: *** [.build-impl] Error 2


BUILD FAILED (exit value 2, total time: 5s)
Después cambié el código de Fortran por esto:

Código:
      FUNCTION FACTORIAL (N)
      INTEGER I, N
      REAL FACTORIAL,  PROD
      PROD = 1.0
      DO I = 2, N
             PROD = PROD * I
      END DO
      END
El proyecto compila correctamente.

Saludos.
__________________
Uso Apache 2.2 con PHP 5.5.9 y MySQL 5.1
Uso Eclipse IDE for Java Developers, Version: Mars.1 Release (4.5.1), Build id: 20150924-1200 para programar en Java bajo Windows

Última edición por letni; 25/06/2013 a las 16:24

Etiquetas: fichero, int, netbeans, proyecto, windows
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:47.