User forums > Using Code::Blocks

mixed language (g++/g95) build setup

<< < (2/2)

oBFusCATed:
There is no problem debugging "app + static lib", nor "app + dynamic lib".

And I think you can't mix two different compilers in one target.
You can mix c++ and c in one project, so you can make a hacky compiler: C++ and g95 (which replaces the C compiler), but this solution is hacky, too hacky...

enalyen:
Ok, thanks I'll use that solution for the time being.

> And I think you can't mix two different compilers in one target.

My experience on this is that in fact you can mix the two compilers to generate one target.

In this specific instance I can (outside C::B) run the following script from the (cygwin) command line:
---------------------------------------------------------------------------------------------
g95 -g -mno-cygwin -o gfort.o -c fort.f95
g++ -g -mno-cygwin -o gmain.o -c main.cpp
g++ -g -mno-cygwin -o ga.exe gmain.o gfort.o -L/usr/lib/gcc/ -L/lib/ -L/usr/local/lib/gcc-lib/i686-pc-mingw32/4.0.3/ -lf95
---------------------------------------------------------------------------------------------
and generate an executable that behaves as expected.




oBFusCATed:
I was talking about C::B and it current capabilities.

p.s. please use quote instead of '>' and code tags when pasting things

enalyen:

--- Quote ---Is there a link to more information on how to properly setup the properties for that advanced tab menu (the one that says: "Please don't change anything unless you really know what you are doing. You could *really* mess-up Code::Blocks' build system").

--- End quote ---

This wiki clarified the issue for me:

--- Quote ---Adding support for non C/C++ files to the build system
http://wiki.codeblocks.org/index.php?title=Adding_support_for_non_C/C%2B%2B_files_to_the_build_system
--- End quote ---

I was not able to implement the extension based solution advocated in the wiki (if somebody does, perhaps can share it on this thread), but it gave me a a clue on how to customize the compilation for my fortran file:

Right-click on fortran source file under the "Project View" in the "Fortran Sources" category. Open the "Properties" context menu, under the "Advanced Tab" check the box "Use custom command to build this file" and inserted the following command:

--- Code: ---g95 $options $includes -c $file -o $object
--- End code ---

Finally, under linker settings for the g++ compiler, in the "Other linker options" I had to add the following lines:


--- Code: ----L/usr/local/lib/gcc-lib/i686-pc-mingw32/4.0.3/
-lf95
-mn0-cygwin

--- End code ---

Navigation

[0] Message Index

[*] Previous page

Go to full version