Skip to content

Latest commit

 

History

History
44 lines (32 loc) · 2.02 KB

SELF-HELP.md

File metadata and controls

44 lines (32 loc) · 2.02 KB

questions records during programing and compiling

What's ./configure; make; make; install

details link: https://zhuanlan.zhihu.com/p/77813702

Most frequently used to compile and install cpp program commands are as follows:

cd /path/to/source
./configure
make
make install

./configure: make sure c compiler and dependent packages(dpkgs) needed have been installed in system. And generate Makefile from Makefile.in(Makefile Template) for compiling.

make: compile the source code according to Makefile. Pls read make && Makefile Tutorial below for futher information.

make install: install the program to system, by copying:

  1. the executable file usually to /usr/local/bin
  2. shared object files(.so) usually to /usr/local/lib
  3. header file usually to /usr/local/include
  4. static library(.a) usually to /usr/local/lib.

btw: Files configure and Makefile.in are generated by autotools most often.

How to use dynamic library(shared object file, short for .so) in linux?

details links: https://www.baeldung.com/linux/library_path-vs-ld_library_path; https://man7.org/linux/man-pages/man1/ld.1.html; https://www.man7.org/linux/man-pages/man8/ld.so.8.html

System will search for all shared object files at runtime. However, in linux, compiler only searches /usr/local/lib, /usr/lib(sometimes /usr/local/lib is not included) and env variable:$LD_LIBRARY_PATH by default.

Hence, export $LD_LIBRARY_PATH=/path/to/lib:$LD_LIBRARY_PATH is recommended.

btw:

defines: ld: GNU linker; id.so: GNU dynamic linker

  1. $LIBRARY_PATH: In addition to the standard default directories like /usr/lib or /usr/local/lib, ld, also uses the directories in LIBRARY_PATH while searching for libraries in the linking phase.
  2. $LD_LIBRARY_PATH: Same as $LIBARAY_PATH, but it's used at runtime.
  3. "LD" in $$LD_LIBRARY_PATH shorts for "Load".
  4. $PATH is the env variable that tells system where to find executable files.

make && Makefile Tutorial

link: https://www.ruanyifeng.com/blog/2015/02/make.html