In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "Linux how to build static link library .lib file", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "Linux how to build static link library .lib file" bar!
There are two main steps:
1. Compile source code
two。 Production library
= =
Take two simple source codes as examples to demonstrate the specific process of making static libraries.
1. Compile source code
Hello_first.c
Void hello_first (void)
{
Printf ("hello first")
}
Hello_second.c
Void hello_second (void)
{
Printf ("hello second")
}
Compile:
Gcc-c hello_first.c-o hello_first.o
Gcc-c hello_second.c-o hello_second.o
two。 Make a static library
Ar-r libhello.a hello_first.o hello_second.o
Specific instance of calling library
Hello_main.c
# include "stdio.h"
Void hello_first (void)
Void hello_second (void)
Int main ()
{
Hello_first ()
Hello_second ()
Return 0
}
Compile:
The first method:
Gcc hello_main.c libhello.a-o hello_main
The second method:
Copy libhello.a to / lib directory
Gcc hello_main.c-lhello-o hello_main2
Run the screenshot:
OK! Static library call succeeded!
Think about:
What is the function of static library? Why invent it?
1. Static libraries are mainly used to facilitate programmers' programming, and the functions to be used are encapsulated into libraries. Just tell them the function interface, so the programmer only needs to know how to call it. The manufacturer can keep the interface unchanged and modify and maintain the code.
two。 In addition, it is possible that programmers encapsulate the functions they often use, so that they don't have to write them repeatedly, just declare them before calling.
Thank you for reading, the above is the content of "Linux how to build static link library .lib file". After the study of this article, I believe you have a deeper understanding of how Linux establishes static link library .lib file, and the specific use needs to be verified in practice. 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.