Objective
Have always been to Linux and vim, in fact, Windows is also very good, because there are some situations in the work can only use Windows to develop, including some APIs or SDK are only Windows version, just use Linux when the feeling and computer especially close to the feeling, hahaha, exaggerated.
As for VIM (which is not a better question of vim and Emacs here, this is a philosophical question), compared to most people are accustomed to using the IDE for programming, the use of vim is much more difficult, so if not a professional developer, there is no need to use VIM programming, but sometimes want to , if the university's programming class taught not to use the IDE programming but the text editor programming, estimation for many people who love the development of the efficiency is much higher, because with the IDE there are a lot of you do not know why all the wrong appearance, I also after a long period of accumulation, plus read the C + + object model And the use of VIM programming to slowly understand the once "unreasonable" error.
Most importantly, once you have mastered the Linux use of VIM programming, then those about the link library and header file link problem will be solved.
What is makefile?
I believe that if you do not use the IDE programming, you have to do is to connect the header files, library files and source files using makefile.
Online there are like "makefile Classic tutorial" such as the tutorial, but said, I also see that no less than three times did not fully remember, but the actual use, in fact, not all are used, even in large-scale team projects, while using more than I provide the makefile template is enough to cope with, Those advanced features (such as variables, function usage) are more likely to be used in writing an SDK or API or library of functions.
My makefile Template
#Makefile filedir_inc =./include #所有头文件放到此处DIR_SRC =./scr #所有源文件放到此处DIR_OBJ =./obj #所有中间件文件放到此处DIR_BIN =./bin #生成的文件放到 Here dir_3rd =./3party #第三方库的头文件放到此处DIR_LIB =./lib #第三方库文件的链接库放到此处SRC = $ (wildcard ${dir_src}/*.cc) OBJ = $ (Patsubst%.cc,${ dir_obj}/%.o,$ (Notdir ${src})) TARGET = Mian #生成的文件名BIN_TARGET = ${DIR_BIN}/${TARGET}CC = G++cxxflags =-g-wall-i${dir_in C}-i${dir_3rd}ldflags =-l${dir_lib}libs=-lopencv_core-lopencv_highgui #链接库模块, separate multiple files with spaces ${bin_target}: ${OBJ} $ (CC) $ (OBJ)-o [email protected] $ (ldflags) $ (LIBS) ${dir_obj}/%. o:${dir_src}/%.cc $ (cc) $ (cxxflags)-C $<-o [email protected].phony:cleanclean: find ${dir_obj}-name *.o- exec rm-rf {}\;
Some precautions
- The entire makefile file do not use the space bar is the most secure, you see all the space is actually a tab generated, once the space bar is used, the file is the default space is a part of the compilation language, which will lead to the occurrence of errors. including when writing comments, do not use spaces, I just because the diagram convenient to use the space to align all the comments, the result, wasted 1.5 hours to troubleshoot the cause.
- When using the-L Connection Library module, do not write the file name directly, you want to remove the lib in the beginning of the file name. For example, the source file is libopencv_core.so, and-lopencv_core is used when connecting.
- Multiple connection modules, separated by spaces.
Reprint Please specify source: http://blog.csdn.net/luoyun614/article/details/42806875
Self-created makefile template under Vim programming