Newsgroup: it.comp.os.linux.development
Titolo: compilare powerLoom

Per una tesi di domotica dovrei usare la versione c++ di PowerLoom.
Secondo il manuale per compilare la versione c++ (quella Java funziona
tranquillamente in Windows XP) dovrebbe bastare:
To compile the C++ version of PowerLoom, change to the native C++
directory of PowerLoom
and run make like this:
% cd native/cpp/powerloom
% make
Ho provato con una distro live di Ubuntu, disinstallando e reinstallando
g++ ma ottengo questi messaggi di errore:
root@ubuntu:/home/ubuntu# sudo apt-get install gcc build-essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  dpkg-dev g++ g++-4.1 libc6-dev libstdc++6-4.1-dev linux-libc-dev
Suggested packages:
  debian-keyring gcc-4.1-doc lib64stdc++6 manpages-dev autoconf automake1.9
  libtool flex bison gcc-doc glibc-doc libstdc++6-4.1-doc
The following NEW packages will be installed:
  build-essential dpkg-dev g++ g++-4.1 gcc libc6-dev libstdc++6-4.1-dev
  linux-libc-dev
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/8056kB of archives.
After unpacking 33.7MB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Selecting previously deselected package linux-libc-dev.
(Reading database ... 91530 files and directories currently installed.)
Unpacking linux-libc-dev (from .../linux-libc-dev_2.6.20-15.27_i386.deb) ...
Selecting previously deselected package libc6-dev.
Unpacking libc6-dev (from .../libc6-dev_2.5-0ubuntu14_i386.deb) ...
Selecting previously deselected package gcc.
Unpacking gcc (from .../gcc_4.1.2-1ubuntu1_i386.deb) ...
Selecting previously deselected package libstdc++6-4.1-dev.
Unpacking libstdc++6-4.1-dev (from
.../libstdc++6-4.1-dev_4.1.2-0ubuntu4_i386.deb) ...
Selecting previously deselected package g++-4.1.
Unpacking g++-4.1 (from .../g++-4.1_4.1.2-0ubuntu4_i386.deb) ...
Selecting previously deselected package g++.
Unpacking g++ (from .../g++_4.1.2-1ubuntu1_i386.deb) ...
Selecting previously deselected package dpkg-dev.
Unpacking dpkg-dev (from .../dpkg-dev_1.13.24ubuntu6_all.deb) ...
Selecting previously deselected package build-essential.
Unpacking build-essential (from .../build-essential_11.3_i386.deb) ...
Setting up linux-libc-dev (2.6.20-15.27) ...
Setting up libc6-dev (2.5-0ubuntu14) ...
Setting up gcc (4.1.2-1ubuntu1) ...
Setting up dpkg-dev (1.13.24ubuntu6) ...
Setting up libstdc++6-4.1-dev (4.1.2-0ubuntu4) ...
Setting up g++-4.1 (4.1.2-0ubuntu4) ...
Setting up g++ (4.1.2-1ubuntu1) ...
Setting up build-essential (11.3) ...
root@ubuntu:/home/ubuntu# cd /media/ACER
root@ubuntu:/media/ACER# cd powerloom-3.2.0
root@ubuntu:/media/ACER/powerloom-3.2.0# cd native/cpp/powerloom
root@ubuntu:/media/ACER/powerloom-3.2.0/native/cpp/powerloom# make
for system in logic logic/extensions  ; do \
          (cd ../${system} ; \
          make  CC=gcc CXX=g++ LINK-MODE=dynamic lib;) \
        done
