You are not logged in.
First off, if this is the wrong place to post, my apologies. I'm running arch off a raspberry pi, and sshing into it on my computer (a mac, if it makes a difference), and I was wondering how I could run c++ programs on it. I don't want to install a desktop environment, because I think using terminal is a cool challenge. I'm assuming I can just use nano or some other text editor to write them, but how do I get them to run, as well as get all the libraries I would need? I am thinking just things that run in terminal, no programs with a gui. Any suggestions?
Offline
Hi, I should say this kind of post is not usually encouraged here; people usually expect you to do some research first and tell them what have you tried, before posting.
However, since you seem not to have any directions, I think it's fair to give you some.
I would advise you to search for those keywords / programs (see also our Wiki):
- SSH (I think you have already done that)
- a C++ compiler. Usually g++ (present in the gcc package) or clang. I would recommend g++.
- a terminal text editor. Emacs or vim are usually choices that advanced users prefer; however, if you don't know them (yet), you should probably use something easier for novices, such as nano. If you opt for emacs, install the emacs-nox package.
That's all you need, really. You might want a program such as make or cmake later, to aid you with your build management. There are several tutorials out there teaching how to do that. Search for 'hello world' ones.
Offline
First, I am going to suggest you take Arch Arm questions to their forums. They are the experts.
But, what you ask is easy -- if the tools are installed on your ras-pi. Here is some code I did not write that generates data that can be piped to gnuplot to animate a Lorenz attractor.
ewaller$@$odin ~/devel/C/lorenz [130]1026 %cat lorenz.cpp
#include <iostream>
#define tab "\t"
using namespace std;
void lorenz(double *x,double *dxdt)
{
dxdt[0]=10.0*(x[1]-x[0]);
dxdt[1]=28.0*x[0]-x[1]-x[0]*x[2];
dxdt[2]=-2.666666666666*x[2]+x[0]*x[1];
}
int main(int argc,char **argv)
{
int len=300;
double x[len*3],dxdt[3],dt=0.01;
x[0]=1.0;x[1]=1.0;x[2]=1.0;
int cur=0,next=1;
for(int i=1;i<len*10;i++)
{
lorenz(x+3*cur,dxdt);
for(int j=0;j<3;j++) x[3*next+j]=x[3*cur+j]+dt*dxdt[j];
if(++cur == len) cur=0;
if(++next == len) next=0;
}
for(double t=0.0;t<100000000.0;t+=dt)
{
cout<<"sp [-30:30][-30:30][0:50] '-' w l"<<endl;
for(int i=cur+1;i<len;i++)
cout<<tab<<x[3*i]<<tab<<x[3*i+1]<<tab<<x[3*i+2]<<endl;
for(int i=0;i<cur+1;i++)
cout<<tab<<x[3*i]<<tab<<x[3*i+1]<<tab<<x[3*i+2]<<endl;
cout<<'e'<<endl;
lorenz(x+3*cur,dxdt);
for(int j=0;j<3;j++) x[3*next+j]=x[3*cur+j]+dt*dxdt[j];
if(++cur == len) cur=0;
if(++next == len) next=0;
}
return 0;
}
ewaller$@$odin ~/devel/C/lorenz 1027 %g++ lorenz.cpp
ewaller$@$odin ~/devel/C/lorenz 1028 %./a.out|head
sp [-30:30][-30:30][0:50] '-' w l
-9.3252 -8.45882 29.0952
-9.23857 -8.27211 29.1081
-9.14192 -8.08701 29.0961
-9.03643 -7.90593 29.0595
-8.92338 -7.73113 28.999
-8.80415 -7.56467 28.9156
-8.68021 -7.40841 28.8105
-8.55303 -7.26397 28.6853
-8.42412 -7.13271 28.5417
ewaller$@$odin ~/devel/C/lorenz 1029 %
You may want to set up a cross compiler on your x86_64 Arch system for ARM. That we can help you with....
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline