* C++ code block not linked
@ 2017-11-25 14:59 Roger Mason
2017-11-25 15:38 ` Thierry Banel
0 siblings, 1 reply; 9+ messages in thread
From: Roger Mason @ 2017-11-25 14:59 UTC (permalink / raw)
To: Org-Mode
Hello,
This code compiles fine on command line but org-babel can't link it.
#+BEGIN_SRC C++ :flags "-std=c++11 -I/usr/local/include" :libs "-L/usr/local/lib -lginac"
#include <iostream>
#include <ginac/ginac.h>
using namespace std;
using namespace GiNaC;
int main () {
symbol a("a"), b("b"), x("x"), y("y");
lst eqns, vars;
eqns = a*x+b*y==3, x-y==b;
vars = x, y;
cout << lsolve(eqns, vars) << endl;
// -> {x==(3+b^2)/(b+a),y==(3-b*a)/(b+a)
return 0;
}
#+END_SRC
The error buffer contains many lines like this:
/tmp//ccv5YYn1.o: In function `main':
C-src-1046xti.cpp:(.text+0x67): undefined reference to `GiNaC::symbol::symbol(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
Org mode version 9.0.3 (release_9.0.3-170-gfed1cf @
/home/rmason/.emacs.d/org-git/org-mode/lisp/)
GNU Emacs 25.3.1 (i386-portbld-freebsd10.3, GTK+ Version 3.22.15) of
2017-11-22
Thanks for any help.
Roger
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: C++ code block not linked
2017-11-25 14:59 C++ code block not linked Roger Mason
@ 2017-11-25 15:38 ` Thierry Banel
2017-11-26 11:42 ` Roger Mason
0 siblings, 1 reply; 9+ messages in thread
From: Thierry Banel @ 2017-11-25 15:38 UTC (permalink / raw)
To: emacs-orgmode
On 25/11/2017 15:59, Roger Mason wrote:
> Hello,
>
> This code compiles fine on command line but org-babel can't link it.
>
> #+BEGIN_SRC C++ :flags "-std=c++11 -I/usr/local/include" :libs "-L/usr/local/lib -lginac"
> #include <iostream>
> #include <ginac/ginac.h>
> using namespace std;
> using namespace GiNaC;
>
> int main () {
> symbol a("a"), b("b"), x("x"), y("y");
> lst eqns, vars;
> eqns = a*x+b*y==3, x-y==b;
> vars = x, y;
> cout << lsolve(eqns, vars) << endl;
> // -> {x==(3+b^2)/(b+a),y==(3-b*a)/(b+a)
>
> return 0;
> }
> #+END_SRC
>
> The error buffer contains many lines like this:
>
> /tmp//ccv5YYn1.o: In function `main':
> C-src-1046xti.cpp:(.text+0x67): undefined reference to `GiNaC::symbol::symbol(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
>
>
> Org mode version 9.0.3 (release_9.0.3-170-gfed1cf @
> /home/rmason/.emacs.d/org-git/org-mode/lisp/)
>
> GNU Emacs 25.3.1 (i386-portbld-freebsd10.3, GTK+ Version 3.22.15) of
> 2017-11-22
>
> Thanks for any help.
>
> Roger
>
>
I get the correct result:
#+RESULTS:
| {x==(3+b^2)*(a+b)^(-1) | y==-(-3+a*b)*(a+b)^(-1)} |
I use Or mode version 9.1.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: C++ code block not linked
2017-11-25 15:38 ` Thierry Banel
@ 2017-11-26 11:42 ` Roger Mason
2017-11-27 7:33 ` Thierry Banel
0 siblings, 1 reply; 9+ messages in thread
From: Roger Mason @ 2017-11-26 11:42 UTC (permalink / raw)
To: emacs-orgmode
Hello,
Thierry Banel <tbanelwebmin@free.fr> writes:
> On 25/11/2017 15:59, Roger Mason wrote:
>> This code compiles fine on command line but org-babel can't link it.
>>
>> #+BEGIN_SRC C++ :flags "-std=c++11 -I/usr/local/include" :libs "-L/usr/local/lib -lginac"
>> #include <iostream>
>> #include <ginac/ginac.h>
>> using namespace std;
>> using namespace GiNaC;
>>
>> int main () {
>> symbol a("a"), b("b"), x("x"), y("y");
>> lst eqns, vars;
>> eqns = a*x+b*y==3, x-y==b;
>> vars = x, y;
>> cout << lsolve(eqns, vars) << endl;
>> // -> {x==(3+b^2)/(b+a),y==(3-b*a)/(b+a)
>>
>> return 0;
>> }
>> #+END_SRC
>>
>> The error buffer contains many lines like this:
>>
>> /tmp//ccv5YYn1.o: In function `main':
>> C-src-1046xti.cpp:(.text+0x67): undefined reference to `GiNaC::symbol::symbol(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
>>
>
> I get the correct result:
>
> #+RESULTS:
> | {x==(3+b^2)*(a+b)^(-1) | y==-(-3+a*b)*(a+b)^(-1)} |
>
> I use Or mode version 9.1.1
I just upgraded to Org mode version 9.1.3 (release_9.1.3-185-g579fa1 @
/home/rmason/.emacs.d/org-git/lisp/) and I'm still getting the link
error.
Cheers,
Roger
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: C++ code block not linked
2017-11-26 11:42 ` Roger Mason
@ 2017-11-27 7:33 ` Thierry Banel
2017-11-27 11:04 ` Roger Mason
0 siblings, 1 reply; 9+ messages in thread
From: Thierry Banel @ 2017-11-27 7:33 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/html, Size: 2416 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: C++ code block not linked
2017-11-27 7:33 ` Thierry Banel
@ 2017-11-27 11:04 ` Roger Mason
2017-11-28 17:08 ` C++ code block not linked [SOLVED] Roger Mason
0 siblings, 1 reply; 9+ messages in thread
From: Roger Mason @ 2017-11-27 11:04 UTC (permalink / raw)
To: Thierry Banel; +Cc: emacs-orgmode
Hello Thierry,
Thierry Banel <tbanelwebmin@free.fr> writes:
> You may try to mimic org-babel in a shell, and see what happens.
>
> cd /tmp/babel-29466ws7
> g++ -std=c++11 -I/usr/local/include C-src-29466moy.cpp -L/usr/local/lib -lginac
>
> (of course you need to change the random names like babel-29466ws7 by the actual ones as generated
> on your system).
It compiles fine:
c++ -std=c++11 -I/usr/local/include -L/usr/local/lib -lginac C-src-1053hn1.cpp
C-src-1053hn1.cpp:16:10: warning: 'operator=' is deprecated [-Wdeprecated-declarations]
eqns = a*x+b*y==3, x-y==b;
^
/usr/local/include/ginac/container.h:199:27: note: 'operator=' declared here
container_init<ex, STLT> operator=(const ex & x) attribute_deprecated;
^
C-src-1053hn1.cpp:17:10: warning: 'operator=' is deprecated [-Wdeprecated-declarations]
vars = x, y;
^
/usr/local/include/ginac/container.h:199:27: note: 'operator=' declared here
container_init<ex, STLT> operator=(const ex & x) attribute_deprecated;
^
2 warnings generated.
Thanks for your help
Roger
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: C++ code block not linked [SOLVED]
2017-11-27 11:04 ` Roger Mason
@ 2017-11-28 17:08 ` Roger Mason
2017-11-28 17:27 ` Thierry Banel
0 siblings, 1 reply; 9+ messages in thread
From: Roger Mason @ 2017-11-28 17:08 UTC (permalink / raw)
To: emacs-orgmode
Hello,
Roger Mason <rmason@MUN.CA> writes:
> It compiles fine:
>
> c++ -std=c++11 -I/usr/local/include -L/usr/local/lib -lginac
> C-src-1053hn1.cpp
Solved by setting:
(setq org-babel-C++-compiler "c++")
I don't recall having had to do this before.
Phew! Very glad to have this working again. I'm not aware of any other tool
that is as good as org-mode for literate programming and reproducible
research. A big thank you to those who created and maintain it.
Cheers,
Roger
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: C++ code block not linked [SOLVED]
2017-11-28 17:08 ` C++ code block not linked [SOLVED] Roger Mason
@ 2017-11-28 17:27 ` Thierry Banel
2017-11-28 21:07 ` Nick Dokos
0 siblings, 1 reply; 9+ messages in thread
From: Thierry Banel @ 2017-11-28 17:27 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/html, Size: 1789 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: C++ code block not linked [SOLVED]
2017-11-28 17:27 ` Thierry Banel
@ 2017-11-28 21:07 ` Nick Dokos
2017-11-29 15:38 ` Roger Mason
0 siblings, 1 reply; 9+ messages in thread
From: Nick Dokos @ 2017-11-28 21:07 UTC (permalink / raw)
To: emacs-orgmode
Thierry Banel <tbanelwebmin@free.fr> writes:
> On 28/11/2017 18:08, Roger Mason wrote:
>
> Hello,
>
> Roger Mason <rmason@MUN.CA> writes:
>
> It compiles fine:
>
> c++ -std=c++11 -I/usr/local/include -L/usr/local/lib -lginac
> C-src-1053hn1.cpp
>
> Solved by setting:
>
> (setq org-babel-C++-compiler "c++")
>
> I don't recall having had to do this before.
>
> Phew! Very glad to have this working again. I'm not aware of any other tool
> that is as good as org-mode for literate programming and reproducible
> research. A big thank you to those who created and maintain it.
>
> Cheers,
> Roger
>
> Good to know it is solved.
> You can customize this variable:
> C-h v org-babel-C++-compiler
>
> In case someone else bump into a similar problem, the actual command launched by Babel can be obtained
> through the debugger:
> M-x debug-on-entry RET org-babel-eval RET
> evaluate the Babel block
> The debugger shows a line like this one:
> * org-babel-eval("g++ -o /tmp/babel-3110Zeg/C-bin-3110Fwh -std=c++11 ...
> This works for many languages supported by Babel.
>
All very good info, but why did the OP not have a g++? Using a
non-linux operating system? Using a non-GNU tool chain? Inquiring
minds want to know...
--
Nick
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: C++ code block not linked [SOLVED]
2017-11-28 21:07 ` Nick Dokos
@ 2017-11-29 15:38 ` Roger Mason
0 siblings, 0 replies; 9+ messages in thread
From: Roger Mason @ 2017-11-29 15:38 UTC (permalink / raw)
To: Nick Dokos; +Cc: emacs-orgmode
Hello,
Nick Dokos <ndokos@gmail.com> writes:
> All very good info, but why did the OP not have a g++? Using a
> non-linux operating system? Using a non-GNU tool chain? Inquiring
> minds want to know...
Running on FreeBSD 10.3, which uses clang/clang++ by default. That
said, I _do_ have gcc 5.4.0 installed and accessible as gcc/g++, so I
don't know why it did not work.
Cheers,
Roger
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-11-29 15:38 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-25 14:59 C++ code block not linked Roger Mason
2017-11-25 15:38 ` Thierry Banel
2017-11-26 11:42 ` Roger Mason
2017-11-27 7:33 ` Thierry Banel
2017-11-27 11:04 ` Roger Mason
2017-11-28 17:08 ` C++ code block not linked [SOLVED] Roger Mason
2017-11-28 17:27 ` Thierry Banel
2017-11-28 21:07 ` Nick Dokos
2017-11-29 15:38 ` Roger Mason
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.