Battery-Intelligence-Lab / SLIDE

SLIDE is C++ code that simulates degradation of lithium ion cells. It extends the single particle model with various degradation models from literature. Users can select which degradation models they want to use for a given simulation.
Other
115 stars 34 forks source link

Compiling and running on Ubuntu 20.04 #21

Open Joris-dehoog opened 1 year ago

Joris-dehoog commented 1 year ago

Hello,

I'm trying to compile the current master branch on my Ubuntu 20.04 machine. Some important package information:

I'm following the installation instructions found here, but the last steps fails when I run cmake --build .:

...
[ 97%] Building CXX object tests/unit/CMakeFiles/unit_test_Module_p.dir/Module_p_test.cpp.o
[100%] Linking CXX executable /mnt/localdata/ProgrammingProjects/SLIDE/bin/Release/unit_test_Module_p
/usr/bin/ld: /tmp/unit_test_Module_p.ebGB4w.ltrans1.ltrans.o: in function `slide::Module_p::timeStep_CC(double, int)':
<artificial>:(.text+0x43be): undefined reference to `pthread_create'
/usr/bin/ld: <artificial>:(.text+0x448f): undefined reference to `pthread_create'
/usr/bin/ld: /tmp/unit_test_Module_p.ebGB4w.ltrans1.ltrans.o: in function `slide::Module_s::timeStep_CC(double, int)':
<artificial>:(.text+0x4bfe): undefined reference to `pthread_create'
/usr/bin/ld: <artificial>:(.text+0x4ccf): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
make[2]: *** [tests/unit/CMakeFiles/unit_test_Module_p.dir/build.make:106: /mnt/localdata/ProgrammingProjects/SLIDE/bin/Release/unit_test_Module_p] Error 1
make[1]: *** [CMakeFiles/Makefile2:723: tests/unit/CMakeFiles/unit_test_Module_p.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

I'm not familiar with cmake, so I'm not sure how to fix the pthread_create problem.

Can you help me?

Kind regards,

Joris

ElektrikAkar commented 1 year ago

Hi Joris,

Thank you for your question. Could you try activating pthread option in your src/CMakeLists.txt ?

In this file you should see

target_link_libraries(src
  PRIVATE
  cells
  modules
  cooling
  power_conversion
  system
  procedures
  factories
  settings
  # pthread -> For WSL.
) 

Here you can remove the # in front of pthread and please also delete -> For WSL. part. This should solve the problem but let me know if it persists.

PS: In these days we are working on the SLIDE v3 release, probably you will see some improvements very soon after the release. Also we are going to update our documentation.

Yours sincerely, Volkan

Joris-dehoog commented 1 year ago

Hello,

Thank you, it does solve the issue! Thanks!

Joris-dehoog commented 1 year ago

Hello,

I'd like to reopen this issue, as I have not been able to run the V2 version. I'm trying to compile this one as the documentation does not seem to cover the version under the Main branch (or I don't know how to run it).

The V2 version also has a CmakeList.txt in the root folder, but I don't know how to enable pthread in this one, any tips?

Thanks!

ElektrikAkar commented 1 year ago

Hi I think it is better to use the verson in the main branch. Otherwise, the examples you made will have massive changes at version 3. I would be happy to help with creating any example you need for v3.

Meanwhile you may have a look at this issue for adding pthread in v2:

https://github.com/Battery-Intelligence-Lab/SLIDE/pull/7#issuecomment-913258926

Or alternatively check the full relevant discussion on Twitter:

https://twitter.com/VolkanKumtepeli/status/1439872932747042818

Yours sincerely, Volkan