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

How to deal with static Link Library and template Class in Linux

2025-01-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly introduces how to deal with static link libraries and template classes in Linux. It is very detailed and has a certain reference value. Friends who are interested must read it!

Before reading this article, the editor first introduces you to a related article: the fast sorting algorithm of Linux static link library using class templates

What happens when a template encounters a static link library.

Let's first consider the steps of a static link library in a conventional way:

1. Extract some functions, put them in a cpp file, and put the interfaces or exported classes in the header file.

2.gcc-c compiles the file to generate .o

The 3.ar command packages .o files into .a, that is, static link libraries.

4. Compile the main function and link the static link library to generate an executable file.

OK, following this line of thinking, we modify the previously written quick sort code as follows:

Lib_test.h:

/ / lib_test.h//head file of quick sort//users should realise operator > and

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: 263

*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