libpthread not found in LD_LIBRARY_PATH

711 views
Skip to first unread message

Joe Pappas

unread,
Apr 26, 2023, 1:38:23 PM4/26/23
to ns-3-users
Hello,

I have posted a few times on getting the visualizer to run on various systems. You can ignore those and those other systems for now.

I am trying to run the visualizer on a Linux Ubuntu system. I was able to get the visualizer module to be enabled. When I try to run a program with --visualize, I am getting an error about not being able to find a .so file.

My command: ./ns3 run scratch/drone/drone-mobility.cc --visualize

Output:
```
[0/2] Re-checking globbed directories...
[998/998] Linking CXX executable ../build/scratch/drone/ns3.38-drone-mobility-default
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/bindings/python/visualizer/__init__.py", line 1, in <module>
    from ns import *
  File "/home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/bindings/python/ns/__init__.py", line 483, in <module>
    ns = load_modules()  # can be imported via 'from ns import ns'
  File "/home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/bindings/python/ns/__init__.py", line 348, in load_modules
    for linked_lib_include_dir in extract_library_include_dirs(library, prefix):
  File "/home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/bindings/python/ns/__init__.py", line 147, in extract_library_include_dirs
    raise Exception(
Exception: Failed to find libpthread.so. Make sure its library directory is in LD_LIBRARY_PATH.
```


I am using conda as my pthon environment. For me,  the libpthread.so file is in /.conda/envs/ns3/x86_64-conda-linux-gnu/sysroot/usr/lib64 . I have tried setting the LD_LIBRARY_PATH environment variable to include this directory, but I am still getting this error.

How should I be including this directory, or is there another way I can get around this error?

Thanks,
Joe

Tommaso Pecorella

unread,
Apr 26, 2023, 2:01:45 PM4/26/23
to ns-3-users
Hi,

theoretically we shouldn't be using anymore libpthread - as we did transition to sys:thread. I don't know if Python uses libpthread though "import threading" tho.

Conda... well, that's a lot of headaches, and I wouldn't add it from there - unless you're using a conda environment to run ns-3. As for libpthread, it's part of the linux "libc6" package, try installing it.

Joe Pappas

unread,
Apr 26, 2023, 2:15:40 PM4/26/23
to ns-3-users
I installed libc6 via apt-get and am still facing the same issue even after restarting the terminal and cleaning and rebuilding my ns3 project. Are there any other things I can try?

Tommaso Pecorella

unread,
Apr 26, 2023, 7:21:45 PM4/26/23
to ns-3-users
Please share what you did to enable the visualiser (stuff you installed, if you have a python env, if you did modify ns-3, etc.).
We'll try to reproduce the problem.

Gabriel Ferreira

unread,
Apr 26, 2023, 8:22:44 PM4/26/23
to ns-3-users
Well, std::threads can be implemented with different thread platforms,
 including pthread, which was chosen by glibc. 

Try the ns/__init__.py from my pending MR.
 It should be a lot better on ensuring everything works. 

Haven't tried it with conda, but should work if you export the updated LD_LIBRARY_PATH from the conda environment. 


Joe Pappas

unread,
Apr 26, 2023, 8:42:50 PM4/26/23
to ns-3-users
I think that might've worked. Now I am getting this error:
```
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/bindings/python/visualizer/__init__.py", line 1, in <module>
    from ns import *
  File "/home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/bindings/python/ns/__init__.py", line 596, in <module>

    ns = load_modules()  # can be imported via 'from ns import ns'
  File "/home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/bindings/python/ns/__init__.py", line 424, in load_modules
    libraries_to_load = sort_to_dependencies(libraries, prefix)
  File "/home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/bindings/python/ns/__init__.py", line 390, in sort_to_dependencies
    _, _, linked_libraries = extract_linked_libraries(ns3_library, prefix)
  File "/home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/bindings/python/ns/__init__.py", line 165, in extract_linked_libraries
    return library_path, lib, list(map(lambda x: x.decode("utf-8"), linked_libs))
  File "/home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/bindings/python/ns/__init__.py", line 165, in <lambda>
    return library_path, lib, list(map(lambda x: x.decode("utf-8"), linked_libs))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 334: invalid start byte
```

I've tried fixing this before by just changing the encoding from utf-8 to utf-16, but then if you rebuild, then it just overwrites this change.

Would you recommend fixing it in a different way?

Joe Pappas

unread,
Apr 26, 2023, 8:45:13 PM4/26/23
to ns-3-users
If I fix it that way, then I get the following error:

```
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/bindings/python/visualizer/__init__.py", line 1, in <module>
    from ns import *
  File "/home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/bindings/python/ns/__init__.py", line 596, in <module>
    ns = load_modules()  # can be imported via 'from ns import ns'
  File "/home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/bindings/python/ns/__init__.py", line 468, in load_modules
    cppyy.include(f"ns3/{module}-module.h")
  File "/home/joe/.conda/envs/ns3/lib/python3.9/site-packages/cppyy/__init__.py", line 257, in include
    raise ImportError('Failed to load header file "%s"%s' % (header, err.err))
ImportError: Failed to load header file "ns3/wifi-module.h"
In file included from input_line_20:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/wifi-module.h:100:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/spectrum-wifi-phy.h:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/wifi/model/spectrum-wifi-phy.h:31:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/spectrum-channel.h:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/spectrum/model/spectrum-channel.h:27:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/phased-array-spectrum-propagation-loss-model.h:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/spectrum/model/phased-array-spectrum-propagation-loss-model.h:24:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/phased-array-model.h:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/antenna/model/phased-array-model.h:23:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/matrix-array.h:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/core/model/matrix-array.h:23:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/core/model/val-array.h:26:
/home/joe/.conda/envs/ns3/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.5.0/valarray:1214:5: error: exception specification in declaration does not match previous declaration
    begin(valarray<_Tp>& __va) noexcept
    ^
/home/joe/.conda/envs/ns3/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.5.0/bits/range_access.h:104:31: note: previous declaration is here
  template<typename _Tp> _Tp* begin(valarray<_Tp>&);
                              ^
In file included from input_line_20:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/wifi-module.h:100:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/spectrum-wifi-phy.h:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/wifi/model/spectrum-wifi-phy.h:31:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/spectrum-channel.h:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/spectrum/model/spectrum-channel.h:27:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/phased-array-spectrum-propagation-loss-model.h:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/spectrum/model/phased-array-spectrum-propagation-loss-model.h:24:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/phased-array-model.h:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/antenna/model/phased-array-model.h:23:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/matrix-array.h:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/core/model/matrix-array.h:23:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/core/model/val-array.h:26:
/home/joe/.conda/envs/ns3/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.5.0/valarray:1224:5: error: exception specification in declaration does not match previous declaration
    begin(const valarray<_Tp>& __va) noexcept
    ^
/home/joe/.conda/envs/ns3/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.5.0/bits/range_access.h:105:37: note: previous declaration is here
  template<typename _Tp> const _Tp* begin(const valarray<_Tp>&);
                                    ^
In file included from input_line_20:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/wifi-module.h:100:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/spectrum-wifi-phy.h:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/wifi/model/spectrum-wifi-phy.h:31:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/spectrum-channel.h:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/spectrum/model/spectrum-channel.h:27:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/phased-array-spectrum-propagation-loss-model.h:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/spectrum/model/phased-array-spectrum-propagation-loss-model.h:24:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/phased-array-model.h:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/antenna/model/phased-array-model.h:23:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/matrix-array.h:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/core/model/matrix-array.h:23:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/core/model/val-array.h:26:
/home/joe/.conda/envs/ns3/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.5.0/valarray:1234:5: error: exception specification in declaration does not match previous declaration
    end(valarray<_Tp>& __va) noexcept
    ^
/home/joe/.conda/envs/ns3/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.5.0/bits/range_access.h:106:31: note: previous declaration is here
  template<typename _Tp> _Tp* end(valarray<_Tp>&);
                              ^
In file included from input_line_20:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/wifi-module.h:100:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/spectrum-wifi-phy.h:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/wifi/model/spectrum-wifi-phy.h:31:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/spectrum-channel.h:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/spectrum/model/spectrum-channel.h:27:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/phased-array-spectrum-propagation-loss-model.h:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/spectrum/model/phased-array-spectrum-propagation-loss-model.h:24:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/phased-array-model.h:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/antenna/model/phased-array-model.h:23:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/build/include/ns3/matrix-array.h:1:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/core/model/matrix-array.h:23:
In file included from /home/joe/researh_projects/ns3/ns-allinone-3.38/ns-3.38/src/core/model/val-array.h:26:
/home/joe/.conda/envs/ns3/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.5.0/valarray:1249:5: error: exception specification in declaration does not match previous declaration
    end(const valarray<_Tp>& __va) noexcept
    ^
/home/joe/.conda/envs/ns3/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.5.0/bits/range_access.h:107:37: note: previous declaration is here
  template<typename _Tp> const _Tp* end(const valarray<_Tp>&);
```

Spinach

unread,
May 14, 2023, 12:46:57 AM5/14/23
to ns-3-users
Hello, I encountered the same issue as you when running an ns3 example using Python. I'm also using conda as the python environment. I simply added the path "/usr/lib/x86_64-linux-gnu" for pthread to the LD_LIBRARY_PATH in zshrc, and the program started running correctly. Although this solution may seem strange, I hope it helps you.
Oh, my system is Debian 11 (WSL2).
Reply all
Reply to author
Forward
0 new messages