Author Topic: Default compilers  (Read 15240 times)

Offline shaz

  • Single posting newcomer
  • *
  • Posts: 8
Default compilers
« on: September 25, 2011, 08:35:43 am »
Hi,

I am new to Linux programming and I have recently downloaded Code Blocks. I will be using Code Blocks for Fortran and C++ programming. I want to know a list of default compilers which are available in Code Blocks? I am specifically interested in Fortran compilers.

I am trying to use G95 but everytime I build, it says, "Test Fortran - Debug": The compiler's setup is invalid so Code::Blocks cannot find/run the compiler. Probably the toolchain path within the compiler options is not setup correctly?"

I am using Ubuntu 10.04.

Thanks for the help.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Default compilers
« Reply #1 on: September 25, 2011, 08:55:17 am »
Code::Blocks is an IDE and does not ship with any compiler on linux.
You have to install a supported compiler yourself and check/fix the setup in "Setup -> Compiler and debugger -> [your compiler] -> Toolchain executables".

C::B is mainly focused on C/C++ development so you have to tweak nore stuf to be able to use a fortran compiler.
There is a thread (or multiple threads) about it in the forum, please search for it.
There is also a wiki-article about installing fortran compiler: http://wiki.codeblocks.org/index.php?title=Installing_Fortran_Compiler

Offline shaz

  • Single posting newcomer
  • *
  • Posts: 8
Re: Default compilers
« Reply #2 on: September 25, 2011, 06:43:37 pm »
Thanks a bunch.....cheers!!

Offline shaz

  • Single posting newcomer
  • *
  • Posts: 8
Re: Default compilers
« Reply #3 on: September 26, 2011, 10:33:51 am »
Okay, so I got myself a GNU Fortran Compiler. I installed it and put the installed path in the toolchain executables. I read (here, http://forums.codeblocks.org/index.php/topic,13090.0.html) that  C :: D would automatically locate the requires files and populate the list. But I am still getting, these errors:

||error: unrecognized command line option ‘-warn’|
||gfortran: error:  all : No such file or directory|
||gfortran: error:  full : No such file or directory|
||=== Build finished: 3 errors, 0 warnings (0 minutes, 0 seconds) ===|


Any help would be appreciated.
« Last Edit: September 26, 2011, 10:47:57 am by shaz »

Offline shaz

  • Single posting newcomer
  • *
  • Posts: 8
Re: Default compilers
« Reply #4 on: September 26, 2011, 03:39:29 pm »
I have gotten a little far,

But I cannot locate the Linker for Static libs, Debugger, Recourse Compiler, Make Program. I am using gfortran 4.7.

The compiler is given the following error on build,

libmpc.so.2 No such file or directory

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Default compilers
« Reply #5 on: September 26, 2011, 03:45:25 pm »
Read this: http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F
Then try to build your project in the console, so you find the commands needed.
Then try to setup C::B to execute the same commands.
Then you if have troubles, write again.
(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 shaz

  • Single posting newcomer
  • *
  • Posts: 8
Re: Default compilers
« Reply #6 on: September 26, 2011, 04:17:31 pm »
Hi,

I am new to linux programming and to CodeBlock, so I am not sure if I completely understand what you mean by building in Console. Can you please be more specific as I new to this.

I did  try what the webpage instructed, here is what I am getting in the log,

-------------- Build: Debug in TestingF ---------------

gfortran -Jobj/Debug/ -Wall  -g     -c /home/shahbaz/Downloads/CodeBlocks/TestingF/main.f90 -o obj/Debug/main.o
/usr/local/gfortran/libexec/gcc/i686-pc-linux-gnu/4.7.0/f951: error while loading shared libraries: libmpc.so.2: cannot open shared object file: No such file or directory
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings (0 minutes, 0 seconds)
 
I have a very simple Hello World program.

Will deeply appreciate your help in this matter as I am quite lost. Thanks once again for your time.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Default compilers
« Reply #7 on: September 26, 2011, 04:26:56 pm »
What I've suggested is to:
1. open a console window, also known as terminal (xterm, gnome-terminal, konsole)
2. cd to the directory with your source file
3. execute some commands to build the source (check the manual of gfortran for how to do so)
4. run your executable

Then you'll know what
Code
gfortran -Jobj/Debug/ -Wall  -g     -c /home/shahbaz/Downloads/CodeBlocks/TestingF/main.f90 -o obj/Debug/main.o
means.

p.s. I've never used a fortran compiler, so I can't help you more.
(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 shaz

  • Single posting newcomer
  • *
  • Posts: 8
Re: Default compilers
« Reply #8 on: September 26, 2011, 10:53:52 pm »
Hi,

Thanks for the suggestion. I did run it in terminal, even the program I was originally running. It compiles and runs perfectly fine. With no errors.

Can anyone suggest, what else could be wrong?

Thanks!!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Default compilers
« Reply #9 on: September 26, 2011, 11:03:27 pm »
Code
gfortran -Jobj/Debug/ -Wall  -g     -c /home/shahbaz/Downloads/CodeBlocks/TestingF/main.f90 -o obj/Debug/main.o
/usr/local/gfortran/libexec/gcc/i686-pc-linux-gnu/4.7.0/f951: error while loading shared libraries: libmpc.so.2: cannot open shared object file: No such file or directory

It seems that the gfortran executable is failing to find its libs, have you restarted gnome/kde after you've installed the gfortran?
Is you library path setup correctly?
You are using gfortran from gcc 4.7.0? The unreleased one, which is still in development?
(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 shaz

  • Single posting newcomer
  • *
  • Posts: 8
Re: Default compilers
« Reply #10 on: September 27, 2011, 12:17:52 am »
Actually, I figured I had the wrong compiler selected. But even after fixing this, I am getting this error:

-------------- Build: Debug in TestingF ---------------

gfortran -Jobj/Debug/ -warn all  -debug full  -Wall    -c /home/shaz/Downloads/CodeBlocks/TestingF/main.f90 -o obj/Debug/main.o
gfortran: error: unrecognized command line option ‘-warn’
gfortran: error: all: No such file or directory
gfortran: error: full: No such file or directory
Process terminated with status 1 (0 minutes, 0 seconds)
3 errors, 0 warnings (0 minutes, 0 seconds)
 
Yeah, it is 4.7 but it was the only one I could find.

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Default compilers
« Reply #11 on: September 27, 2011, 03:31:41 am »
Yeah, it is 4.7 but it was the only one I could find.
This is shot in the dark as I only rarely work on Linux (and never with Fortran), but did you check your system's package manager for gfortran, or availability of GFortranBinaries?

I also saw Code::Blocks IDE for Fortran (Fortran Project plugin) that might interest you (it probably has nothing to do with your problem).

Edit: The errors in your build log imply that some of the switches you are sending to the compiler are invalid.  You could try removing all switches (including any custom ones), and see if it compiles then.
« Last Edit: September 27, 2011, 03:36:36 am by Alpha »

Offline shaz

  • Single posting newcomer
  • *
  • Posts: 8
Re: Default compilers
« Reply #12 on: September 27, 2011, 09:27:49 am »
Yeah, I  thought about that too. Is it really true that Code Blocks isn't made for Fortran?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Default compilers
« Reply #13 on: September 27, 2011, 09:36:02 am »
100%, it is a C/C++ IDE, but there are many users which use it to compile fortran code. I've used it to compile D code, so it is doable, I think.

Check the options in the project for any warnings set. Also check the manual of your compiler for the correct cmd arguments.

"-warn all" seems to be used to enable all warnings on an older compiler.
(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 MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Default compilers
« Reply #14 on: September 27, 2011, 06:17:38 pm »
Yeah, I  thought about that too. Is it really true that Code Blocks isn't made for Fortran?
Not really, but you can achieve great feature options, including CC, if you are using a 3rd party plugin which can be obtained from here:
http://darmar.vgtu.lt
Alternatively if you develop in Fortran, only - use the forked C::B IDE from this page.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