LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxAnswers Discussion
User Name
Password
LinuxAnswers Discussion This forum is to discuss articles posted to LinuxAnswers.

Notices


Reply
  Search this Thread
Old 07-02-2011, 03:49 PM   #31
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,220

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309

Quote:
Originally Posted by TheStefan12345 View Post
I just bought a book, and it doesn't say that you need using namespace std; and you need iostream.h

What the hell?
The book is outdated. Throw it out.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 11-21-2012, 11:06 PM   #32
durgam anil
LQ Newbie
 
Registered: Oct 2012
Location: banglore,india
Distribution: open suse,redhat,ubuntu
Posts: 13
Blog Entries: 1

Rep: Reputation: Disabled
compiling the c and c++ codes

in vi editor:

for c:
in shell :
step 1:type vi <your_program_name>.c
step 2: type gcc <your_program_name>.c -o <your_program_name>.out
or
type gcc <your_program_name>.c -o a.out
step 3:type ./<your_program_name>.out
or
./a.out

for c++:
in shell :
step 1:type vi <your_program_name>.cpp
step 2: type g++ <your_program_name>.cpp -o <your_program_name>.out
or
type g++ <your_program_name>.cpp -o a.out
step 3:type ./<your_program_name>.out
or
./a.out
 
1 members found this post helpful.
Old 10-03-2013, 09:27 AM   #33
NoStressHQ
Member
 
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609

Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by partha6794 View Post
There is a easy method to bulid "C" & "C ++ " programming:

There are three methods to bulid "C" & "C++" programming in RHL 9.0 & FC .by using GNOME desktop & another in KDE .
There are mainly two editor in GNOME , viz. vi- editor & another is emacs editor.I will discuss both here.



using VI-editor:

1. open terminal .
2. type for C programming
vi <filename>.c

for C++
vi <filename>.cpp

e.g:

vi hello.c { for C}
vi hello. cpp { for C++}

3. then type " i" ( i= insert)
4. then write source code . for details www.howstuffworks.com how to works "C" programming?
5. then press
esc : wq
it is save now.

6. now for comile the programme type,
cc <filename>
7. then for execute type
(dot)/a.out ( dot = . )

8. then it will see your screen.


USING EMACS EDITOR:

1.type emacs<file name> on terminal.
3. then type " i" ( i= insert)
4. then write source code . for details www.howstuffworks.com how to works "C" programming?
5. then press
esc : wq
it is save now.

6. now for comile the programme type,
cc <filename>
7. then for execute type
(dot)/a.out ( dot = . )

8. then it will see your screen.


USING KWRITE IN ( GNOME OR KDE DESKTOP)

1. Open terminal & type kwrite
2. then write source code
3. then click file .
4. then clck save as
5. save the file wtth extension .c/.cpp
now for comile the programme type,
cc <filename>
7. then for execute type
(dot)/a.out ( dot = . )


I hope it will helpful .


If you face any diffuculty u can email me
partha_26786794123@yahoo.com , ( for alert reply here)

partha
I know this is old... But the EMACS help is strange... It describes VI syntax NOT emacs !!
 
Old 05-18-2017, 05:53 AM   #34
ciuiu
LQ Newbie
 
Registered: May 2009
Posts: 16

Rep: Reputation: 0
Making executable files for Windows from a C++ program under LINUX

I have a C++ program called estsert.cpp, that estimates the parameters of an AR(p), MA(q) or ARMA(p,q) time series.

The command

g++ estsert.cpp -o estsert

makes the LINUX executable program estsert, and the execution is as we know,


./estsert

If I want to make the executable file on Windows, I need to create using Visual C++ a
new project with the same name (estsert.dsw), and the code
Code:
#include <stdio.h>
#include "sertimp.h"

