Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » Error when using dlopen function in ext_modules
Error when using dlopen function in ext_modules [message #1862688] Thu, 21 December 2023 03:21 Go to next message
Haotian Zhou is currently offline Haotian ZhouFriend
Messages: 1
Registered: December 2023
Junior Member
When I try to use the function in the <dlfcn.h> in a custom function block to call the external dynamic link library, I get the following error.
(Generate the Makefile using the CMAKE GUI tool, and the CMAKE_EXE_LINKER_FLAGS -ldl option has been set)

Here is the error info.
[100%] Linking CXX executable forte
/usr/bin/ld: CMakeFiles/FORTE_LITE.dir/ext_modules/DYNAMIC_LIBRARY_TEST/FB_CALL_X2.cpp.o: in function `openlibaray(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
/home/imc/work/61499/4diac/forte/source_code/forte_2.0.1/src/ext_modules/DYNAMIC_LIBRARY_TEST/FB_CALL_X2.cpp:45: undefined reference to `dlopen'
/usr/bin/ld: /home/imc/work/61499/4diac/forte/source_code/forte_2.0.1/src/ext_modules/DYNAMIC_LIBRARY_TEST/FB_CALL_X2.cpp:48: undefined reference to `dlerror'
/usr/bin/ld: CMakeFiles/FORTE_LITE.dir/ext_modules/DYNAMIC_LIBRARY_TEST/FB_CALL_X2.cpp.o: in function `callLibaray(void*, char const*, unsigned char*, unsigned char*, unsigned char*)':
/home/imc/work/61499/4diac/forte/source_code/forte_2.0.1/src/ext_modules/DYNAMIC_LIBRARY_TEST/FB_CALL_X2.cpp:57: undefined reference to `dlsym'
/usr/bin/ld: /home/imc/work/61499/4diac/forte/source_code/forte_2.0.1/src/ext_modules/DYNAMIC_LIBRARY_TEST/FB_CALL_X2.cpp:60: undefined reference to `dlerror'
collect2: error: ld returned 1 exit status
make[2]: *** [src/CMakeFiles/forte.dir/build.make:328: src/forte] Error 1
make[1]: *** [CMakeFiles/Makefile2:1403: src/CMakeFiles/forte.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
Re: Error when using dlopen function in ext_modules [message #1862705 is a reply to message #1862688] Thu, 21 December 2023 16:19 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1585
Registered: January 2014
Senior Member

I recommend to run the build with the VERBOSE=1 option. Then you can better see what compiler and linker flags are used in your cmake make build.

Furthermore please have a look on 4diac FORTE modules like paho or OPC UA which are using external libs to configure this from your cmakelists.txt.
Re: Error when using dlopen function in ext_modules [message #1862858 is a reply to message #1862688] Wed, 03 January 2024 08:38 Go to previous message
Ernst Blecha is currently offline Ernst BlechaFriend
Messages: 14
Registered: December 2019
Junior Member
Have you tried adding
forte_add_link_library("-ldl")

to to CMakeLists.txt of your external module? It seems like CMAKE_EXE_LINKER_FLAGS is not always considered by the build process.
Previous Topic:Analog Inputs for NXP
Next Topic:Discover the name of a block
Goto Forum:
  


Current Time: Sat Apr 27 17:33:27 GMT 2024

Powered by FUDForum. Page generated in 0.02397 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top