其他分享
首页 > 其他分享> > make 随笔

make 随笔

作者:互联网

# --with--cc-opt flag导致./configure时找不到对应库文件?
checking for --with-ld-opt="-Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E" ... found


checking for --with-ld-opt="-Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E" ... not found


'--with-cc-opt=-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong 
-grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables
 -fstack-clash-protection -fcf-protection 
 
 
 '--with-cc-opt=-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong 
 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables 
 -fstack-clash-protection -fcf-protection 
 -floop-unroll-and-jam  -ftree-loop-distribution  --param early-inlining-insns=160 --param inline-heuristics-hint-percent=800 --param inline-min-speedup=50
 --param inline-unit-growth=256  --param max-average-unrolled-insns=500 --param max-completely-peel-times=32 --param max-completely-peeled-insns=800
 --param max-inline-insns-auto=128 --param max-inline-insns-small=128 --param max-unroll-times=16 --param max-unrolled-insns=16'

gcc

  1. 预处理
    gcc -E x.cpp >test.ii将include代码导进来
  2. 编译
    gcc -S test.ii 生成汇编代码
  3. 汇编
    gcc -c test.s 生成.o (二进制文件)
  4. 链接
    g++ test.o -o test
  5. 运行 (运行时才会加载动态链接库)
    ./test

makefile

# first_make
# $^ 依赖 不重复
# $@ 目标
# @ 不显示命令执行过程 -失败不停止
# LD_LIBRARY_PATH=../xthread 运行的时候去哪里找链接库
TARGET=first_make
LIBS=-lpthread
#有的.o文件与要编译的文件不同目录,所以定义CXXFLAGS
CXXFLAGS=-I../test_gcc  
OBJS=first_make.cpp xdate.cpp
$(TARGET):$(OBJS)
	@#-@rm test
	@echo "begin build $(TARGET)"
	$(CXX) $^ -o $@ $(LIBS)
	@echo "a$(TARGET) build success"

clean:
	$(RM) $(OBJS) $(TARGET)
#尾部标对应的清理
.PHONY: clean *clean

-----------------
make clean
make

begin build first_make
gcc first_make.cpp xdate.cpp -o first_mak -lpthread
first_make build success

ldd xx.so

静态库 ar -crv libmylib.a mylib.o

动态库

标签:gcc,redhat,--,make,param,test,随笔
来源: https://www.cnblogs.com/hhds/p/15943350.html