常用工具使用¶
Authors: | Larry@ www.joyglue.com |
---|---|
Version: | 1.0 |
配置NPM¶
npm config set strict-ssl false
npm config set registry http://registry.npmjs.org
npm config set proxy=http://ip:port
npm config delete http-proxy
npm config delete https-proxy
编译相关¶
微软MD MT链接选项¶
- MD 是以微软产品为链接目标,动态链接入dll,是统一堆模型,使用msvcrt.lib
- MT 是以标准C为链接目标, 静态链接Libcmt.lib。在微软平台为多堆模型,申请释放内存必须在同一模块内。
GCC编译¶
编译gmp:
./configure; make check
编译mpfr
先打pack,然后再编:
./configure; make check
编译mpc:
./configure LDFLAGS=L/mpc-1.0.3/lib CPPFLAGS=-l/mpc-1.0.3/include/ make check
编译isl:
./configure LDFLAGS=/isl-0.14/pub/lib/ CPPFLAGS=-l/isl-0.14/pub/include/ make
编译gcc
sudo ./configure –prefix=$(pwd)/publish –with-gmp=/usr/local/gmp-5.1.3 –with-mpfr=... –with-mpc=... –enable-bootstrap –enable-share –enable-threads=posix –enable-checking=release –with-system-zlib –enable-__cxa_atexit –disable-libunwind-exceptions –enable-gnu-unique-object –enable-languages=c,c++,objc,obj-c++ –disable-dssi –with-ppl –with-cloog –with-tune=generic –with-arch_32=i686 –build=x86_64-redhat-linux
工具链¶
ar -x foo.a 解开成.o文件
gcc -fPIC 此参数是位置无关代码之意。 Position-independent Code。避免了早期动态库重复加载的问题,使动态库成为共享库。如果编译动态库时依赖有静态库,那么必须加此参数。
控制动态库的导出符号的可见性¶
- 控制一个函数的可见性
- __attribute__((visibility(“default|hidden”)))
- 控制一组
- #pragma visibility push(hidden) void foo1(); void fool2(); #pragma visibility pop
- CFLAGS -fvisibility=hidden
- strip命令擦除符号
示例:
#if 1
#define FOR_EXPORT __attribute__((visibility("default")))
#else
#define FOR_EXPORT
#endif
void FOR_EXPORT PrintMessage(){}
用nm -D foo.so 查看导出符号
Busybox 1.24.2的编译¶
出现Busybox undefined reference to ‘syncfs’ 错误 使用23版本的sync.c 文件替换后,问题解决。
make menuconfig
make
make install
make CONFIG_PREFIX=publish install
新版本的busybox可以执行以下find参数:
find . |xargs -l {}cp {} $D_PATH
find . |xargs -i cp {} $D_PATH
find . \(-size -7000k -name "*.asf"\) |xargs -l {}cp{} /targetdir
该find只支持单位k
cmake的使用¶
cmake -DCMAKE_BUILD_TYPE=Debug 编译调试版本
make package 打包
make package_source 打源码包
cmake -DCMAKE_TOOLCHAIN_FILE=../arm.cmakefile -DCMAKE_INSTALL_PREFIX=../publish
cmake --help-variable-list
cmake --help-variable CMAKE_TOOLCHAIN_FILE
例如: cmake .. -DCMAKE_TOOLCHAIN_FILE=../Platform/arm.cmake
Gperftool的使用:
先安装libunwind-0.99
./configure --prefix=$(pwd)/publish --enable-libunwind LDFLAGS="-L$(pwd)/lib"
使用 libtcmalloc_and_profiler.a库
机器需要安装graphviz生成图形
./pprof --pdf test test.prof>1.pdf
在windows下查看linux下的man文件¶
要把man文件转换成txt再看:
find . -type f -exec man -l {}>manul.txt \;
也可以转为html:
man -Thtml -l manpage > manpage.html
一些命令行:
pkill -u uid
lsattr -a
chattr -i somefile
firewall-cmd --get-active-zones
firewall-cmd --zone=public --add-port=8000/tcp --permanent
firewall-cmd --reload
firewall-cmd --zone=public --query-port=8000/tcp
firewall-cmd --zone=public --query-service=http
- centos7 add sudoer::
chmod 740 /etc/sudoers
vi /etc/sudoers
root ALL=(ALL) ALL
larry ALL=(ALL) ALL
chmod 440 /etc/sudoers
C宏定义¶
参见gcc文档Stringification关于#的作用。
Do{...}while(0) 是为了C程序员吞掉分号。见Swallowing the Semicolon。 如: macro_function(arg); 可以当函数的样子使用
sudo apt install python-pip python-dev pydoc pip
Rusthon 可以编译成JavaScript、c++的中间语言,用Python写的 cefPython、electron
语言间通信 www.zerorpc.io¶
server side¶
import zerorpc
class HelloRPC(object):
"pass a name, then it print out hello name!"
def hello(self,name):
return "hello, {0}!".format(name)
def main():
s = zerorpc.Server(HelloRPC())
s.bind("tcp://*:4242")
s.run()
if __name__ == "__main__": main()
client side¶
import zerorpc, sys
c = zerorpc.Client()
c.connect("tcp://127.0.0.1:4242")
name = sys.argv[1] if len(sys.argv)>1 else "dude"
print(c.hello(name))
cx-freeze¶
- 设置Qt plugin环境变量
QT_PLUGIN_PATH E:Anaconda3Libraryplugins
主py文件中涉及__file__的地方,做如下改变:
rootdir = None if getattr(sys, 'frozen', False): rootdir=os.path.dirname(sys.executable) else: rootdir = os.path.dirname(os.path.realpath(__file__)) sys.path.append(rootdir)
把Anaconda3\LibSite-packages\setuptools-27.2.0-py3.6目录下的pkg_resources拷贝到上一层目录。该目录由setuptools-27.2.0-py3.6.egg解压得到
安装KB2999226系统补丁
python3 格式化¶
>>>”{0:->20}”.format(“hello”) ‘—————hello’
0是占位符,代表第一个参数。冒号表示格式化,以-填充,右对齐,最小20个字符。其他还有<左对齐,^居中对齐
字典代替switch¶
selected = None
for k, v in {QMessageBox.Abort:"Abort",QMessageBox.Retry:"Retry",QMessageBox.Ignore:"Ignore"}.items():
if k==reply:
selected=v
QMessageBox.question(self,"title","you selected {}".format(selected),QMessageBox.Yes|
QMessageBox.No|QMessageBox.Cancel)