Organize Linux compile link out undefined reference ' dlclose ' ERROR solution

Source: Internet
Author: User

I'm neutral about Linux, and I think the reason Linux has been slow for so many years is because the desktop is bad or not good enough, so I prefer Ubuntu.

As a result of the previous project is makefile, I personally do not like makefile, because he looks more laborious, and compiled after the problem debugging is a big problem, not everyone is proficient in gdb, and VI to start more difficult. So will the project into Codeblocks CBP, originally want to use CMake, but feel to write more, so forget, after all, the code is not cross-platform, Windows can not use.

After the compile link, reported a undefined reference ' dlclose@xxx function ', do not know what the problem, Shing Cheng came to see the next, said is the DL library did not pack in, checked the next DL library is used to do dynamic library load, (dynamic load), The project uses the libmysqld.so, after added still has the question, changes the-LDL link option to be possible finally.

This paper sums up the common problems of undefined reference:

1.DL Library


Undefined reference to ' dlerror '
Undefined reference to ' Dlopen '
Undefined reference to ' dlerror '

Add-LDL Link option (-l is the prefix of link options)

2.pthread Library

Undefined reference to ' pthread_create '

Undefined reference to ' pthread_xxxx '

Add-lpthread Link Options

3.rt Library

Undefined reference to ' clock_gettime '

Add-LRT Link Options

If you are using Codeblocks, you can add the link option, but because of the dependency order problem, if link option Riga or error, directly in the link file, adding pthread DL RT can be

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.