- 你可能不知道的shell 陈皓推荐的一些有用而冷门的shell
- 如何调试bash脚本 依然是陈皓的分享
Android开发时,在AndroidManifest.xml中指定特定的权限
如下,指明程序有访问网络和写扩展存储(SDCARD)的权限.
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
libcurl 7.52.0 编译 OpenSSL 依赖。
1.使用如下目录结构
1 2 3 4 5 6 7 8 |
somedirectory\ |_curl-src | |_winbuild | |_deps |_ lib |_ include |_ bin |
2.将 OpenSSL 的 lib,dll,头文件(带openssl文件夹) 分别拷贝到 deps 路径的 lib,bin,include 目录下
3. 进入 winbuild 目录。
1 |
nmake /f Makefile.vc mode=dll WITH_SSL=dll ENABLE_WINSSL=no |
编译正确。但是在链接阶段出现 openssl.obj 中的某些符号无法链接:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
openssl.obj : error LNK2019: 无法解析的外部符号 _OpenSSL_version_num,该符号在函数 _Curl_ossl_version 中被引用 openssl.obj : error LNK2019: 无法解析的外部符号 _EVP_PKEY_get0_RSA,该符号在函数 _get_cert_chain 中被引用 openssl.obj : error LNK2019: 无法解析的外部符号 _EVP_PKEY_get0_DSA,该符号在函数 _get_cert_chain 中被引用 openssl.obj : error LNK2019: 无法解析的外部符号 _EVP_PKEY_get0_DH,该符号在函数 _get_cert_chain 中被引用 openssl.obj : error LNK2019: 无法解析的外部符号 _RSA_get0_key,该符号在函数 _get_cert_chain 中被引用 openssl.obj : error LNK2019: 无法解析的外部符号 _RSA_get0_factors,该符号在函数 _get_cert_chain 中被引用 openssl.obj : error LNK2019: 无法解析的外部符号 _RSA_get0_crt_params,该符号在函数 _get_cert_chain 中被引用 openssl.obj : error LNK2019: 无法解析的外部符号 _DH_get0_pqg,该符号在函数 _get_cert_chain 中被引用 openssl.obj : error LNK2019: 无法解析的外部符号 _DH_get0_key,该符号在函数 _get_cert_chain 中被引用 openssl.obj : error LNK2019: 无法解析的外部符号 _DSA_get0_pqg,该符号在函数 _get_cert_chain 中被引用 openssl.obj : error LNK2019: 无法解析的外部符号 _DSA_get0_key,该符号在函数 _get_cert_chain 中被引用 openssl.obj : error LNK2019: 无法解析的外部符号 _X509_get_version,该符号在函数 _get_cert_chain 中被引用 openssl.obj : error LNK2019: 无法解析的外部符号 _X509_get_X509_PUBKEY,该符号在函数 _pkp_pin_peer_pubkey 中被引用 openssl.obj : error LNK2019: 无法解析的外部符号 _X509_get0_extensions,该符号在函数 _get_cert_chain 中被引用 openssl.obj : error LNK2019: 无法解析的外部符号 _SSL_CTX_set_options,该符号在函数 _ossl_connect_step1 中被引用 openssl.obj : error LNK2019: 无法解析的外部符号 _TLS_client_method,该符号在函数 _ossl_connect_step1 中被引用 |
检查 libcurl\lib\vtls\openssl.c 文件,发现这些符号都与 OPENSSL_VERSION_NUMBER 宏有关。这个宏在 openssl的头文件 opensslv.h 中定义。
在 libcurl\lib\vtls\openssl.h 中添加 opensslv.h 引用,重新编译,可解决此问题。
当我们在实现一个带有引用参数的函数时,可能会将该参数的地址存储在该函数作用域外的某个地方。如下代码所示:
MyObject* pObj = NULL;
MyObject tempObj;
void Fun(const MyObject& obj)
{
pObj = &obj;
}tempObj.Release();
pObj.DoSomething();
当变量tempObj释放后,pObj仍保留了其地址。这将导致pObj变为空悬指针。
为了避免此类BUG出现,Mark Linton提出了如下法则:
函数中,禁止将引用参数的指针保存到函数作用域外。如果确有需要,需要将引用参数声明为指针参数