kpeeters / cadabra2

A field-theory motivated approach to computer algebra.
https://cadabra.science/
GNU General Public License v3.0
216 stars 37 forks source link

Cadabra as C++ library: Cannot find the 'treetracker.h' file in './treetracker' #137

Closed TCodina closed 5 years ago

TCodina commented 5 years ago

Hello there. I already have cadabra2 inside jupyter notebook but I'd like to have the chance to use it as a C++ library from time to time. However, when I try to build the library from source following the GitHub instructions I get the following error:

cmake .. -- The C compiler identification is GNU 7.3.0 -- The CXX compiler identification is GNU 7.3.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- CMake version = 3.13.4 -- Found gmp /usr/lib/x86_64-linux-gnu/libgmp.so -- Found gmpxx /usr/lib/x86_64-linux-gnu/libgmpxx.so -- Found PCRE: /usr/lib/x86_64-linux-gnu/libpcrecpp.so
CMake Error at CMakeLists.txt:188 (message): -- Cannot find the 'treetracker.h' file in './treetracker'

-- Configuring incomplete, errors occurred! See also "/home/tomaco/Tomaco/Hobbies/Programacion/Cadabra/cadabra2/c++lib/build/CMakeFiles/CMakeOutput.log".

I guess that I don't have that header... What should I do?

kpeeters commented 5 years ago

Add the -DUSE_TREETRACKER=OFF flag to the cmake command. I should probably make that the default.

TCodina commented 5 years ago

Yes, I tried that before but I get another problem when I run the make command at approximately 97% in SympyDummies.cc, because that file depends on treetracker.h. I get the following error:

[ 1%] Building CXX object CMakeFiles/cadabra2++objects.dir/SympyDummy.cc.o /home/tomaco/Tomaco/Hobbies/Programacion/Cadabra/cadabra2/c++lib/SympyDummy.cc:7:10: fatal error: treetracker.h: No such file or directory

include "treetracker.h"

      ^~~~~~~~~~~~~~~

compilation terminated. CMakeFiles/cadabra2++objects.dir/build.make:1609: recipe for target 'CMakeFiles/cadabra2++objects.dir/SympyDummy.cc.o' failed make[2]: [CMakeFiles/cadabra2++objects.dir/SympyDummy.cc.o] Error 1 CMakeFiles/Makefile2:109: recipe for target 'CMakeFiles/cadabra2++objects.dir/all' failed make[1]: [CMakeFiles/cadabra2++objects.dir/all] Error 2 Makefile:129: recipe for target 'all' failed make: *** [all] Error 2

Then, I tried commenting #include "treetracker.h" inside SympyDummies but it did not work yet I get:

[ 1%] Building CXX object CMakeFiles/cadabra2++objects.dir/SympyDummy.cc.o /home/tomaco/Tomaco/Hobbies/Programacion/Cadabra/cadabra2/c++lib/SympyDummy.cc:11:61: error: ‘tree::iterator sympy::apply(const cadabra::Kernel&, cadabra::Ex&, tree::iterator&, const std::vector<std::__cxx11::basic_string >&, const string&, const string&)’ should have been declared inside ‘sympy’ const std::string& method) ^ /home/tomaco/Tomaco/Hobbies/Programacion/Cadabra/cadabra2/c++lib/SympyDummy.cc: In function ‘tree::iterator sympy::apply(const cadabra::Kernel&, cadabra::Ex&, tree::iterator&, const std::vector<std::__cxx11::basic_string >&, const string&, const string&)’: /home/tomaco/Tomaco/Hobbies/Programacion/Cadabra/cadabra2/c++lib/SympyDummy.cc:13:21: error: aggregate ‘std::ostringstream str’ has incomplete type and cannot be defined std::ostringstream str; ^~~ /home/tomaco/Tomaco/Hobbies/Programacion/Cadabra/cadabra2/c++lib/SympyDummy.cc: At global scope: /home/tomaco/Tomaco/Hobbies/Programacion/Cadabra/cadabra2/c++lib/SympyDummy.cc:53:100: error: ‘cadabra::Ex sympy::invert_matrix(const cadabra::Kernel&, cadabra::Ex&, cadabra::Ex&)’ should have been declared inside ‘sympy’ vert_matrix(const cadabra::Kernel& kernel, cadabra::Ex& ex, cadabra::Ex& rules) ^ CMakeFiles/cadabra2++objects.dir/build.make:1609: recipe for target 'CMakeFiles/cadabra2++objects.dir/SympyDummy.cc.o' failed make[2]: [CMakeFiles/cadabra2++objects.dir/SympyDummy.cc.o] Error 1 CMakeFiles/Makefile2:109: recipe for target 'CMakeFiles/cadabra2++objects.dir/all' failed make[1]: [CMakeFiles/cadabra2++objects.dir/all] Error 2 Makefile:129: recipe for target 'all' failed make: *** [all] Error 2

kpeeters commented 5 years ago

This is now fixed on github, please give it a shot if you are still interested.

TCodina commented 5 years ago

Thank you so much, it works! I am having a few troubles with the include path but I guess I will figure it out on my own. Regarding my interest in cadabra2 as a C++ library, nowadays I am trying to make an "all_contractions" program to take a few objects with particular indices and symmetries and get the most general combination (contraction) of them. If I am not mistaken, I think that you had a version of that program on cadabra1, but I do not find it in cadabra 2. These days I am trying to make a humble version of the program using a mixed between python and cadabra2 tools inside jupyter notebook, but now that you solved the C++library problem I guess that it would be much more easier from the source code of cadabra2, is it true? I would appreciate every advice you can give me regarding this program that I would like to build!

Best wishes, Tomas.

On Thu, 9 May 2019 at 12:16, Kasper Peeters notifications@github.com wrote:

This is now fixed on github, please give it a shot if you are still interested.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kpeeters/cadabra2/issues/137#issuecomment-490947104, or mute the thread https://github.com/notifications/unsubscribe-auth/AH2SJ4XHH3VPFB7Y35M4GWDPUQ533ANCNFSM4G4O7W4Q .

kpeeters commented 5 years ago

The all_contractions algorithm is no longer present in cadabra2 because it was only incompletely implemented in cadabra1. This problem is quite a bit more tricky than you might think. There are two issues which cadabra1 did not solve:

This may not matter for your particular application, but it is good to keep this in mind.

We are at the moment implementing new algorithms which handle the first problem correctly, but have not yet tackled the second one. If you are interested I am happy to discuss this with you though. Email me privately.