make[1]: Entering directory `/media/ACER/powerloom-3.2.0/native/cpp/logic'
g++ -w -g -O2 -fno-common -DSTELLA_USE_GC -I../stella/cpp-lib/gc/include
 -c -I.. logic-macros.cc
../stella/primal.hh:84: error: explicit qualification in declaration of
â€˜double stella::fmod(double, double)â€™
../stella/primal.hh:89: error: explicit qualification in declaration of
â€˜int stella::random(int)â€™
../stella/primal.hh:91: error: explicit qualification in declaration of
â€˜double stella::sqrt(double)â€™
../stella/primal.hh:92: error: explicit qualification in declaration of
â€˜double stella::cos(double)â€™
../stella/primal.hh:93: error: explicit qualification in declaration of
â€˜double stella::sin(double)â€™
../stella/primal.hh:94: error: explicit qualification in declaration of
â€˜double stella::tan(double)â€™
../stella/primal.hh:95: error: explicit qualification in declaration of
â€˜double stella::acos(double)â€™
../stella/primal.hh:96: error: explicit qualification in declaration of
â€˜double stella::asin(double)â€™
../stella/primal.hh:97: error: explicit qualification in declaration of
â€˜double stella::atan(double)â€™
../stella/primal.hh:98: error: explicit qualification in declaration of
â€˜double stella::atan2(double, double)â€™
../stella/primal.hh:99: error: explicit qualification in declaration of
â€˜double stella::log(double)â€™
../stella/primal.hh:101: error: explicit qualification in declaration of
â€˜double stella::exp(double)â€™
../stella/primal.hh:103: error: explicit qualification in declaration of
â€˜int stella::min(int, int)â€™
../stella/primal.hh:104: error: explicit qualification in declaration of
â€˜int stella::max(int, int)â€™
../stella/primal.hh:198: error: explicit qualification in declaration of
â€˜void stella::sleep(double)â€™
../stella/collections.hh:165: error: explicit qualification in
declaration of â€˜stella::Vector* stella::vector(int, ...)â€™
make[1]: *** [logic-macros.o] Error 1
make[1]: Leaving directory `/media/ACER/powerloom-3.2.0/native/cpp/logic'
make[1]: Entering directory
`/media/ACER/powerloom-3.2.0/native/cpp/logic/extensions'
g++ -w -g -O2 -fno-common -DSTELLA_USE_GC
-I../../stella/cpp-lib/gc/include  -c -I../.. extensions.cc
../../stella/primal.hh:84: error: explicit qualification in declaration
of â€˜double stella::fmod(double, double)â€™
../../stella/primal.hh:89: error: explicit qualification in declaration
of â€˜int stella::random(int)â€™
../../stella/primal.hh:91: error: explicit qualification in declaration
of â€˜double stella::sqrt(double)â€™
../../stella/primal.hh:92: error: explicit qualification in declaration
of â€˜double stella::cos(double)â€™
../../stella/primal.hh:93: error: explicit qualification in declaration
of â€˜double stella::sin(double)â€™
../../stella/primal.hh:94: error: explicit qualification in declaration
of â€˜double stella::tan(double)â€™
../../stella/primal.hh:95: error: explicit qualification in declaration
of â€˜double stella::acos(double)â€™
../../stella/primal.hh:96: error: explicit qualification in declaration
of â€˜double stella::asin(double)â€™
../../stella/primal.hh:97: error: explicit qualification in declaration
of â€˜double stella::atan(double)â€™
../../stella/primal.hh:98: error: explicit qualification in declaration
of â€˜double stella::atan2(double, double)â€™
../../stella/primal.hh:99: error: explicit qualification in declaration
of â€˜double stella::log(double)â€™
../../stella/primal.hh:101: error: explicit qualification in declaration
of â€˜double stella::exp(double)â€™
../../stella/primal.hh:103: error: explicit qualification in declaration
of â€˜int stella::min(int, int)â€™
../../stella/primal.hh:104: error: explicit qualification in declaration
of â€˜int stella::max(int, int)â€™
../../stella/primal.hh:198: error: explicit qualification in declaration
of â€˜void stella::sleep(double)â€™
../../stella/collections.hh:165: error: explicit qualification in
declaration of â€˜stella::Vector* stella::vector(int, ...)â€™
make[1]: *** [extensions.o] Error 1
make[1]: Leaving directory
`/media/ACER/powerloom-3.2.0/native/cpp/logic/extensions'
make: *** [update-required-systems] Error 2
root@ubuntu:/media/ACER/powerloom-3.2.0/native/cpp/powerloom#

 g++ ma ottengo questi messaggi di errore:
