From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id QPpzBioHMmMGXwAAbAwnHQ (envelope-from ) for ; Mon, 26 Sep 2022 22:10:18 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id kM9xBioHMmMoYAEA9RJhRA (envelope-from ) for ; Mon, 26 Sep 2022 22:10:18 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id C03E3EB41 for ; Mon, 26 Sep 2022 22:10:17 +0200 (CEST) Received: from localhost ([::1]:52192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocuQi-0007Nj-SZ for larch@yhetil.org; Mon, 26 Sep 2022 16:10:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48146) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocuDI-0003kW-0F for emacs-orgmode@gnu.org; Mon, 26 Sep 2022 15:56:24 -0400 Received: from smtp5-g21.free.fr ([212.27.42.5]:11400) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocuDF-0006U2-Jy for emacs-orgmode@gnu.org; Mon, 26 Sep 2022 15:56:23 -0400 Received: from [IPv6:2a01:e35:39f3:4610:ece7:be1b:6549:b9b7] (unknown [IPv6:2a01:e35:39f3:4610:ece7:be1b:6549:b9b7]) (Authenticated sender: tbanelwebmin@free.fr) by smtp5-g21.free.fr (Postfix) with ESMTPSA id 2FBE65FFAA for ; Mon, 26 Sep 2022 21:56:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=free.fr; s=smtp-20201208; t=1664222179; bh=un7p1IyUZGNZKtvy3pNhthe9SRSg220AUPRxCTk6+e4=; h=Subject:To:References:From:Date:In-Reply-To:From; b=uOxUJiqce/U4jAdwkajXfCROGOWzLH2v9du4HRiZLDmaaMF4T+2xlYJguHk8VFS+c C7Gfap+I6cLoLGnplRXo3S5KwCUTJEQsKDMKJsqoQ6ISY/Yxwa0lO9J605Xw4znJKB 6ei7X4UFDfqwHjy1Q6kZixV5+x3CNC72LRLYsKaWw+EJEr3IBAwswOfC8M8vxJ2df8 8tKNFzyYiDiCP3pdIwxRhPmR83/A8gRgm1KbWCjD+ebAk4VDTuNFsJHQgX0EHkfn07 oQdV7TfDUFQqqTQ9PJmErCedW8HVa9438tV1ZxtO8KchfHS0vWlE0VsbGdVYZnLKNC nfSJODTBaZH5A== Subject: Re: Compiling a C++ source block To: emacs-orgmode@gnu.org References: From: tbanelwebmin Message-ID: <756c0374-abef-8e73-e765-9cfeb03bb462@free.fr> Date: Mon, 26 Sep 2022 21:56:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/html; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=212.27.42.5; envelope-from=tbanelwebmin@free.fr; helo=smtp5-g21.free.fr X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, MIME_HTML_ONLY=0.1, NICE_REPLY_A=-2.319, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1664223017; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=OP9SbxmOzGWWWvDRoz3wDxjGmWV7qPljWw0iABPyRRk=; b=Z1CD5lyYIW0SS9OlReQ3eCD3kr8WtCtBaf9oSwqUqcHVEQUQ9ZGmwzHrjjH6+Y6Tqcye8F 1JylIH0sY3luljhjRZSP3MGvxcpObiJbRPBD9qPBohnF0ATvs9/GVMnfnix4iCtifKhEcf 6I+IM2Tw9b0sq6dUo+/H4++Vs2UDHjz+zWIGu9A+semHyE4/HdAFt2nzk/1FOn0U5BsjfP /mBT3vHaQ4E7FN0z0sH6QK+TYt2VObG0jBAFO85VKuZrCCjZHtUW8+SlMOwv2v3zfg/M/M WHpXe8z1dRCekZgjO/7CVM06Da32i4OeLRp4HOkko308tV3eIDneGknunB+bcg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1664223017; a=rsa-sha256; cv=none; b=TDegca9crzEJNh8s+QdD9t6d+aw1CyT+SA7M7m378MJE+ee9AXuy/RUUV9pK5QFLGSQ63v fRcw59CA7VWggytjU1p/BsGayGV+9YETvWaqb4nYRz6KKEJO59IYZmaRbld2ghLDBqlN4U i/WuM+Vr0G3xAtIoh9oH85LLpbB7Jmvz30Lk0Betk0J8PMQOvnjOrV/EVWtCtA+V3cN8UO e81kGRor+ImgGc6hRIXYmCLOXv1AaAMRREcZRlkGkPoEP1vSRSYT3f2tjRtVaVDnZJoZ8m T0dejYPPN12aTujnFzFzw8XcQOnaOhjJ2d01V3S28k2dbPbLqGTOVtbkYVpILA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=free.fr header.s=smtp-20201208 header.b=uOxUJiqc; dmarc=pass (policy=none) header.from=free.fr; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -7.55 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=free.fr header.s=smtp-20201208 header.b=uOxUJiqc; dmarc=pass (policy=none) header.from=free.fr; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: C03E3EB41 X-Spam-Score: -7.55 X-Migadu-Scanner: scn0.migadu.com X-TUID: Okc0JVZm509r You may try:
#+header: :includes '("<iostream>" "<ginac.h>")

