M2Crypto安装方法以及配置LDFLAGS、CFLAGS

python3.7+mac环境:

$ brew install openssl && brew install swig
$ brew --prefix openssl
/usr/local/opt/openssl
$ LDFLAGS="-L$(brew --prefix openssl)/lib" \
CFLAGS="-I$(brew --prefix openssl)/include" \
SWIG_FEATURES="-I$(brew --prefix openssl)/include" \
pip install m2crypto

关于swig的作用

  SWIG is an interface compiler that connects programs written in C and C++ with scripting languages such as Perl, Python, Ruby, and Tcl. It works by taking the declarations found in C/C++ header files and using them to generate the wrapper code that scripting languages need to access the underlying C/C++ code. In addition, SWIG provides a variety of customization features that let you tailor the wrapping process to suit your application

CFLAGS与LDFLAGS

CFLAGS的选项-I : 用于把新目录添加到include路径上,可以使用相对和绝对路径,“-I.”、“-I./include”、“-I/opt/include”

LDFLAGS的选项-L:用于把新目录添加到库搜索路径上,可以使用相对和绝对路径,“-L.”、“-L./include”、“-L/opt/include”

Makefile 选项 CFLAGS 、LDFLAGS 、LIBS

CFLAGS 表示用于C编译器的选项
CXXFLAGS 表示用于C++编译器的选项
这两个变量实际上涵盖了编译和汇编的两个步骤

CFLAGS:指定头文件(.h)的路径,如:CFLAGS=-I/usr/include -I/path/include 。

相同地,安装一个包时会在安装路径下建立一个include文件夹,当安装过程中出现故障时,试着把曾经安装的包的include文件夹增加到该变量中来。

LDFLAGS:gcc 等编译器会用到的一些优化參数,也能够在里面指定库文件的位置。使用方法:LDFLAGS=-L/usr/lib -L/path/to/your/lib。每安装一个包都一定会在安装文件夹里建立一个lib文件夹

LIBS:告诉链接器要链接哪些库文件。如LIBS = -lpthread -liconv

简单地说,LDFLAGS是告诉链接器从哪里寻找库文件,而LIBS是告诉链接器要链接哪些库文件。

参考:

http://www.swig.org/exec.html

https://gitlab.com/m2crypto/m2crypto/blob/master/INSTALL.rst#macosx

https://blog.csdn.net/zhaoyun_zzz/article/details/82466031

https://www.cnblogs.com/lytwajue/p/7161742.html

posted @ 2019-01-30 21:18  脚本小娃子  阅读(926)  评论(0编辑  收藏  举报