[cut sui messaggi di errore]
La versione di PowerLoom che stai provando a compilare e' stata
scritta male (non e' C++ standard). Hai tre possibilita':
(1) Istalli il gcc 3.3, che accetta quel codice anche se non e'
standard.
(2) Provi a vedere se c'e' una versione di PoweLoom piu' recente in
cui questi errori sono stati corretti.
(3) Correggi gli errori a mano, non e' poi cosi' difficile. guarda
qui, sotto "Conflicting Declarations in Namespaces":
http://developer.apple.com/releasenotes/DeveloperTools/GCC40PortingReleaseNotes/Articles/PortingToGCC.html
Saluti,
The Librarian

 The Librarian
Grazie mille.

 Thanks.
Well, the make file should have built libraries for stella and powerloom
(logic), as well as an executable.   The executable, for historic
reasons, is called "logic".
You should be able to run it by typing "./logic" in the build directory.
Note that it may also be necessary to do an install of the Boehm GC from
the stella/cpp-lib/gc directory.
Non capisco la parte riguardo a "logic", il garbage collector come lo
installo?


 installo?
Visto che il programma ha compilato correttamente probabilmente o il
GC e' gia' istallato, oppure non ti serve.
Comunque, per istallarlo, utilizza i pacchetti della tua distribuzione
(NB: devi istallare *anche* i pacchetti di sviluppo del Boehm GC).
Saluti,
The Librarian

 
Non riesco a trovare il file "logic". Invece lanciando ./powerloom
funziona :-)
Il problema era che sono talmente niubbo che non sapevo come lanciare
gli eseguibili Linux da riga di comando :-O
Non capisco perché Mr Russ mi abbia scritto di logic, anziché powerloom,
forse perché lui usa Il Mac?
Grazie di nuovo.
Ora proverò a compilarlo anche per winzoz


 The manual hasn't any documentation on C++ API. There are some examples?
We don't really have any specific C++ examples, since we haven't
programmed directly using that language.  When we use the C++ version of
PowerLoom, we have always done that through the Stella programming
language and had the resulting C++ code generated for us.
What you can do, however, is use the command "cpptrans" in the PowerLoom
listener to translate and print Stella constructs in their C++ form.
That will allow you to see how constructs from the reference manual will
look.  There are also analogous commands for java "jptrans" and lisp
"ptrans".  The name is short for "print translation".
For example:
PL-USER |= (cpptrans (pli/get-concept "RELATION" null null))
pli::getConcept("RELATION", NULL, NULL)
PL-USER |= (cpptrans (pli/s-retrieve "all (concept ?y" null null))
pli::sRetrieve("all (concept ?y", NULL, NULL)
The main difference between the C++ examples and the Java code is that
C++ uses namespaces corresponding to the PowerLoom modules, in contrast
to Java and Lisp which uses their native packages.  For lisp, the pli
functions are in the PLI package.  All others are in the STELLA package.
The other difference in C++ compared to Java, is that objects are
referred to using pointers.
PL-USER |= (cpptrans (let ((c (pli/get-concept "CONCEPT" null null))
                           (it (pli/get-concept-instances c null null)))
                       (print it)))
{ LogicObject* c = pli::getConcept("CONCEPT", NULL, NULL);
  pli::PlIterator* it = pli::getConceptInstances(c, NULL, NULL);
  std::cout << it;
}
The naming convention transformations for C++ are the same as Java,
except that the "*" character is translated to "o" instead of "$".
per quel poco di C++ che conosco (o ho capito)
pli::getConcept("RELATION", NULL, NULL)
dovrebbe significare usare la funzione getConcept della classe pli,
giusto? Ma per avere la classe pli devo includere un file che l'abbia
definita, no?