Also, you have this commented line:
# #+header: :var table=
It seems to break the #+header: chain
Just remove it.

By the way, to figure out future compilation problems, you may click on the error:
/tmp/babel-eqG2i0/C-src-3zG2ec.cpp:16:1: error: unknown type name 'ex'
This will open the source file actually being compiled.

Have fun!



Le 26/09/2022 à 21:13, Roger Mason a écrit :
Hello,

I wish to compile & run this source block in org-mode:

#+name: gnc_cav
#+header: :includes  <iostream> <ginac.h>
#+header: :libs -L/usr/local/lib -lginac -lcln
#+header: :flags -std=c++17
#+header: :namespaces std GiNaC
# #+header: :var table=
#+header: :var job="vectors" :var vol=113.13115406160385926 :var r=1.0995524816924328312
#+header: :var a=4.916 :var c=5.4054
#+header: :main no
#+begin_src  C++
    ex vol(symbol a, symbol c)
    {
      ex v = a*a * c * sin(60*Pi/180);

      return v;
    }

    ex coa(symbol a, symbol c) {
      ex covera = c/a;

      return covera;
    }

    ex scl(symbol a, symbol c, double ad, double cd) {

      //  symbol v("v");
      // symbol r("r");
      ex v = vol(a,c);

      ex r = coa(a,c);
      numeric three(3);

      //  ex s = power(v.subs(lst{a==ad,c==cd})),1/three)/(power(sin(60*Pi/180),1/three) * power(r.subs(lst{a==ad,c==cd}),1/three));
      ex s = power(v.subs(lst{a==ad,c==cd}),1/three)/(power(sin(60*Pi/180),1/three) * power(r.subs(lst{a==ad,c==cd}),1/three));

      return s;
    }

    ex scl(double vd, double rd) {

      numeric three(3);

      ex s = power(vd,1/three)/(power(sin(60*Pi/180),1/three) * power(rd,1/three));

      return s;
    }

    int main () {
      if ( strncmp(job, "volume", 6) == 0) { // ./v volume a c, calculate volume

	symbol as("as");
	symbol cs("cs");

	ex v = vol(as, cs);
	cout << "Volume = " << v.subs(lst{as == a, cs == c}).evalf() << "\n";

	ex r = coa(as, cs);
	cout << "c/a = " << r.subs(lst{as == a, cs == c}).evalf() << "\n";

	ex a_calc = scl(as, cs, a, c);
	cout << "a_calc = " << a_calc.evalf() << "\n";
	cout << "c_calc = "
	     << a_calc.evalf() * r.subs(lst{as == a, cs == c}).evalf() << "\n";

      } else if ( job,"vectors",5) == 0 ) { // ./v vectors vol c/a

	//double vd = stod(argv[2]);
	//double rd = stod(argv[3]);
	ex a_calc = scl(v,r);
	cout << "a_calc = " << a_calc.evalf() << "\n";
	cout << "c_calc = " << a_calc.evalf() * rd << "\n";

	//double a_scale = a;
      } // vectors
    } // main

#+end_src

When I attempt compilation using 'C-c C-c' I get:

/tmp/babel-eqG2i0/C-src-3zG2ec.cpp:16:1: error: unknown type name 'ex'
ex vol(symbol a, symbol c)

and lots of similar errors.  I infer this is because ginac.h is not
found.  I have tried specifying <ginac/ginac.h> in ':includes' to no
avail.  I have tried specifying the full path to ginac.h:
</usr/local/lib/ginac/ginac.h> and specifying -I/usr/local/lib/ginac/ as
part of ':includes', but the error persists.

Maybe the C++ support is not set up to handle this use case, but perhaps
I am missing something.

Any help will be much appreciated.

Thanks,
Roger