Linux compiler link undefined reference 'dlclose' how to do?

  

In the Linux system compiled link error, prompt "undefined reference & rsquo; dlclose@xxx function" error, I believe many users also encountered this The problem, this problem is not difficult to solve, the following small series for everyone to introduce the solution to the undefined reference error.

compiled link time, reported an undefined reference & rsquo; dlclose @ xxx main function & lsquo ;, looking away over looked at, say dl library does not go bag, checked the library is dl Used to do dynamic library loading (dynamic load), the project uses libmysqld.so, after adding, there is still a problem, the -ldl link option can be changed to the end.

More common undefined reference problems:

1.dl library

undefined reference to ‘dlerror’

undefined reference to ‘dlopen’< Br>

undefined reference to ‘dlerror’

Add -ldl link option (-l is the prefix of the link option)

2.pthread library

undefined reference To ‘pthread_create’

undefined reference to ‘pthread_xxxx‘

Add -lpthread link option

3.rt library

undefined reference to `clock_gettime&rsquo ;

Add -lrt link option

If you are using codeblocks, you can add the link option again, but because of the dependency order, if the link option is added or an error is reported, add it directly in the link file. Pthread dl rt, etc.

If it is your own library, this undefined reference function, first check the source code of the library to see the specific problem.

The above is the solution to the Linux compiler link error. In addition to introducing the link error, this article also summarizes some undefined reference problems, I hope to help you.

Copyright © Windows knowledge All Rights Reserved