Binding python - Error with first.py - Failed to load header file

132 views
Skip to first unread message

Gabriela Caspa Huayhua

unread,
Feb 22, 2023, 5:12:10 PM2/22/23
to ns-3-users
Hello everybody!

I am using ns-3.37 in an Ubuntu 22.04 LTS  and I am struggling with python bindings. First I had trouble with a library directory and now a header can´t be load.

I tried:

./ns3 configure --enable-python-bindings
./ns3 run first.py

1. First error:

Traceback (most recent call last):
  File "/home/gabi/Documents/Simulador/bake/source/ns-3.37/examples/tutorial/first.py", line 16, in <module>
    from ns import ns
  File "/home/gabi/Documents/Simulador/bake/source/ns-3.37/build/bindings/python/ns/__init__.py", line 488, in <module>

    ns = load_modules()  # can be imported via 'from ns import ns'
  File "/home/gabi/Documents/Simulador/bake/source/ns-3.37/build/bindings/python/ns/__init__.py", line 343, in load_modules
    for linked_lib_include_dir in extract_library_include_dirs(library, prefix):
  File "/home/gabi/Documents/Simulador/bake/source/ns-3.37/build/bindings/python/ns/__init__.py", line 142, in extract_library_include_dirs
    raise Exception(
Exception: Failed to find libnsclick.so. Make sure its library directory is in LD_LIBRARY_PATH.
Command 'python3 /home/gabi/Documents/Simulador/bake/source/ns-3.37/examples/tutorial/first.py' returned non-zero exit status 1.

Which was solved by adding the path: (Thank you Gabriel)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/gabi/Documents/Simulador/bake/build/lib

2. However, then when running again the example:

./ns3 run first.py

The folllowing is displayed:

Traceback (most recent call last):
  File "/home/gabi/Documents/Simulador/bake/source/ns-3.37/examples/tutorial/first.py", line 16, in <module>
    from ns import ns
  File "/home/gabi/Documents/Simulador/bake/source/ns-3.37/build/bindings/python/ns/__init__.py", line 488, in <module>
    ns = load_modules()  # can be imported via 'from ns import ns'
  File "/home/gabi/Documents/Simulador/bake/source/ns-3.37/build/bindings/python/ns/__init__.py", line 349, in load_modules
    cppyy.include("ns3/%s-module.h" % module)
  File "/home/gabi/.local/lib/python3.10/site-packages/cppyy/__init__.py", line 245, in include
    raise ImportError('Failed to load header file "%s"%s' % (header, err.err))
ImportError: Failed to load header file "ns3/openflow-module.h"
In file included from input_line_32:1:
In file included from /home/gabi/Documents/Simulador/bake/source/ns-3.37/build/include/ns3/openflow-module.h:6:
In file included from /home/gabi/Documents/Simulador/bake/source/ns-3.37/build/include/ns3/openflow-switch-helper.h:1:
In file included from /home/gabi/Documents/Simulador/bake/source/ns-3.37/src/openflow/helper/openflow-switch-helper.h:24:
In file included from /home/gabi/Documents/Simulador/bake/source/ns-3.37/build/include/ns3/openflow-interface.h:1:
In file included from /home/gabi/Documents/Simulador/bake/source/ns-3.37/src/openflow/model/openflow-interface.h:52:
In file included from /home/gabi/Documents/Simulador/bake/build/include/openflow/private/stp.h:43:
/home/gabi/Documents/Simulador/bake/build/include/openflow/private/util.h:107:6: error: functions that differ only in their return type cannot be overloaded
void strlcpy(char *dst, const char *src, size_t size);
~~~~ ^
/tmp/pip-build-env-ccwmx7_o/normal/local/lib/python3.10/dist-packages/cppyy_backend/include/strlcpy.h:26:8: note: previous declaration is here
size_t strlcpy(char *dst, const char *src, size_t siz);
~~~~~~ ^

Command 'python3 /home/gabi/Documents/Simulador/bake/source/ns-3.37/examples/tutorial/first.py' returned non-zero exit status 1.


I would appreciate your help with that issue. Thank you all in advance!!




Gabriel Ferreira

unread,
Feb 22, 2023, 9:17:26 PM2/22/23
to ns-3-users

You just hit another known problem https://gitlab.com/nsnam/ns-3-dev/-/merge_requests/1277#note_1260319640.

The fix was merged to openflow a few days ago. 
You can either get the newer openflow version (https://code.nsnam.org/openflow/archive/d45e7d184151.zip)
or disable it (can't help you with that one, since I don't use Bake).

We will hopefully have a pip-installable package in the future, and you won't see that anymore. :)
Reply all
Reply to author
Forward
Message has been deleted
0 new messages