<?xml version="1.0" encoding="utf-8"?> <rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>ROS Answers: Open Source Q&A Forum - RSS feed</title><link>https://answers.ros.org/questions/</link><description>Open source question and answer forum written in Python and Django</description><atom:link href="https://answers.ros.org/feeds/question/43215/" rel="self"></atom:link><language>en</language><copyright>ROS Answers is licensed under Creative Commons Attribution 3.0</copyright><lastBuildDate>Thu, 06 Sep 2012 05:06:26 -0500</lastBuildDate><item><title>Compiling ros node with cmake and swi-prolog</title><link>https://answers.ros.org/question/43215/compiling-ros-node-with-cmake-and-swi-prolog/</link><description>Hi to all! I have a ROS node that performs some swi-prolog queries using the pl2cpp library (it comes together with the swi-prolog installation). Now, the problem is that when i have a .cpp file that interacts with prolog in this way, i need to compile it together with the used prolog file with the compilation command swipl-ld ex. swipl-ld my_ccp_file.cpp my_prolog_file.pl this generates the stand alone executable with the cpp and the prolog linked together. I don't know how and when to call this procedure in the compilation process of a ROS node.</description><pubDate>Thu, 06 Sep 2012 02:38:16 -0500</pubDate><guid>https://answers.ros.org/question/43215/compiling-ros-node-with-cmake-and-swi-prolog/</guid></item><item><title>Answer by Lorenz for <p>Hi to all! I have a ROS node that performs some swi-prolog queries using the pl2cpp library (it comes together with the swi-prolog installation). Now, the problem is that when i have a .cpp file that interacts with prolog in this way, i need to compile it together with the used prolog file with the compilation command swipl-ld</p> <p>ex. swipl-ld my_ccp_file.cpp my_prolog_file.pl</p> <p>this generates the stand alone executable with the cpp and the prolog linked together. I don't know how and when to call this procedure in the compilation process of a ROS node.</p> </title><link>https://answers.ros.org/question/43215/compiling-ros-node-with-cmake-and-swi-prolog/?answer=43222#post-id-43222</link><description>I don't think you are required to use `swipl-ld` if you just want to link against prolog. As far as I know, it's just a wrapper that makes sure the right libraries are included and maybe stores some initial state. However, on Ubuntu, swi-prolog provides a package-config file that you can use in your CMakeLists.txt. For swi-prolog, something like this should work: include(FindPkgConfig) pkg_check_modules(SWIPL REQUIRED swipl) include_directories(${SWIPL_INCLUDE_DIRS}) link_directories(${SWIPL_LIBRARY_DIRS}) # ... some other stuff and the definition of your executable target target_link_libraries(<your target> ${SWIPL_LIBRARIES}) If initialization of the prolog kernel does not work properly, the reason could be that your prolog home could not be found since your executable will not contain any saved prolog state. Have a look at the corresponding section in the prolog manual. Sorry for not providing a direct link but this site does not like urls with parenthesis and I'm too lazy to look up the corresponding code. Here the url: http://www.swi-prolog.org/pldoc/doc_for?object=section(2,'9.6',swi('/doc/Manual/findhome.html')). </description><pubDate>Thu, 06 Sep 2012 02:59:43 -0500</pubDate><guid>https://answers.ros.org/question/43215/compiling-ros-node-with-cmake-and-swi-prolog/?answer=43222#post-id-43222</guid></item><item><title>Answer by McKracken for <p>Hi to all! I have a ROS node that performs some swi-prolog queries using the pl2cpp library (it comes together with the swi-prolog installation). Now, the problem is that when i have a .cpp file that interacts with prolog in this way, i need to compile it together with the used prolog file with the compilation command swipl-ld</p> <p>ex. swipl-ld my_ccp_file.cpp my_prolog_file.pl</p> <p>this generates the stand alone executable with the cpp and the prolog linked together. I don't know how and when to call this procedure in the compilation process of a ROS node.</p> </title><link>https://answers.ros.org/question/43215/compiling-ros-node-with-cmake-and-swi-prolog/?answer=43233#post-id-43233</link><description>Ok, i think this is the right way! Thank you. Now I have one last question (i know it could be the last because i tried it): To use prolog via code, first of all i need to initialize the prolog engine PlEngine e("a.out") passing it the "a.out" file produced by the swipl-ld compilation. Then, i can produce this file by compiling another project (oh yeah, another totally different from my ROS node), by putting this file in the ROS node directory and by using it to initialize the engine. This works (it seems, now i'm testing hard this solution), but... ...it is a non conventional solution. What i would like to have is the compilation of the ROS node producing the a.out file (or something similar...by compiling first the ROS node with swipl-ld - this rises a problem of resource linking).</description><pubDate>Thu, 06 Sep 2012 04:12:04 -0500</pubDate><guid>https://answers.ros.org/question/43215/compiling-ros-node-with-cmake-and-swi-prolog/?answer=43233#post-id-43233</guid></item><item><title>Comment by Lorenz for <p>Ok, i think this is the right way! Thank you. Now I have one last question (i know it could be the last because i tried it): To use prolog via code, first of all i need to initialize the prolog engine</p> <p>PlEngine e("a.out")</p> <p>passing it the "a.out" file produced by the swipl-ld compilation. Then, i can produce this file by compiling another project (oh yeah, another totally different from my ROS node), by putting this file in the ROS node directory and by using it to initialize the engine. This works (it seems, now i'm testing hard this solution), but... ...it is a non conventional solution. What i would like to have is the compilation of the ROS node producing the a.out file (or something similar...by compiling first the ROS node with swipl-ld - this rises a problem of resource linking).</p> </title><link>https://answers.ros.org/question/43215/compiling-ros-node-with-cmake-and-swi-prolog/?comment=43235#post-id-43235</link><description>Also. if my answer was correct, please mark it so (little check under the downvote button).</description><pubDate>Thu, 06 Sep 2012 04:20:52 -0500</pubDate><guid>https://answers.ros.org/question/43215/compiling-ros-node-with-cmake-and-swi-prolog/?comment=43235#post-id-43235</guid></item><item><title>Comment by Lorenz for <p>Ok, i think this is the right way! Thank you. Now I have one last question (i know it could be the last because i tried it): To use prolog via code, first of all i need to initialize the prolog engine</p> <p>PlEngine e("a.out")</p> <p>passing it the "a.out" file produced by the swipl-ld compilation. Then, i can produce this file by compiling another project (oh yeah, another totally different from my ROS node), by putting this file in the ROS node directory and by using it to initialize the engine. This works (it seems, now i'm testing hard this solution), but... ...it is a non conventional solution. What i would like to have is the compilation of the ROS node producing the a.out file (or something similar...by compiling first the ROS node with swipl-ld - this rises a problem of resource linking).</p> </title><link>https://answers.ros.org/question/43215/compiling-ros-node-with-cmake-and-swi-prolog/?comment=43234#post-id-43234</link><description>I think you can just path the path to the swipl binary, e.g. /usr/bin/swipl. All it needs is the path to a binary that contains the prolog state as far as I know. Btw. please don't open answers for new questions. Either comment or edit your original question. This site is different from forums.</description><pubDate>Thu, 06 Sep 2012 04:20:11 -0500</pubDate><guid>https://answers.ros.org/question/43215/compiling-ros-node-with-cmake-and-swi-prolog/?comment=43234#post-id-43234</guid></item><item><title>Comment by McKracken for <p>Ok, i think this is the right way! Thank you. Now I have one last question (i know it could be the last because i tried it): To use prolog via code, first of all i need to initialize the prolog engine</p> <p>PlEngine e("a.out")</p> <p>passing it the "a.out" file produced by the swipl-ld compilation. Then, i can produce this file by compiling another project (oh yeah, another totally different from my ROS node), by putting this file in the ROS node directory and by using it to initialize the engine. This works (it seems, now i'm testing hard this solution), but... ...it is a non conventional solution. What i would like to have is the compilation of the ROS node producing the a.out file (or something similar...by compiling first the ROS node with swipl-ld - this rises a problem of resource linking).</p> </title><link>https://answers.ros.org/question/43215/compiling-ros-node-with-cmake-and-swi-prolog/?comment=43241#post-id-43241</link><description>Sorry, it's my first post! Thank you a lot</description><pubDate>Thu, 06 Sep 2012 05:06:26 -0500</pubDate><guid>https://answers.ros.org/question/43215/compiling-ros-node-with-cmake-and-swi-prolog/?comment=43241#post-id-43241</guid></item></channel></rss>