Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » How to compile the enclosed sample project (mixed language C++/fortran)?
icon7.gif  How to compile the enclosed sample project (mixed language C++/fortran)? [message #1243517] Tue, 11 February 2014 04:31
Li-Pin Juan is currently offline Li-Pin JuanFriend
Messages: 1
Registered: February 2014
Junior Member
Hello,

I have been playing around the configuration of Eclipse IDE for compiling a short mixed-language (C++/Fortran) sample project (that came with my Intel compiler 2013) on my university's Linux cluster, but keep receiving error messages during compiling.

I have the knowledge to compile the same project successfully on my desktop (windows 7, visual studio and intel compiler 2013) but have no luck to see the same outcome on the Linux cluster.

May I ask anyone for doing me a favor to give a simple walkthrough on how to correctly compile the mixed language project (not via command-line syntax)? The source codes that are provided by intel compiler are enclosed in the text below. Thanks for your help in advance.

------------------------------------------------------------
(1) The Fortran main program:
program fmain
use, intrinsic :: iso_c_binding
implicit none
interface
subroutine c_routine (int_arg, str_in, str_out, str_out_len) bind(c)
import ! use declarations from host
integer(c_int), value,intent(in) :: int_arg
character(kind=c_char), dimension(*), intent(in) :: str_in
character(kind=c_char), dimension(*), intent(out) :: str_out
integer(c_int), value, intent(in) :: str_out_len
end subroutine c_routine
end interface
character(80) output_text
integer in_arg, output_len
character(80) input_text
input_text = "testing..."//c_null_char
in_arg = 123
call c_routine (in_arg, input_text, output_text, len(output_text))
output_len = index(output_text," ")
if (output_len == 0) output_len = len(output_text)
write (*,*) output_text(1:output_len)
end
(2) The C++ subroutine:
#include <stdio.h>
extern "C" void c_routine (
int int_arg, // integer to convert
char* input_text, // text to prepend to converted integer
char* output_text, // output buffer
int output_text_len // length of output buffer
)
{
sprintf_s(output_text,output_text_len,"%s%i ",input_text,int_arg);
}
--------------------------------------------------------------------------

The outcome of this project is "Testing...123."
Thanks.
Li
Previous Topic:Problem - text font in Vuforia Application
Next Topic:Application seems not running when using shared library
Goto Forum:
  


Current Time: Tue Apr 16 13:13:31 GMT 2024

Powered by FUDForum. Page generated in 0.03051 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top