Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling and running on Ubuntu 20.04 #21

Open
Joris-dehoog opened this issue Mar 23, 2023 · 4 comments
Open

Compiling and running on Ubuntu 20.04 #21

Joris-dehoog opened this issue Mar 23, 2023 · 4 comments

Comments

@Joris-dehoog
Copy link

Hello,

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

  • cmake version 3.26.0
  • gcc (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0
  • g++ (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0

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
Copy link
Collaborator

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
Copy link
Author

Hello,

Thank you, it does solve the issue! Thanks!

@Joris-dehoog
Copy link
Author

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!

@Joris-dehoog Joris-dehoog reopened this Mar 27, 2023
@ElektrikAkar
Copy link
Collaborator

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:

#7 (comment)

Or alternatively check the full relevant discussion on Twitter:

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

Yours sincerely,
Volkan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants