Codeblocks compilation Pthread raises an error

Source: Internet
Author: User

Just contact Codeblocks in the fedora9 under the configuration of the environment, copied the book a piece of thread application code. Encounter two confusing problems. Not resolved.
1. Start compiling, prompting pthread_create undefined (use: res = pthread_create (&thread[no), NULL, Thrd_func, (void*) No).
Internet reason: Problem reason: Pthread Library is not the default library of Linux system, the connection needs to use static library libpthread.a, so create a thread using Pthread_create (), and call Pthread_atfork () function to establish a fork handler, you need to link the library.
You then add LIBPTHREAD.A to the Codeblocks linker settings item to find the file in/usr/bin/lib (note that different environmental paths may vary).
2. Compile again. Undefined questions were solved, but then a larger problem came.
Debug information:
/USR/LIB/LIBPTHREAD.A (PTHREAD_CREATE.O) | | In function ' Pthread_create ': |
(. text+0xa2f) | | Undefined reference to ' _dl_stack_flags ' |
/USR/LIB/LIBPTHREAD.A (PTHREAD_CREATE.O) | | In function ' Pthread_create ': |
(. Text+0xbe5) | | Undefined reference to ' _dl_stack_flags ' |
/USR/LIB/LIBPTHREAD.A (PTW-PAUSE.O) | | In function ' __pause_nocancel ': |
(. text+0x18) | | Undefined reference to ' __syscall_error ' |
/USR/LIB/LIBPTHREAD.A (PTW-PAUSE.O) | | In function ' __pause_nocancel ': |
(. text+0x3b) | | Undefined reference to ' __syscall_error ' |
/USR/LIB/LIBPTHREAD.A (INIT.O) | | In function ' __pthread_initialize_minimal ': |
(. text+0x1c) | | Undefined reference to ' __libc_setup_tls ' |
/USR/LIB/LIBPTHREAD.A (INIT.O) | | In function ' __pthread_initialize_minimal ': |
(. text+0x236) | | Undefined reference to ' _dl_init_static_tls ' |
/USR/LIB/LIBPTHREAD.A (INIT.O) | | In function ' __pthread_initialize_minimal ': |
(. text+0x240) | | Undefined reference to ' _dl_wait_lookup_done ' |
/USR/LIB/LIBPTHREAD.A (PTW-READ.O) | | In function ' __read_nocancel ': |
(. text+0x26) | | Undefined reference to ' __syscall_error ' |
/USR/LIB/LIBPTHREAD.A (PTW-READ.O) | | In function ' __read_nocancel ': |
(. text+0x56) | | Undefined reference to ' __syscall_error ' |
/USR/LIB/LIBPTHREAD.A (PTW-OPEN.O) | | In function ' __open_nocancel ': |
(. text+0x26) | | Undefined reference to ' __syscall_error ' |
/USR/LIB/LIBPTHREAD.A (PTW-OPEN.O) | | In function ' __open_nocancel ': |
(. text+0x56) | | Undefined reference to ' __syscall_error ' |
/USR/LIB/LIBPTHREAD.A (SIGACTION.O) | | In function ' __libc_sigaction ': |
(. text+0x46) | | Undefined reference to ' _DL_SYSINFO_DSO ' |
|| = = = Completed Build: 12 errors, 0 warnings ===|

It's a faint dish to see this. The predecessor was able to guide the maze. Thank.
Documents are scheduled #include <pthread.h>

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.