美文网首页
gcc 基本知识

gcc 基本知识

作者: lindyang | 来源:发表于2021-03-26 17:34 被阅读0次

选项

  • L(大写l): 库所在位置

-Ldir
Add directory dir to the list of directories to be searched for -l.

  • l(小写l): 库

-llibrary
-l library // POSIX compliance, not recommended.
除非指定 -static, 否则优先共享库;
顺序很重要;
循环引用要多次指定(gcc foo.c -lfoo -lbar -lfoo)
-( -) -start-group和--end-group 指定循环依赖关系的归档

  • I(大写i): include

变量

  • C_INCLUDE_PATH: 在 I 选项之后,在默认目录之前被搜索。
/usr/local/include/
/usr/include/
  • LIBRARY_PATH: gcc 编译时动态链接库
  • LD_LIBRARY_PATH: 程序加载运行时动态链接库

L 选项之后,在默认目录之前被搜索。

/usr/local/lib/
/usr/lib/
-fno-builtin
-fno-builtin-function: -fno-builtin-printf
ld -static
gcc -shared -fPIC -o lib.so lib.c

gcc -m32

ld -static -m elf_i386

pip

pip install \
    --global-option=build_ext \
    --global-option="-I/tmp/openssl/include" \
    --global-option="-L/tmp/openssl/lib" \
    --global-option="-R/tmp/openssl/lib" \
    cryptography==1.0;

CFLAGS

CFLAGS=-I/usr/include -I/path/include

LDFLAGS和LIBS区别

LDFLAGS = -L/var/xxx/lib -L/opt/mysql/lib -Wl,R/var/xxx/lib -Wl,R/opt/mysql/lib
LIBS = -lpthread -liconv

ld

ld

python 调用 so

import ctypes
from cytpes import create_string_buffer, c_int, c_char_p, c_void_p
so = ctypes.cdll.LoadLibrary
lib = so("./lib.so")
p = create_string_buffer(512)
code = lib.enums(p,sizeof(p), 0);

def callback_fn(buf, void_p):
    ...
    return 0
# end def

void_ppp = 123456
CMPFUNC = ctypes.CFUNCTYPE(c_int, c_char_p, c_void_p)
_callback_fn = CMPFUNC(callback_fn)
code = lib.monitor(_callback_fn, void_ppp)

clang --target=i386

相关文章

  • gcc 基本知识

    选项 L(大写l): 库所在位置 -LdirAdd directory dir to the list of di...

  • day01

    今天大概浏览了下《UnixProgrammingTools》, 知道了一下几方面的基本知识。 gcc编译器的使用 ...

  • redis

    GCC Linux 安装gcc、gcc-c++编译器 yum -y install gcc gcc-c++ GNU...

  • 5_嵌入式C语言编译器

    关键词:GCC与gcc有什么不同、交叉编译、 gcc关键编译选项 1. GCC与gcc有什么不同? GCC(GNU...

  • CentOS 7 安装 Redis

    1、安装gcc 查看gcc是否安装:$ yum list installed | grep gcc 安装gcc:$...

  • Centos7安装nginx

    1、gcc 编译依赖gcc环境,如果没有gcc环境,需要安装gcc yum install gcc-c++ 2、P...

  • yum升级高版本 5.3 gcc

    gcc 4.8安装 gcc 4.9 安装 gcc 5.2 安装

  • Nginx安装操作手册

    1.yum install gcc gcc-c++ (gcc -v) 2.yum -y install gcc z...

  • linux CentOS8安装redis

    安装编译工具 安装编译工具# yum install -y gcc gcc-c++检查gcc的版本# gcc --...

  • Linux gcc 静态库动态库制作

    gcc GCC, the GNU Compiler Collection。对应Terminal命令叫做gcc,它可...

网友评论

      本文标题:gcc 基本知识

      本文链接:https://www.haomeiwen.com/subject/ptajhltx.html