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

undefined reference to "shm_xxx" #111

Open
mkris0714 opened this issue Mar 5, 2024 · 5 comments
Open

undefined reference to "shm_xxx" #111

mkris0714 opened this issue Mar 5, 2024 · 5 comments

Comments

@mkris0714
Copy link

In the ns3-ai build processing, the below undefined error occurred.

It's the problem that cmake should be performed including the option "-lrt".

I tried to address the problem using in "set(CXXFLAGS="-lrt") command" or ns3 configure CXXFLAGS, but I failed.

How can I fix it ?

[100%] Linking CXX shared library /root/impl_source/netai_impl/learning/environments/ns-allinone-3.38/ns-3.38/build/lib/libns3.38-core-default.so
[100%] Linking CXX shared library /root/impl_source/netai_impl/learning/environments/ns-allinone-3.38/ns-3.38/build/lib/libns3.38-ai-default.so
[100%] Building CXX object contrib/ai/examples/a-plus-b/CMakeFiles/ns3ai_apb_gym.dir/use-gym/apb.cc.o
[100%] Linking CXX executable /root/impl_source/netai_impl/learning/environments/ns-allinone-3.38/ns-3.38/build/contrib/ai/examples/a-plus-b/ns3.38-ns3ai_apb_gym-default
/usr/bin/ld: /root/impl_source/netai_impl/learning/environments/ns-allinone-3.38/ns-3.38/build/lib/libns3.38-ai-default.so: undefined reference to shm_open' /usr/bin/ld: /root/impl_source/netai_impl/learning/environments/ns-allinone-3.38/ns-3.38/build/lib/libns3.38-ai-default.so: undefined reference to shm_unlink'
collect2: error: ld returned 1 exit status
make[3]: *** [contrib/ai/examples/a-plus-b/CMakeFiles/ns3ai_apb_gym.dir/build.make:101: /root/impl_source/netai_impl/learning/environments/ns-allinone-3.38/ns-3.38/build/contrib/ai/examples/a-plus-b/ns3.38-ns3ai_apb_gym-default] Error 1
make[2]: *** [CMakeFiles/Makefile2:4673: contrib/ai/examples/a-plus-b/CMakeFiles/ns3ai_apb_gym.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:4679: contrib/ai/examples/a-plus-b/CMakeFiles/ns3ai_apb_gym.dir/rule] Error 2
make: *** [Makefile:1038: ns3ai_apb_gym] Error 2
Finished executing the following commands:
cd cmake-cache; /usr/local/bin/cmake --build . -j 7 --target ns3ai_apb_gym ; cd ..

@mkris0714
Copy link
Author

I temporarily fixed the linking error by modifying the build file, build-support/macros-and-definitions.cmake.

However, new command lines will be needed for building dependency to ns3-ai modules.

if(${NS3_STATIC} AND (NOT BEXEC_STANDALONE))
target_link_libraries(
┆ ${BEXEC_EXECNAME_PREFIX}${BEXEC_EXECNAME} ${LIB_AS_NEEDED_PRE_STATIC}
┆ ${lib-ns3-static}
)
elseif(${NS3_MONOLIB} AND (NOT BEXEC_STANDALONE))
target_link_libraries(
┆ ${BEXEC_EXECNAME_PREFIX}${BEXEC_EXECNAME} ${LIB_AS_NEEDED_PRE}
┆ ${lib-ns3-monolib} ${LIB_AS_NEEDED_POST}
)
else()
target_link_libraries(
┆ ${BEXEC_EXECNAME_PREFIX}${BEXEC_EXECNAME} ${LIB_AS_NEEDED_PRE}
┆ "${BEXEC_LIBRARIES_TO_LINK}" ${LIB_AS_NEEDED_POST} "-lrt"
)
endif()

@ShenMuyuan
Copy link
Contributor

Hi, @mkris0714. Could you provide your OS version and the command you are running, to reproduce the error?

@mkris0714
Copy link
Author

Hi, @ShenMuyuan.

  • OS version : Linux 20.04 on docker (no conda) All required libraries are installed
  • commnad : "./ns3 clean && ./ns3 configure --enable-examples --enable-tests && ./ns3 build" on NS3 3.38 with ns3-ai main branch (not v1.2.0)

In addition, "ns3-ai v1.2.0" is compatible with ns3 version 3.37, not with version 3.38 (based on "rl-tcp example" execution).

please check, ns3-ai v1.2.0 with ns3 3.38

Thank you !

@ShenMuyuan
Copy link
Contributor

OS version : Linux 20.04 on docker (no conda) All required libraries are installed

In development of the main branch, we used a mix of Ubuntu 22.04 virtual machine and WSL, rather than Ubuntu 20.04 in docker. Your issue may be the difference of system libraries, as in our Ubuntu 22.04 the ns3ai_apb_gym can run without librt linking explicitly.

So,

  1. If you keep using your platform, you can try to add rt in ns3-ai's LIBRARIES_TO_LINK, like:
build_lib(
        LIBNAME ai
        SOURCE_FILES ${msg_interface_srcs} ${gym_interface_srcs}
        HEADER_FILES ${msg_interface_hdrs} ${gym_interface_hdrs}
        LIBRARIES_TO_LINK ${libcore} Boost::program_options protobuf::libprotobuf rt
)

This method avoids changing the global build process of ns-3.

  1. Alternatively, you could switch to Ubuntu 22.04, in virtual machine or WSL.

"ns3-ai v1.2.0" is compatible with ns3 version 3.37, not with version 3.38

The v1.2.0 is outdated (with the old API) and we have no plan to update its compatibility. We will release a new version soon (with the new API), based on current main branch.

@mkris0714
Copy link
Author

Thank you for your kind solution !

I support the ns3-ai module. That module is very convenient for running rl on ns3.

Have a nice day

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