Error:
Linking CXX executable cmakeproject
CMakeFiles/cmakeproject.dir/main.cpp.o: In function `main':
main.cpp:(.text+0x1a): undefined reference to `dlopen'
main.cpp:(.text+0x2a): undefined reference to `dlclose'
collect2: ld returned 1 exit status
make[2]: *** [testlink] Error 1
make[1]: *** [CMakeFiles/cmakeproject.dir/all] Error 2
make: *** [all] Error 2
I ask how to fix this in CMake Project because there are multiple questions like this and answers but CMake is not used by them:
- https://stackoverflow.com/a/956698/13545849
- https://stackoverflow.com/a/20419191/13545849
- https://stackoverflow.com/a/33035858/13545849
- https://stackoverflow.com/a/6183935/13545849
- ... And a lot of other "duplicates"
How to fix this if I use CMake?