I am trying to learn Fortran using the NetBeans IDE with the basic "Hello World" programming application. However, I keep getting "Build Failed". I don't know why? I have installed the MinGW. Then I configured the PATH in the Environment Variables. Finally, I installed NetBeans. This is what I programmed in NetBeans:
PRINT*, 'Hello World'
END
The following is the error and the history that I get:
cd 'C:\Users\ABCD\Documents\NetBeansProjects\CppApplication_1'
C:\MinGW\msys\1.0\bin\make.exe -f Makefile CONF=Debug
"/C/MinGW/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/c/Users/ABCD/Documents/NetBeansProjects/CppApplication_1'
"/C/MinGW/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/cppapplication_1.exe
make.exe[2]: Entering directory `/c/Users/ABCD/Documents/NetBeansProjects/CppApplication_1'
mkdir -p build/Debug/MinGW-Windows
gfortran -c -g -o build/Debug/MinGW-Windows/testfortran.o testfortran.f90
mkdir -p dist/Debug/MinGW-Windows
g++ -o dist/Debug/MinGW-Windows/cppapplication_1 build/Debug/MinGW-Windows/main.o build/Debug/MinGW-Windows/testfortran.o
build/Debug/MinGW-Windows/testfortran.o: In function `main':
C:\Users\ABCD\Documents\NetBeansProjects\CppApplication_1/testfortran.f90:2: multiple definition of `main'
build/Debug/MinGW-Windows/main.o:C:\Users\ABCD\Documents\NetBeansProjects\CppApplication_1/main.cpp:21: first defined here
build/Debug/MinGW-Windows/testfortran.o: In function `MAIN__':
C:\Users\ABCD\Documents\NetBeansProjects\CppApplication_1/testfortran.f90:1: undefined reference to `_gfortran_st_write'
C:\Users\ABCD\Documents\NetBeansProjects\CppApplication_1/testfortran.f90:1: undefined reference to `_gfortran_transfer_character_write'
C:\Users\ABCD\Documents\NetBeansProjects\CppApplication_1/testfortran.f90:1: undefined reference to `_gfortran_st_write_done'
build/Debug/MinGW-Windows/testfortran.o: In function `main':
C:\Users\ABCD\Documents\NetBeansProjects\CppApplication_1/testfortran.f90:2: undefined reference to `_gfortran_set_args'
C:\Users\ABCD\Documents\NetBeansProjects\CppApplication_1/testfortran.f90:2: undefined reference to `_gfortran_set_options'
collect2.exe: error: ld returned 1 exit status
make.exe[2]: *** [dist/Debug/MinGW-Windows/cppapplication_1.exe] Error 1
make.exe[2]: Leaving directory `/c/Users/ABCD/Documents/NetBeansProjects/CppApplication_1'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory `/c/Users/ABCD/Documents/NetBeansProjects/CppApplication_1'
make.exe": *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
I am not understanding how do I fix it? I would appreciate any help as I am a beginner to the Fortran/C++ world.
gfortran
properly installed. It looks like you are running Windows, so what do you see if you open aCommand Prompt
window and enter gfortran --version? – skomisa