Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Errors in compilation under Linux and their Solutions

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains the "Linux compilation errors and solutions", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Linux compilation errors and solutions" bar!

(1) because he is a novice in Linux, he just started thread programming. Input and compile according to an example in the GUN/Linux programming guide, resulting in the following error:

Undefined reference to 'pthread_create'

Undefined reference to 'pthread_join'

The cause of the problem:

The pthread library is not the default library for the Linux system, and you need to use the static library libpthread.a when connecting, so you need to link it when you create a thread using pthread_create () and when you call the pthread_atfork () function to set up a fork handler.

Problem solving:

Add the-lpthread parameter to the compilation

Gcc-o thread thread.c-lpthread

Thread.c is some source files for you, don't forget to add the header file # include

(2) warning: implicit declaration of built-in function strlen incompatibility, implicit declaration of built-in function exit incompatibility

The reason for the problem: because the function strlen is in string and exit is in stdlib. The header files string.h and stdlib are not added to the file

Problem solving: add header files string.h and stdlib to the file

(3) error occurred: the storage size of sem_union is unknown

The reason for the problem: the union sem_union consortium has been annotated in the new 2.6 kernel, so you need to write it yourself.

Problem solving: define in C file first

Union semun {int val; struct semid_ds * buf; unsigned short * array;} sem_union

It can then find the predefined sem_union complex when it compiles.

Thank you for your reading, the above is the "Linux compilation errors and solutions" content, after the study of this article, I believe you under the Linux compilation errors and solutions to this problem have a deeper understanding, the specific use of the need for practice to verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report