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 linux compiles cpp files

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

Share

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

This article mainly introduces how linux compiles cpp files, which can be used for reference by friends who need it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.

If we have a written demo.cpp function, how can we compile the program and run the result in linux system?

We can carry out the order:

Gmail + demo.cpp-o demo

Generate the executable program demo, and then execute the command:

. / demo

Then you can execute the program.

Similarly, if it is a .c file, you can execute the command:

Gcc demo.c-o demo

In addition, when compiling, if we need to add the header file and the path of the library file, we can refer to the following parameters:

-l: used to specify the library to be linked by the program, and the-l parameter is followed by the library name. The relationship between the library name and the real library file name can be interpreted as: if the library name is caffe, its library file name is libcaffe.so.

-L: the compiler follows the path specified by-L to look for library files. Generally, you can specify multiple library files with-l at a time after-L. For example, .a (static library) and .so (dynamic library) under linux.

-I: the compiler follows the path specified by-I to search for the header file. (xxx.h)

For example, suppose I have written a demo.cpp file and need to use the related files of caffe. You can execute the command:

Gmail + demo.cpp-o demo-I ~ / caffe/include/-D CPU_ONLY\-I ~ / caffe/.build_debug/src/-L ~ / caffe/build/lib-lcaffe thank you for reading this article carefully. I hope it is helpful for everyone to share how linux compiles the contents of cpp files. At the same time, I also hope you can support us, pay attention to the industry information channel, find problems and learn detailed solutions!

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