main()
{int n,i,j,caz,model,ordin,p,q;
 double X[2000],A[100][100],A1[100][100],A2[5][5],coef[5],disper,ldisp[5],lstud[5],rezcrt,disp1[25],
   corel[25],lcov[25],corelp[25],fi[25],AIC1[25],BIC1[25],teta[25],teta1[25][25],aic,bic;
 char ch;
 FILE *f,*g,*f1;
 printf("No. of observations: n=");scanf("%d",&n);
 printf("caz: 1--> Dickey-Fuller, 2-->AR(p) model, 3--> MA(q) model, 4--> ARMA(p,q) model, ");
 printf("5--> difference, 6--> correlogram white noise AR(p), 7--> correlogram white noise MA(q), ");
 printf("8--> correlogram white noise ARMA(p,q)\ncaz=");
 scanf("%d",&caz);
 switch(caz)
   {case 2:
       printf("Order of the correlogram=");
       scanf("%d",&ordin);
       printf("p=");scanf("%d",&p);
    break;
	case 3:
       printf("Order of the correlogram=");
       scanf("%d",&ordin);
       printf("q=");scanf("%d",&q);
    break;
	case 4:
       printf("Order of the correlogram=");
       scanf("%d",&ordin);
       printf("p=");scanf("%d",&p);
	   printf("q=");scanf("%d",&q);
    break;
    default:
     printf("model=");scanf("%d",&model);
   }
 f=fopen("date.txt","r+");
 for(i=1;i<=n;i++)
   fscanf(f,"%lf",&X[i]);
 fclose(f);
 


 matrdf(n,X,A,A1,A2);
 disper=0;

 switch(caz)
   {case 2:
       covar(n,ordin,X,lcov);
	   for(i=1;i<=ordin;i++)
		   corel[i]=lcov[i]/lcov[0];
       yw(n,p,lcov,fi,&disper,&aic,&bic);
    break;
	case 3:
       covar(n,ordin,X,lcov);
	   for(i=1;i<=ordin;i++)
		   corel[i]=lcov[i]/lcov[0];
       inov(n,q,lcov,teta1,disp1,AIC1,BIC1);
    break;
	case 4:
       covar(n,ordin,X,lcov);
	   for(i=1;i<=ordin;i++)
		   corel[i]=lcov[i]/lcov[0];
       hr(n,p,q,lcov,X,fi,teta,&disper,&aic,&bic);
    break;
    default:
      //Dickey-Fuller
      switch(model)
	{case 2:
	    coef[1]=A2[1][1]*A[1][4]+A2[1][2]*A[2][4];
	    coef[2]=A2[2][1]*A[1][4]+A2[2][2]*A[2][4];
	 break;
	 case 3:
	   coef[1]=A1[1][1]*A[1][4]+A1[1][2]*A[2][4]+A1[1][3]*A[3][4];
	   coef[2]=A1[2][1]*A[1][4]+A1[2][2]*A[2][4]+A1[2][3]*A[3][4];
	   coef[3]=A1[3][1]*A[1][4]+A1[3][2]*A[2][4]+A1[3][3]*A[3][4];
	 break;
	 default:
	   coef[1]=A[2][4]/A[2][2];
	}
      for(i=2;i<=n;i++)
	{rezcrt=X[i]-X[i-1]-coef[1]-coef[2]*X[i-1];
	 if(model==3) rezcrt-=coef[3]*i;
	 if(model==1) rezcrt=X[i]-(1+coef[1])*X[i-1];
	 disper+=rezcrt*rezcrt/(n-1-model);
	}
      switch(model)
	{case 2:
	    ldisp[1]=disper*A2[1][1]/(n-1.0);
	    ldisp[2]=disper*A2[2][2]/(n-1.0);
         break;
	 case 3:
	   ldisp[1]=disper*A1[1][1]/(n-1.0);
	   ldisp[2]=disper*A1[2][2]/(n-1.0);
	   ldisp[3]=disper*A1[3][3]/(n-1.0);
         break;
	default:
	  ldisp[1]=disper/A[2][2]/(n-1.0);
	}
      for(i=1;i<=model;i++)
	lstud[i]=coef[i]/sqrt(ldisp[i]);
   }




 f=fopen("rez.txt","w+");
 g=fopen("rez.csv","w+");
 printf("Matrix of the system model 3 (A):\n");
 fprintf(f,"Matrix of the system model 3 (A):\n");
 fprintf(g,"Matrix of the systemmodel 3 (A):\n");
 for(i=1;i<=3;i++)
   {for(j=1;j<=4;j++)
       {printf("%10.5lf ",A[i][j]);
	fprintf(f,"%10.5lf ",A[i][j]);
	fprintf(g,"%10.5lf,",A[i][j]);
       }
     printf("\n");fprintf(f,"\n");fprintf(g,"\n");
   }
 printf("Inverse of A:\n");
 fprintf(f,"Inverse of A:\n");
 fprintf(g,"Inverse of A:\n");
 for(i=1;i<=3;i++)
   {for(j=1;j<=3;j++)
       {printf("%10.5lf ",A1[i][j]);
	fprintf(f,"%10.5lf ",A1[i][j]);
	fprintf(g,"%10.5lf,",A1[i][j]);
       }
     printf("\n");fprintf(f,"\n");fprintf(g,"\n");
   }
 printf("Inverse of A, first two rows/ columns:\n");
 fprintf(f,"Inverse of A, first two rows/ columns:\n");
 fprintf(g,"Inverse of A, first two rows/ columns:\n");
 for(i=1;i<=2;i++)
   {for(j=1;j<=2;j++)
       {printf("%10.5lf ",A2[i][j]);
	fprintf(f,"%10.5lf ",A2[i][j]);
	fprintf(g,"%10.5lf,",A2[i][j]);
       }
     printf("\n");fprintf(f,"\n");fprintf(g,"\n");
   }


 switch(caz)
   {case 2:
       f1=fopen("corel.txt","w+");
       for(i=0;i<=ordin;i++)
	 {printf("corel[%d]=%10.7lf\n",i,corel[i]);
	  fprintf(f1,"%10.7lf\n",corel[i]);
	 }
       fclose(f1);
       printf("AR(%d) coefficients:\n",p);
       fprintf(f,"AR(%d) coefficients:\n",p);
       fprintf(g,"AR(%d) coefficients:\n",p);
       for(i=1;i<=p;i++)
	 {printf("%10.5lf ",fi[i]);
	  fprintf(f,"%10.5lf ",fi[i]);
	  fprintf(g,"%10.5lf,",fi[i]);
	 }
       printf("\nVariance of the errors=%10.5lf\n",disper);
       fprintf(f,"\nVariance of the errors=%10.5lf\n",disper);
       fprintf(g,"\nVariance of the errors=,%10.5lf\n",disper);
	   printf("\nAIC=%10.5lf\n",aic);
       fprintf(f,"\nAIC=%10.5lf\n",aic);
       fprintf(g,"\nAIC=,%10.5lf\n",aic);
	   printf("\nBIC=%10.5lf\n",bic);
       fprintf(f,"\nBIC=%10.5lf\n",bic);
       fprintf(g,"\nBIC=,%10.5lf\n",bic);
    break;
	case 3:
       f1=fopen("corel.txt","w+");
       for(i=0;i<=ordin;i++)
	 {printf("corel[%d]=%10.7lf\n",i,corel[i]);
	  fprintf(f1,"%10.7lf\n",corel[i]);
	 }
       fclose(f1);
       printf("MA(%d) coefficients:\n",q);
       fprintf(f,"MA(%d) coefficients:\n",q);
       fprintf(g,"MA(%d) coefficients:\n",q);
       for(j=1;j<=q;j++)
	 {for(i=1;i<=j;i++)
	     {printf("%10.5lf ",teta1[i][j]);
	      fprintf(f,"%10.5lf ",teta1[i][j]);
	      fprintf(g,"%10.5lf,",teta1[i][j]);
	     }
	  printf("\n");fprintf(f,"\n");fprintf(g,"\n");
	 }
       printf("\nVariance of the errors:\n");
       fprintf(f,"\nVariance of the errors:\n");
       fprintf(g,"\nVariance of the errors:\n");
       for(i=0;i<=q;i++)
	 {printf("%10.5lf ",disp1[i]);
	  fprintf(f,"%10.5lf ",disp1[i]);
	  fprintf(g,"%10.5lf,",disp1[i]);
	 }
       printf("\n");fprintf(f,"\n");fprintf(g,"\n");
       printf("\nAIC:\n");
       fprintf(f,"\nAIC:\n");
       fprintf(g,"\nAIC:\n");
       for(i=0;i<=q;i++)
	 {printf("%10.5lf ",AIC1[i]);
	  fprintf(f,"%10.5lf ",AIC1[i]);
	  fprintf(g,"%10.5lf,",AIC1[i]);
	 }
       printf("\n");fprintf(f,"\n");fprintf(g,"\n");
       printf("\nBIC:\n");
       fprintf(f,"\nBIC:\n");
       fprintf(g,"\nBIC:\n");
       for(i=0;i<=q;i++)
	 {printf("%10.5lf ",BIC1[i]);
	  fprintf(f,"%10.5lf ",BIC1[i]);
	  fprintf(g,"%10.5lf,",BIC1[i]);
	 }
       printf("\n");fprintf(f,"\n");fprintf(g,"\n");
    break;
	case 4:
       f1=fopen("corel.txt","w+");
       for(i=0;i<=ordin;i++)
	 {printf("corel[%d]=%10.7lf\n",i,corel[i]);
	  fprintf(f1,"%10.7lf\n",corel[i]);
	 }
       fclose(f1);
       printf("ARMA(%d;%d) coefficients:\n",p,q);
       fprintf(f,"ARMA(%d;%d) coefficients:\n",p,q);
       fprintf(g,"ARMA(%d;%d) coefficients:\n",p,q);
       printf("Polynomial phi:\n");
       fprintf(f,"Polynomial phi:\n");
       fprintf(g,"Polynomial phi:\n");
       for(i=1;i<=p;i++)
	 {printf("%10.5lf ",fi[i]);
	  fprintf(f,"%10.5lf ",fi[i]);
	  fprintf(g,"%10.5lf,",fi[i]);
	 }
       printf("\n");fprintf(f,"\n");fprintf(g,"\n");
       printf("Polynomial theta:\n");
       fprintf(f,"Polynomial theta:\n");
       fprintf(g,"Polynomial theta:\n");
       for(i=1;i<=q;i++)
	 {printf("%10.5lf ",teta[i]);
	  fprintf(f,"%10.5lf ",teta[i]);
	  fprintf(g,"%10.5lf,",teta[i]);
	 }
       printf("\n");fprintf(f,"\n");fprintf(g,"\n");
       printf("Variance of the errors=%10.5lf\n",disper);
       fprintf(f,"Variance of the errors=%10.5lf\n",disper);
       fprintf(g,"Variance of the errors=,%10.5lf\n",disper);
	   printf("AIC=%10.5lf\n",aic);
       fprintf(f,"AIC=%10.5lf\n",aic);
       fprintf(g,"AIC=,%10.5lf\n",aic);
       printf("BIC=%10.5lf\n",bic);
       fprintf(f,"BIC=%10.5lf\n",bic);
       fprintf(g,"BIC=,%10.5lf\n",bic);
    break;
    default:
      printf("Coefficients:\n");
      fprintf(f,"Coefficients:\n");
      fprintf(g,"Coefficients:\n");
      for(i=1;i<=model;i++)
	{printf("%10.5lf ",coef[i]);
	 fprintf(f,"%10.5lf ",coef[i]);
	 fprintf(g,"%10.5lf,",coef[i]);
	}
      printf("\n");fprintf(f,"\n");fprintf(g,"\n");
      printf("Student statistics:\n");
      fprintf(f,"Student statistics:\n");
      fprintf(g,"Student statistics:\n");
      for(i=1;i<=model;i++)
	{printf("%10.5lf ",lstud[i]);
	 fprintf(f,"%10.5lf ",lstud[i]);
	 fprintf(g,"%10.5lf,",lstud[i]);
	}
      printf("\n");fprintf(f,"\n");fprintf(g,"\n");
   }



 fclose(f);fclose(g);

 printf("ENTER");scanf("%c",&ch);scanf("%c",&ch);
}


