Tutorial :Issues with I/O in Multi-language compiling



Question:

Greeting Everyone

I'm trying to compile and run a multi-language code in C, C++ and fortran using gcc, g++ & f77 respectively in UNIX. My program consists of two parts, one in C, the other in C++. They interface via a main() writen in C+, while the fortran code can be ignored for this case.

I have been having numerous issues with this, most noticabbly a Segmentation Error thats been occuring as I run the executable. The previous two topics of mine have whittled it down, unfortunatly nothing seems to be solving the problem outright other than completely removing any input/output processes in either half of my program, which just isn't feasible.

Accessing public class memory from C++ using C Output conflicts between C & C++

I need to locate the reason why I recieve Segmentation Errors when I use input/outputs in both parts of my program. All sources compile, all link successfully and I know that each part (C & C++) works when linked alone with no such Segmentation Errors (with modifications to let them work alone of course). I've included all the code that interfaces between the two parts and performs input/output functions.

Any help would be much appriciated.

Makefile

products: SlowDynamic.exe    SlowDynamic.exe: main.o SA.o mersenne.o CFE.o BCs.o EMatrix.o Numbering.o KMatrix.o Solve.o MA_57.o blas.o MA_57_Depend.o Metis.o      f77 -L/usr/sfw/lib -R/usr/sfw/lib -lgcc_s -lstdc++ -o SlowDynamic.exe main.o \          SA.o mersenne.o CFE.o MA_57.o blas.o MA_57_Depend.o Metis.o\          BCs.o EMatrix.o Numbering.o KMatrix.o Solve.o    main.o: main.cpp      g++ -c -o main.o main.cpp    SA.o: SA.cpp      g++ -c -o SA.o SA.cpp    mersenne.o: mersenne.cpp      g++ -c -o mersenne.o mersenne.cpp    CFE.o: CFE.c      gcc -c -o CFE.o CFE.c    MA_57.o: MA_57.f      f77 -c -o MA_57.o MA_57.f    blas.o: blas.f      f77 -c -o blas.o blas.f    MA_57_Depend.o: MA_57_Depend.f      f77 -c -o MA_57_Depend.o MA_57_Depend.f    Metis.o: Metis.f      f77 -c -o Metis.o Metis.f    BCs.o: BCs.c      gcc -c -o BCs.o BCs.c    EMatrix.o: EMatrix.c      gcc -c -o EMatrix.o EMatrix.c    Numbering.o: Numbering.c      gcc -c -o Numbering.o Numbering.c    KMatrix.o: KMatrix.c      gcc -c -o KMatrix.o KMatrix.c    Solve.o : Solve.c      gcc -c -o Solve.o Solve.c    clean:       rm *.o Main.exe *.gpi  

main.ccp

#include <iostream>  #include "SA.h"     using namespace std;      int main()   {           Initial.Initialize();        Parent.SA(Initial.Write);        system ("PAUSE");        return 0;  }  

SA.h

#ifndef SA_H  #define SA_H    #include <vector>    class SimAnneal {        std::vector< std::vector<float> > DensityDomain;        float Solid_Ele_Num, Void_Ele_Num;      float Solid, Void;        double Energy;      double Time;        void Metropolis (double, int, int);      void Next_State (double, int);      double Schedule (double, int);      double ObjFunction ();      void Distribute ();      void Mutate ();      void Convert ();      void PrintDomain ();      void WriteResults (double, double, double, double, double);      public:      int x_max, y_max;      ...      std::vector<float> DensityArray;       std::vector<float> EnergyArray;      ...      void SA (int);      void Initialize ();  };    extern SimAnneal Initial, Parent, Child, Mutation, Best;    





        
Previous
Next Post »