Compiling New C++ Code using Chrono

192 views
Skip to first unread message

koala

unread,
Jul 21, 2020, 4:45:16 AM7/21/20
to ProjectChrono
Hi, I am on Ubuntu 18.04, I followed the instructions and after installing irrlicht, cmake, etc was able to compile Chrono. The basic demos run. 

How do I compile additional code through the build system though? I am not too familiar with cmake, if I had plain Makefiles I would take its library, include ref list, but here, not sure where to start. For example let's say I want to compile and run something visual, src/demos/irrlicht/demo_IRR_crank.cpp. Which files do I need to change, add etc for this?

Thanks,

Radu Serban

unread,
Jul 21, 2020, 5:59:06 AM7/21/20
to projec...@googlegroups.com

You can find instructions on how to build a new project that uses Chrono here: http://api.projectchrono.org/tutorial_install_project.html

That will walk you through the necessary steps to build such a project (which happens to also use run-time visualization with Irrlicht).  The sample code used in those instructions is included in the Chrono distribution (see https://github.com/projectchrono/chrono/tree/develop/template_project).   Make sure to use the 'template_project' code that is in your clone of Chrono to make sure it's compatible with the version of Chrono you currently have.

Hope that this helps,
--Radu

--
You received this message because you are subscribed to the Google Groups "ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projectchron...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/8e363872-6fa5-4436-bd10-06851951c479o%40googlegroups.com.

koala

unread,
Jul 21, 2020, 6:34:51 AM7/21/20
to ProjectChrono
Hi Radu, 

So I tried to compile the my_example.cpp in chrono/template_project. The link you said was helpful but I need to use the command line, I tried to replicate what I saw on that link. My chrono is under $HOME/Downloads/repos/chrono, and my build directory is $HOME/Downloads/repos/chrono/build_dir/, 

cmake -D CMAKE_CONFIGURATION_TYPES=Debug \
      -D CMAKE_INSTALL_PREFIX=$HOME/Downloads/repos/chrono/template_project \
      -D Chrono_DIR=$HOME/Downloads/repos/chrono/build_dir/cmake .

This created a Makefile, however when I run make, it does nothing. I am not sure what I am doing wrong. 

Thanks,

On Tuesday, July 21, 2020 at 12:59:06 PM UTC+3, Radu Serban wrote:

You can find instructions on how to build a new project that uses Chrono here: http://api.projectchrono.org/tutorial_install_project.html

That will walk you through the necessary steps to build such a project (which happens to also use run-time visualization with Irrlicht).  The sample code used in those instructions is included in the Chrono distribution (see https://github.com/projectchrono/chrono/tree/develop/template_project).   Make sure to use the 'template_project' code that is in your clone of Chrono to make sure it's compatible with the version of Chrono you currently have.

Hope that this helps,
--Radu

On 7/21/2020 10:45 AM, burakb...@gmail.com wrote:
Hi, I am on Ubuntu 18.04, I followed the instructions and after installing irrlicht, cmake, etc was able to compile Chrono. The basic demos run. 

How do I compile additional code through the build system though? I am not too familiar with cmake, if I had plain Makefiles I would take its library, include ref list, but here, not sure where to start. For example let's say I want to compile and run something visual, src/demos/irrlicht/demo_IRR_crank.cpp. Which files do I need to change, add etc for this?

Thanks,
--
You received this message because you are subscribed to the Google Groups "ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projec...@googlegroups.com.

Radu Serban

unread,
Jul 21, 2020, 8:29:34 AM7/21/20
to projec...@googlegroups.com

There's no problem configuring the build with cmake from the command line. 

  • In Linux, you do not use CMAKE_CONFIGURATION_TYPES, but rather CMAKE_BUILD_TYPE
  • I assume you have already built Chrono.  In Debug mode? 
  • No need to set the install prefix
  • I suggest you do an out-of-source build also for this stand-alone project

With your setup, something along the following lines should work:
$ cd $HOME/Downloads/repos
$ mkdir build_template_project
$ cd build_template_project
$ cmake -DCMAKE_BUILD_TYPE=Debug -DChrono_DIR=$HOME/Downloads/repos/chrono/build_dir/cmake $HOME/Downloads/repos/chrono/template_project

--Radu

To unsubscribe from this group and stop receiving emails from it, send an email to projectchron...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/e96b07c3-d50d-470f-b8b6-05b64af2bdaao%40googlegroups.com.

koala

unread,
Jul 21, 2020, 3:24:28 PM7/21/20
to ProjectChrono

I realized my previous build had some missing components. I rebuilt using

sudo apt-get install libirrlicht-dev swig freeglut3-dev libgl1-mesa-dev libx11-dev

Then

cmake -DENABLE_MODULE_IRRLICHT=TRUE \
      -DENABLE_MODULE_PYTHON=TRUE \
      -DENABLE_MODULE_POSTPROCESS=TRUE \
      -DCMAKE_BUILD_TYPE=Debug ..


After these I saw IRR demos being built, and what you described worked as well. 

Thanks,
Reply all
Reply to author
Forward
0 new messages