is copied from the LINUX file copied on memory stick after

// estsert.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
After this I make it executable, and I can run the program on computers that has only Windows as operating system.

My question is if I can make an Windows executable program from a C++ program on LINUX, without accesing a computer with Windows.

Sincerely,
Daniel Ciuiu

Last edited by onebuck; 06-02-2017 at 10:45 AM. Reason: clean up post with code tags
 
Old 05-22-2017, 08:18 PM   #35
NoStressHQ
Member
 
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609

Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by ciuiu View Post
I have a C++ program called estsert.cpp, that estimates the parameters of an AR(p), MA(q) or ARMA(p,q) time series.
[...]
My question is if I can make an Windows executable program from a C++ program on LINUX, without accesing a computer with Windows.

Sincerely,
Daniel Ciuiu
Please use
Code:
[code][/code]
tags to post source code (or command lines)...

Also check http://mxe.cc/

Bests,

G.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
DISCUSSION: Compiling Programs from Source jeremy LinuxAnswers Discussion 52 03-02-2024 12:26 PM
DISCUSSION: Building C programs on Linux crabboy LinuxAnswers Discussion 29 09-04-2013 10:19 AM
DISCUSSION: Building a Slackware Wireless Access Point eric.r.turner LinuxAnswers Discussion 11 09-09-2006 01:36 AM
DISCUSSION: ssh w/ gtk programs (host-client display export) mrchaos LinuxAnswers Discussion 1 12-14-2005 01:50 PM
DISCUSSION: Virtual Filesystem: Building a Linux Filesystem from an Ordinary File mchirico LinuxAnswers Discussion 0 10-28-2004 10:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxAnswers Discussion

All times are GMT -5. The time now is 09:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration