Author Topic: Compiling fortran77 project using codeblocks  (Read 3758 times)

Offline krispy

  • Single posting newcomer
  • *
  • Posts: 4
Compiling fortran77 project using codeblocks
« on: April 15, 2020, 03:39:26 pm »
I am running Code::Blocks version 16.01mingw_fortran on Windows 10. The compiler I use is GNU Fortran compiler that came alongwith the codeblocks-16.01mingw_fortran-setup.exe file

When I try to build the code

I get the message
=== Build: Win32 Release in TYPE 862 (name of the sourcecode file) (compiler: GNU Fortran Compiler)===
=== Build failed: 0 error(s), o warning(s) (0 minutes, 0 second(s))===
in Build Messages


Build log:
-------------- Build: Win32 Release in TYPE 862 (compiler: GNU Fortran Compiler)---------------

g++.exe -JRelease  /MT /W3 /GX /O2 /DWIN32 /DNDEBUG /D_WINDOWS /D_MBCS /D_USRDLL /YX /FD     -c "C:\Program Files (x86)\Trnsys16\SourceCode\MyComponentsSC\TYPE 862\TYPE 862.for" -o "Release\SourceCode\MyComponentsSC\TYPE 862\TYPE 862.o"
g++.exe: error: /MT: No such file or directory
g++.exe: error: /W3: No such file or directory
g++.exe: error: /GX: No such file or directory
g++.exe: error: /O2: No such file or directory
g++.exe: error: /DWIN32: No such file or directory
g++.exe: error: /DNDEBUG: No such file or directory
g++.exe: error: /D_WINDOWS: No such file or directory
g++.exe: error: /D_MBCS: No such file or directory
g++.exe: error: /D_USRDLL: No such file or directory
g++.exe: error: /YX: No such file or directory
g++.exe: error: /FD: No such file or directory
Process terminated with status 1 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
 


I have already tried
Various other  configurations as suggested online and various youtube videos
but none of them worked.
I have another system with windows 7 and I'm flexible downloading other OS or using different method on it if it needed

This is my first time coding so I'm absolutely unaware about what exactly needs to be carried out and why. Please help me with what needs to be done. References to suitable steps or to obtain knowledge needed for compiling the code would be appreciated. 
« Last Edit: April 15, 2020, 03:45:29 pm by krispy »

Offline sodev

  • Regular
  • ***
  • Posts: 497
Re: Compiling fortran77 project using codeblocks
« Reply #1 on: April 15, 2020, 04:33:36 pm »
These look like MSVC command line switches, it seems like your compiler configuration is pretty much messed up. Did you change anything in the advanced compiler settings? That CodeBlocks version is also pretty dated, not sure if this is a bug that got already fixed.

My best bet would be backup your current CodeBlocks configuration (should be under %APPDATA%\Roaming\CodeBlocks) and delete it so that it gets recreated and/or upgrade to the latest release.

Offline krispy

  • Single posting newcomer
  • *
  • Posts: 4
Re: Compiling fortran77 project using codeblocks
« Reply #2 on: April 15, 2020, 08:32:30 pm »
I've uninstalled and reinstalled several times and the error is pretty much the same. I read on a thread about codeblocks by darmar for fortran and tried compiling the same code this is what has popped up in the build log

-------------- Build: Win32 Release in TYPE 862 (compiler: GNU Fortran Compiler)---------------

g++.exe -JRelease  /MT /W3 /GX /O2 /DWIN32 /DNDEBUG /D_WINDOWS /D_MBCS /D_USRDLL /YX /FD     -c "C:\Program Files (x86)\Trnsys16\SourceCode\MyComponentsSC\TYPE 862\TYPE 862.for" -o "Release\SourceCode\MyComponentsSC\TYPE 862\TYPE 862.o"
Execution of 'g++.exe -JRelease  /MT /W3 /GX /O2 /DWIN32 /DNDEBUG /D_WINDOWS /D_MBCS /D_USRDLL /YX /FD     -c "C:\Program Files (x86)\Trnsys16\SourceCode\MyComponentsSC\TYPE 862\TYPE 862.for" -o "Release\SourceCode\MyComponentsSC\TYPE 862\TYPE 862.o"' in 'C:\Program Files (x86)\Trnsys16\SourceCode\MyComponentsSC\TYPE 862' failed.

and this is what has popped up in build messages
=== Build: win32 Release in TYPE 862 (compiler: GNU Fortran Compiler)===
Exedcution of 'g++.exe -JRelease /MT /W3 /GX /o2 /DWIN32 /DDNDEBUG /D_WINDOWS /D_MBCS /D_USRDLL /YX /FD   -c "C:\Program Files (x86)\Trnsys16\SourceCode\MyComponents\Type 862.for" -o "Release\SourceCode\MyComponentsSC\TYPE 862\TYPE 862.o" ' in 'C:\


Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1563
Re: Compiling fortran77 project using codeblocks
« Reply #3 on: April 15, 2020, 08:40:41 pm »
Writing under Program files is not allowed to user programs. Change the source folder to another location and try again.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Compiling fortran77 project using codeblocks
« Reply #4 on: April 15, 2020, 08:49:25 pm »
Your tool chain settings are completely messed up!

You need to fix them!

Reinstalling C::B does not change the tool chain settings!

Either manually fix the setting or as already suggest rename the default.conf under %APPDATA%\CodeBlocks to a new name and see if the default file is regenerated with the correct values.

Tim S.

C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline krispy

  • Single posting newcomer
  • *
  • Posts: 4
Re: Compiling fortran77 project using codeblocks
« Reply #5 on: April 16, 2020, 09:30:28 am »
As suggested by Miguel and Stahta01 I changed the directory as well as reset to default and the files got regenerated and tried rebuilding the files again, but the errors were the same. So thought I'd try with the other system which had 'codeblocks-17.12mingw-setup.exe' file and tried compiling the same file with the .for file in a different directory and this is what popped up in build log

Project/Target: "TYPE861 - Win32 Release":
  The compiler's setup (GNU Fortran Compiler) is invalid, so Code::Blocks cannot find/run the compiler.
  Probably the toolchain path within the compiler options is not setup correctly?!
  Do you have a compiler installed?
Goto "Settings->Compiler...->Global compiler settings->GNU Fortran Compiler->Toolchain executables" and fix the compiler's setup.

Tried to run compiler executable 'C:\MinGW/bin/mingw32-gfortran.exe', but failed!

Skipping...
Nothing to be done (all items are up-to-date).


Since it was too messed up last time, I thought to proceed with your guidance on this one.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Compiling fortran77 project using codeblocks
« Reply #6 on: April 16, 2020, 09:35:23 am »
You don't have a fortran compiler installed. I guess the mingw we ship contains only c/c++ compilers.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline krispy

  • Single posting newcomer
  • *
  • Posts: 4
Re: Compiling fortran77 project using codeblocks
« Reply #7 on: April 16, 2020, 10:05:58 am »
Okay, could you direct me where could I get the compiler to compile fortran77 code?

Offline gd_on

  • Lives here!
  • ****
  • Posts: 797
Re: Compiling fortran77 project using codeblocks
« Reply #8 on: April 16, 2020, 10:28:35 am »
Have a look in the user manual (http://www.codeblocks.org/user-manual), chapter 5.2.
In your first post you have used g++, but you should use gfortran or mingw32-gfortran.exe to compile fortran (even if with g++ it can work).
Windows 11 64 bits (23H2), svn C::B (last version or almost!), wxWidgets 3.2.4 (tests with 3.3), Msys2 Compilers 13.2.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).