From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Hannon Subject: Re: Details of compling and running C++ code from Org-mode? Date: Sat, 19 Nov 2011 12:27:26 -0800 (PST) Message-ID: <1321734446.10889.YahooMailNeo@web161920.mail.bf1.yahoo.com> References: <1320479064.94834.YahooMailNeo@web161908.mail.bf1.yahoo.com> <87vcqhgqu3.fsf@gmail.com> Reply-To: Michael Hannon Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:52502) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRrVZ-0006PN-Gf for emacs-orgmode@gnu.org; Sat, 19 Nov 2011 15:27:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RRrVY-00035d-3R for emacs-orgmode@gnu.org; Sat, 19 Nov 2011 15:27:29 -0500 Received: from nm29.bullet.mail.bf1.yahoo.com ([98.139.212.188]:44572) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1RRrVX-00035X-UD for emacs-orgmode@gnu.org; Sat, 19 Nov 2011 15:27:28 -0500 In-Reply-To: <87vcqhgqu3.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: Org-Mode List Nice.=A0 Very interesting and informative.=A0 Thanks, Eric.=0A=0A-- Mike=0A= =0A=0A=0A----- Original Message -----=0A> From: Eric Schulte =0A> To: Michael Hannon =0A> Cc: Org-Mode Li= st =0A> Sent: Friday, November 18, 2011 11:39 AM=0A>= Subject: Re: [O] Details of compling and running C++ code from Org-mode?= =0A> =0A> Hi Michael,=0A> =0A> Michael Hannon writes:= =0A> =0A>> Greetings.=A0 I'm curious about the process of executing a prog= ram that =0A> is=0A>> compiled from a source block in Org-mode.=0A>> =0A>>= Some background: I was playing with some C++ code (a slight generalizatio= n =0A> of=0A>> some code I found in a book).=A0 I wanted to use the "assig= n" =0A> method to=0A>> initialize a vector, as:=0A>> =0A>> =A0=A0=A0 vect= or testVec(5, 0);=0A>> =A0=A0=A0 testVec.assign({2, 4, 6, 8, 10});=0A= >> =0A>> It turns out that to do this one has to tell g++ (in my case) to = use the=0A>> latest version of the C++ standard.=A0 I discovered that I co= uld do this via:=0A>> =0A>> =A0=A0=A0 (setq org-babel-C++-compiler "g++ -s= td=3Dc++0x")=0A>> =0A> =0A> You could also use the :flags header argument (= :flags "-std=3Dc++0x") to=0A> pass this flag to g++.=0A> =0A>> =0A>> This = got me to wondering if there were any similar hooks that relate to=0A>> ru= nning the program once it's compiled.=A0 I looked through the list of=0A>> = org-babel* variables, but didn't find anything obvious.=0A>> =0A>> So wha= t does happen when I hit C-c C-c in, say, a cpp source-code block?=A0 =0A> = The=0A>> contents of the file are evidently written to a temporary file, a= fter which=0A>> the command specified by org-babel-C++-compiler is run on = that file.=A0 The=0A>> results of the compilation are stuck some place -- = another temporary file, =0A> I=0A>> suppose.=A0 Then the second, executabl= e file is run and the results=0A>> collected.=0A> =0A> Thanks for asking t= his question, and sorry it took so long to respond.=0A> I've placed an anno= tated copy of the relevant code up at [1] which=0A> should explain the eval= uation process for c/c++ code.=A0 In many cases=0A> browsing the relevant o= rg-babel-execute:* function for your language is=0A> the best way to discov= er what flags are available.=0A> =0A>> =0A>> What command runs the file?= =0A> =0A> The file itself is called directly.=0A> =0A>> =A0 Is there any c= ontrol from Org-mode over this second stage of the=0A>> process?=0A> =0A> = Yes, the :cmdline header argument may be used to pass values to the=0A> exe= cuting file.=0A> =0A> Best -- Eric=0A> =0A>> =0A>> Thanks,=0A>> =0A>> -- = Mike=0A>> =0A> =0A> =0A> Footnotes: =0A> [1]=A0 http://cs.unm.edu/~eschulte= /data/babel-c-execution.html=0A> =A0 =A0 http://cs.unm.edu/~eschulte/data/= babel-c-execution.org=0A> =0A> -- =0A> Eric Schulte=0A> http://cs.unm.edu/~= eschulte/=0A>