Ironbin


  • 首页

  • 关于

  • 标签

  • 分类

  • 归档

  • 搜索

NSIS 用法小结

发表于 2017-02-22 | 分类于 installer | | 阅读次数:

编译 Unicode 版本

在 nsi 文件开头加上宏配置:

1
Unicode true

注意

unicode 版本的 nsi 和 nsh 文件,需要将编码设置成 utf8 with BOM。不然编译器会仍然以 ACP 方式读取文件。

NSIS Users Manual

socket 常用数据结构

发表于 2017-02-16 | 分类于 c++ | | 阅读次数:

编译步骤

1. sockaddr

1
2
3
4
struct sockaddr {
unsigned short sa_family; // address family, AF_xxx
char sa_data[14]; // 14 bytes of protocol address
};

2. inet 相关

sockaddr_in 继承 sockaddr 并添加了一些 INET 的数据属性。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

// IPv4 AF_INET sockets:
struct in_addr {
unsigned long s_addr; // load with inet_pton()
};

struct sockaddr_in {
short sin_family; // e.g. AF_INET, AF_INET6
unsigned short sin_port; // e.g. htons(3490)
struct in_addr sin_addr; // see struct in_addr, below
char sin_zero[8]; // zero this if you want to
};

// IPv6 AF_INET6 sockets:
struct in6_addr {
unsigned char s6_addr[16]; // load with inet_pton()
};

struct sockaddr_in6 {
u_int16_t sin6_family; // address family, AF_INET6
u_int16_t sin6_port; // port number, Network Byte Order
u_int32_t sin6_flowinfo; // IPv6 flow information
struct in6_addr sin6_addr; // IPv6 address
u_int32_t sin6_scope_id; // Scope ID
};

sockaddr 转换为 sockaddr_in:

1
2
3

sockaddr from;
sockaddr_in to = (sockaddr_in)from;

3. sockaddr_storage

1
2
3
4
5
6
7
8
9
10
11
// General socket address holding structure, big enough to hold either
// struct sockaddr_in or struct sockaddr_in6 data:

struct sockaddr_storage {
sa_family_t ss_family; // address family

// all this is padding, implementation specific, ignore it:
char __ss_pad1[_SS_PAD1SIZE];
int64_t __ss_align;
char __ss_pad2[_SS_PAD2SIZE];
};

4. addrinfo

1
2
3
4
5
6
7
8
9
10
11
12

struct addrinfo {
int ai_flags; // AI_PASSIVE, AI_CANONNAME, ...
int ai_family; // AF_xxx
int ai_socktype; // SOCK_xxx
int ai_protocol; // 0 (auto) or IPPROTO_TCP, IPPROTO_UDP

socklen_t ai_addrlen; // length of ai_addr
char *ai_canonname; // canonical name for nodename
struct sockaddr *ai_addr; // binary address
struct addrinfo *ai_next; // next structure in linked list
};

struct sockaddr and pals

使用 VS2015 编译 cpp-netlib

发表于 2017-02-15 | 分类于 c++ | | 阅读次数:

cpp-netlib 官方文档

cpp-netlib 旨在用最新的 C++ 标准,提供易用的网络接口库。

  • 官方网站:官网提供最新的代码和库下载
  • GitHub:提供较早版本的下载

编译步骤

1. 编译 boost

1
2
bootstrap.bat
.\b2 install --prefix=C:\Users\jon\Desktop\builds\boost --toolset=msvc --without-python link=static runtime-link=shared debug release
  • runtime-link=shared 是使用动态库方式编译,对应 VS 设置值 runtime = MD
  • runtime-link=static 是使用静态库方式编译,对应 VS 设置值 runtime = MT

2. 生成 cpp-netlib 配置文件

1
2
3
4
5
mkdir cpp-netlib-build

cd cpp-netlib-build

cmake -G "Visual Studio 14" -DCMAKE_BUILD_TYPE=Debug -DBOOST_ROOT=C:/Users/jon/Desktop/builds/boost ..\cpp-netlib-0.12.0-final

其它的设置选项还有:

  • -DCMAKE_BUILD_TYPE=Debug
  • -DCMAKE_C_COMPILER=clang
  • -DCMAKE_CXX_COMPILER=clang++

3. 打开 cpp-netlib-build/CPP-NETLIB.sln 编译

可以全部编译,也可以根据需要单独编译某个模块。比如,单独编译 cppnetlib-uri 项目。编译好的文件输出在 cpp-netlib-build/libs/network/src/Release

遇到的问题

1. Invalid escape sequence \U

检查 -DBOOST_ROOT= 后面的路径分隔符是不是反斜扛。

使用 VS2015 编译 boost

发表于 2017-02-14 | 分类于 c++ | | 阅读次数:

boost 官方文档

最简单的编译方法

1
2
bootstrap.bat
.\b2.exe

当编译成功,会得到提示

1
2
3
4
5
6
7
8
9
10

The Boost C++ Libraries were successfully built!

The following directory should be added to compiler include paths:

C:\Users\jon\Desktop\boost_1_63_0

The following directory should be added to linker library paths:

C:\Users\jon\Desktop\boost_1_63_0\stage\lib

编译并指定目录

1
./b2 install --prefix=PREFIX

参考

编译参数示例

1
.\b2 install --prefix=C:\Users\jon\Desktop\builds\boost --toolset=msvc --without-python link=static runtime-link=shared debug release

使用 boost 头文件库(Header Only)

将下载的 boost 目录添加到项目的 include 路径即可

使用 boost 编译库(Header+CPP)

除了将 boost 目录添加到 include,还要将上面编译出来的 stage/lib 目录添加到 library 路径

Chromium 拾遗

发表于 2017-01-19 | 分类于 chromium | | 阅读次数:

记录 SSL 的 Session Key

在环境变量中添加一个变量

1
SSLKEYLOGFILE  C:\Users\Jonathan\Documents\SSLKEYLOGFILE.txt

可用的命令行参数

参考

Chrome 发布日历

最新日历

Chromium Development Calendar and Release Info

Chromium 分支和标签

src.git/+refs

Chrome 功能更新

查看 这里

Chrome CI 持续集成

查看 这里

chromium-browser-official

chromium-browser-official

chromium src

Chrome 历史离线包

Google Chrome Older Versions Download

Chrome 扩展抓取

  • 全部扩展列表
  • 抓取源码

Chrome 安装路径

  • mac:/Users/{user-name}/Library/Application Support/Google/Chrome
  • windows: C:/Users/{user-name}/App Data/Local/Google/Chrome
  • linux:/home/{user-name}/.config/google-chrome

PHPStorm 设置 watcher

发表于 2017-01-19 | 分类于 php | | 阅读次数:

步骤

Arguments:

1
--no-cache --update $FileName$:$ProjectFileDir$/dist/css/$FileNameWithoutExtension$.css

Outputs path to refresh:

1
$ProjectFileDir$/dist/css/$FileNameWithoutExtension$.css:$ProjectFileDir$/dist/css/$FileNameWithoutExtension$.css.map

编译 Chromium 常见问题

发表于 2017-01-17 | 分类于 chromium | | 阅读次数:

配置

命令行翻墙设置

Windows 命令行设置

1
2
3
set http_proxy=127.0.0.1:1080
set https_proxy=127.0.0.1:1080
set socks5_proxy=127.0.0.1:1080

Git 设置

1
2
git config --global http.proxy 127.0.0.1:1080
git config --global https.proxy 127.0.0.1:1080

获取代码

gclient sync 参数

–nohooks

–no-history

–with_branch_heads

–with_tags

–output-json

编译

DEPOT_TOOLS_WIN_TOOLCHAIN

GYP_GENERATORS=msvs-ninja,ninja

GYP_DEFINES

buildtype=Official

如果不添加 buildtype=Official 可能会遇到下面问题:

  1. XP 系统不能正常运行

在添加了该编译参数情况下,也会遇到某些奇怪问题:

  1. 在某些机器上,当打开某些页面,比如新浪视频,退出浏览器后,会收到网络层不能析构的 bug

gclient runhooks

gclient runhooks 会做二件事:一是检查编译环境,二是生成编译脚本。我们也可以跳过检查编译环境,直接生成编译脚本:

生成全部脚本

1
python src\build\gyp_chromium

生成某个工程

1
2
3
4
# chrome 工程
python src\build\gyp_chromium src\chrome\chrome.gyp
# 安装包工程
python src\build\gyp_chromium src\chrome\installer\mini_installer.gyp

Goutput_dir

错误

查找错误

1
ninja -C src/out/Debug chrome | findstr error

VS 忽略错误

VS2015 编译时会遇到一些错误,通过以下设置解决

1
2
3
4
4334, # 
4595, #
4275, #
4819, # The file contains a character that cannot berepresented in the current code page (936).

gclient sync 错误 1

1
2
3
4
5

fatal: Needed a single revision
Does not point to a valid commit: 4ce7fef091e1d63a3bfc2ed225619893b0eb1782
32> Unrecognized error, please merge or rebase manually.
32> cd src\third_party\libjingle\source\talk && git rebase --onto 4ce7fef091e1d63a3bfc2ed225619893b0eb1782 refs/remotes/origin/master

解决办法:

1
gclient sync --with_branch_heads

gclient sync 错误 2

1
2
> Cannot rebase:You have unstaged changes.
> Please commit or stash them.

解决办法:

忽略行结尾的不一致:

1
git config --global core.autocrlf true

Windows 系统语言错误

1
> The file contains a character that cannot berepresented in the current code page.

解决办法:

依次打开:Region and Language > Administrative > Langeuage for non-Unicode programs

点击 Change system locale…,切换为 English (United State)

SourceTree 操作被挂起

发表于 2017-01-17 | 分类于 git | | 阅读次数:

出现的问题

1
2
3
4
5
6
7
8
9
10
11
The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 59:ca:22:af:f9:8e:6f:f7:87:b3:ea:da:1b:2b:aa:f2
If you trust this host, enter "y" to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.

解决

手动连接一次 git 服务器,比如 GitLab,StackOverflow

1
"C:\Program Files (x86)\Atlassian\SourceTree\tools\putty\plink.exe" gitlab.com

Windows Batch 用法

发表于 2017-01-17 | 分类于 windows | | 阅读次数:

当前脚本目录

1
%~dp0

当前目录

1
for %%* in (.) do set CurrentDirName=%%~nx*

当前目录(不带斜线 )

1
2
SET mypath=%~dp0
echo %mypath:~0,-1%

WebBrowser 运行 ActiveX 异常

发表于 2017-01-17 | 分类于 activex | | 阅读次数:

问题描述

前段时间使用 VS2015 编译 WebBrowser 的程序,然后运行包含 ActiveX 的页面时,出现了一些奇怪的问题(呃…问题记不清了)。但是,换成 VS2008 或其它低版本编译器时,又不会出现该问题了。

解决

经过一翻查找,发现是编译参数 /NXCOMPAT 引起的,早期的 VS,该参数默认为 NO,新版本默认为 YES。可修改默认值为 NO 解决此问题。

参考

WebBrowser无法显示招商银行密码输入控件的问题

1…789…12
程学彬

程学彬

117 日志
48 分类
99 标签
Creative Commons
Links
  • ShinySky
0%
© 2014 — 2020 程学彬