Linux thread not found during MySQL Compilation

Source: Internet
Author: User
Tags mysql manual

Install from source code in FC6 SystemMySQLThe error message "Linux thread not found" is displayed. The Code is as follows:

 
 
  1. #./configure --prefix=/usr/local/mysql  
  2.  
  3. …  
  4.  
  5. …  
  6.  
  7. checking "LinuxThreads"... "Not found"  
  8.  
  9. configure: error: This is a linux system and Linuxthreads was not found. On linux Linuxthreads should be used.   
  10.  
  11. Please install Linuxthreads (or a new glibc) and try again.   
  12.  
  13. See the Installation chapter in the Reference Manual for more information. 

You can find many related posts by searching the keyword "Linuxthreads was not found" on the Internet, but most of them do not provide a complete solution.

Next we will analyze the above error and provide a solution. From the above error, we can see that the system lacks a thread library. Does Linux run without a thread? Well, of course not. Since there is no linuxthread, what is it now?

The answer is:NPTL.

As a step to remove the obsolete LinuxThreads library, the Code Compiled and connected in Fedora Core 5 test1 now automatically uses the NPTL header file and library. In previous versions, the default thread model for Red Hat Linux 9 was LnuxThreads, because the interface was the most common. The NPTL interface has the advantage of faster processing of thread cancellation (even in C code when the-fexception parameter is used ). Now the attached interface is available, and no special compiler or connector parameters are required.

The following is a turning point. How can this problem be solved?

You can modify the program to support NPTL, or add support for the original thread library during compilation. I chose the latter, so that the source code of MySql is not moved. Search for the keyword thread in the mysql manual. You can find it in Chapter 2. Installing and Upgrading MySQL.

2.8.5. MIT-pthreads Notes

 
 
  1. If your system does not provide native thread support, you should build MySQL using the MIT-pthreads package.   
  2.  
  3. This includes older FreeBSD systems, SunOS 4.x, Solaris 2.4 and earlier, and some others. See Section 2.1.1, “Operating Systems Supported by MySQL”.  
  4.  
  5. Beginning with MySQL 4.0.2, MIT-pthreads is no longer part of the source distribution.   
  6.  
  7. If you require this package, you need to download it separately from http://www.mysql.com/Downloads/Contrib/pthreads-1_60_beta6-mysql.tar.gz  
  8.  
  9. After downloading, extract this source archive into the top level of the MySQL source directory.  
  10.  
  11.  It creates a new subdirectory named mit-pthreads. 

As shown in the preceding figure, you only need to go to the mit-thread source code. But I don't know why the official website is no longer available (I still haven't found an image on the official website and am depressed ). Take a closer look at the above, just put the thread source code under the root directory of the MySql source code directory and name it mit-pthreads. The same is true if the official team does not perform the next step on their own. Just unzip the package and put it in the above position.

So I went to a pthread source code package and decompressed it to the corresponding location.

Run the following command:

 
 
  1. #./configure  --prefix=/usr/local/mysql --with-mit-threads 

It was successfully passed.

Appendix: Advantages of NPTL over LinuxThreads

NPTL does not use a management thread. Some requirements of Management threads, such as sending termination signals to all threads as part of the process, are not required because the kernel itself can implement these functions. The kernel also processes the memory used by each thread stack for recycling. It even waits before the parent thread is cleared to manage the end of all threads, so as to avoid zombie processes. Because NPTL does not use management threads, its thread model has better scalability and synchronization mechanisms on NUMA and SMP systems.

By using the NPTL thread Library and the new kernel implementation, we can avoid using signals to synchronize threads. For this purpose, NPTL introduced a new mechanism named futex. Futex works in the shared memory area, so it can be shared among processes. This provides the POSIX synchronization mechanism between processes. We can also share a futex between processes. This behavior makes synchronization between processes possible. In fact, NPTL contains a PTHREAD_PROCESS_SHARED macro, allowing developers to share mutex locks between user-level processes in different threads.

Because NPTL is POSIX compatible, it processes signals according to the principles of each process. getpid () returns the same process ID for all threads. For example, if a SIGSTOP signal is sent, the entire process will stop. With LinuxThreads, only the thread that receives the signal will stop. In this way, NPTL-based applications can better utilize the debugger, such as GDB.

Because all threads in NPTL have a parent process, the resource usage reported by the parent process, such as the percentage of CPU and memory, is counted, instead of counting a thread.

An Implementation feature introduced by the NPTL thread library is the support for the ABI application binary interface. This helps achieve backward compatibility with LinuxThreads.

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.