User forums > Help

Code:Blocks Error

(1/2) > >>

Cryptic Maniac:
I am using Windows 10, this is the version of codeblocks that I am using: codeblocks-17.12mingw_fortran-setup.exe

Issue:
When I am trying to compile a Fortran Code in CB, I have a series of errors pop up
Code
! A fortran95 program for G95
! By WQY

program main

  implicit none

  integer re_i

  write(*,*) "Do you work?"

  re_i = system("pause")
end

Errors
||=== Build: Debug in Fortran Test (compiler: GNU GCC Compiler) ===|
obj\Debug\main.o||In function `MAIN__':|
C:\Users\Peter\Documents\Coding\Fortran Test\main.f95|10|undefined reference to `_gfortran_st_write'|
C:\Users\Peter\Documents\Coding\Fortran Test\main.f95|10|undefined reference to `_gfortran_transfer_character_write'|
C:\Users\Peter\Documents\Coding\Fortran Test\main.f95|10|undefined reference to `_gfortran_st_write_done'|
C:\Users\Peter\Documents\Coding\Fortran Test\main.f95|11|undefined reference to `_gfortran_st_write'|
C:\Users\Peter\Documents\Coding\Fortran Test\main.f95|11|undefined reference to `_gfortran_transfer_character_write'|
C:\Users\Peter\Documents\Coding\Fortran Test\main.f95|11|undefined reference to `_gfortran_transfer_character_write'|
C:\Users\Peter\Documents\Coding\Fortran Test\main.f95|11|undefined reference to `_gfortran_transfer_character_write'|
C:\Users\Peter\Documents\Coding\Fortran Test\main.f95|11|undefined reference to `_gfortran_transfer_character_write'|
C:\Users\Peter\Documents\Coding\Fortran Test\main.f95|11|undefined reference to `_gfortran_st_write_done'|
C:\Users\Peter\Documents\Coding\Fortran Test\main.f95|13|undefined reference to `_gfortran_system'|
obj\Debug\main.o||In function `main':|
C:\Users\Peter\Documents\Coding\Fortran Test\main.f95|14|undefined reference to `_gfortran_set_args'|
C:\Users\Peter\Documents\Coding\Fortran Test\main.f95|14|undefined reference to `_gfortran_set_options'|
||error: ld returned 1 exit status|
||=== Build failed: 13 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|


I have uninstalled and reinstalled several times but the errors remain.
A mate told me it's linking errors in code blocks as I can use the Console just fine.

On top of that, the debugger also doesn't work.
It skips over breakpoints, doesn't run to cursor, and fails to complete debugging on its own with this error.
At C:\Users\Peter\DOCUME~1\Coding\C__TUT~1\1AA5E~1.11A\main.cpp:22
Cannot open file: watching variables and the call stack)\main.cpp
At watching variables and the call stack)\main.cpp:22


I have been stuck googling solutions to no avail.

stahta01:
You need to link to a library; I do not do FORTRAN; so, I have no idea what library.

Edit: http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

You may need to find an FORTRAN support site and post a build log in order to get help.

Tim S.

gd_on:
You need to compile your code with gfortran not gcc ... see :

--- Code: ---||=== Build: Debug in Fortran Test (compiler: GNU GCC Compiler) ===|

--- End code ---
look in the wiki how to set up your fortran compiler if it's not already done.
And your file should be named something like main.f or main.f90 or main .f95, but you have :

--- Code: ---C:\Users\Peter\DOCUME~1\Coding\C__TUT~1\1AA5E~1.11A\main.cpp
--- End code ---
gd_on

BentL:
You need to configure your Fortran project properly. The best way to start a new Fortran project is to use the "Fortran application" template:

File > New > Project... > Projects > Fortran application > Go

This way all necessary settings needed for a Fortran project are applied.

But you can also manually set these settings.


1) First set the compiler:

File > Settings... > Compiler... > Global compiler settings > Selected compiler: GNU Fortran Compiler

Then the toolchain:

File > Settings... > Compiler... > Global compiler settings > Toolchain executables > Program files

with the settings:

C compiler: mingw32-gfortran.exe
C++ compiler: mingw32-gfortran.exe
Linker for dynamic libs: mingw32-gfortran.exe
Linker for static libs: ar.exe
Debugger: GDB/CDB debugger : default
Resource compiler: windres.exe
Make program: mingw32.make.exe


2) Next you can configure the debugger:

Settings > Debugger... > GDB/CDB debugger > Default > Executable path > C:\Program Files (x86)\CodeBlocks\MinGW\bin\gdb32.exe

and select GDB as debugger.


3) Next you can specify that all libraries should be statically linked to the exe-file, so the application contains just one file:

File > Project > Build options... > Select application name > Linker settings > Other linker options > -static


4) Finally, you need to update the file "libgfortran-3.dll" as described in this post in order to work with files.

Cryptic Maniac:
Thank you very much,
I feel very foolish not realising that building Fortran with GNU GCC settings doesn't make it work.
Although when I can't compiler it also didn't work.

C++ and Fortran now run thanks to you wonderful people.
However, I am still having trouble with the Debugger, even after following your instructions.

It still ignores Breakpoints.

'Run to Cursor' causes the debugger to crash. Luckily not C::B though.

'Step out' function brings up this error
Debugger name and version: GNU gdb (GDB) 7.9.1
Child process PID: 11460
At C:\Users\Peter\Documents\Coding\C++ Tutorials\1.11a — Debugging your program (watching variables and the call stack)\main.cpp:22
Cannot open file: watching variables and the call stack)\main.cpp
At watching variables and the call stack)\main.cpp:22

I know it's the same error.  :(

Navigation

[0] Message Index

[#] Next page

Go to full version