01. 将光标调整至需要生成目录的地方 02. 按下[Ctrl+Shift+P]快捷键,输入[Markdown All in One: Create Table of Contents],然后回车执行即可
84 lines
6.4 KiB
Markdown
84 lines
6.4 KiB
Markdown
# vcpkg安装库失败常见错误及其解决方法
|
||
|
||
## 目录
|
||
- [vcpkg安装库失败常见错误及其解决方法](#vcpkg安装库失败常见错误及其解决方法)
|
||
- [目录](#目录)
|
||
- [1. 科学上网](#1-科学上网)
|
||
- [1.1 控制台设置代理](#11-控制台设置代理)
|
||
- [1.2 vcpkg包下载失败](#12-vcpkg包下载失败)
|
||
- [1.3 osg/osgEarth网络代理环境变量](#13-osgosgearth网络代理环境变量)
|
||
- [2. 遇到某些库编译错误时,在本地修改代码并使用修改后的代码编译](#2-遇到某些库编译错误时在本地修改代码并使用修改后的代码编译)
|
||
- [3. vcpkg ports内可以修改库的配置,如工程目录,windows SDK版本,以及部分错](#3-vcpkg-ports内可以修改库的配置如工程目录windows-sdk版本以及部分错)
|
||
- [4. 找不到Windows SDK库的错误修改:https://github.com/microsoft/vcpkg/issues/8288](#4-找不到windows-sdk库的错误修改httpsgithubcommicrosoftvcpkgissues8288)
|
||
- [5. vc错误: `error MSB4115: 函数“exists”只接受标量值,但其参数“$(ForceImportBeforeCppTargets)”的计算结果为`](#5-vc错误-error-msb4115-函数exists只接受标量值但其参数forceimportbeforecpptargets的计算结果为)
|
||
- [5. 编译GDAL 出现 +{}; 加号不明确](#5-编译gdal-出现--加号不明确)
|
||
- [6. Windows 7 Python 3.8](#6-windows-7-python-38)
|
||
|
||
|
||
## 1. 科学上网
|
||
|
||
vcpkg中大部份依赖均托管在github仓库中,由于国内特殊的网络环境,导致github大部分时间无法正常访问,尤其是下载较大源码包或文件时会出现网络错误,此时需要通过科学上网措施(目前统一使用Mielink)建立代理上网,建立代理后,一般会有一个本地代理端口,如果配置的不是全局代理,那么有时需要在控制台设定上网代理,下面介绍代理配置方法及一些网络相关的其它错误...
|
||
|
||
### 1.1 控制台设置代理
|
||
|
||
控制台设置网络代理,需要将2801修改成本机的科学上网代理端口
|
||
|
||
* set HTTP_PROXY=http://127.0.0.1:2801
|
||
* set HTTPS_PROXY=http://127.0.0.1:2801
|
||
|
||
### 1.2 vcpkg包下载失败
|
||
|
||
* 有时使用vcpkg安装指定库时,由于网络抽风,有时会出现无法成功下载某些源码包的情况,此时可先使用vcpkg安装一次,确认源码包的下载目录及保存的文件名(此二者有时不一致),然后使用以下方法下载压缩包,重命名后放在vcpkg的download目录中即可
|
||
* 关于库下载错误,可以通过迅雷或其它工具下载,然后添加到download目录,注意从命令行确认保存的文件名
|
||
|
||
### 1.3 osg/osgEarth网络代理环境变量
|
||
|
||
* set OSGEARTH_HTTP_DEBUG=1
|
||
* set OSG_CURL_PROXY="127.0.0.1"
|
||
* set OSG_CURL_PROXYPORT=2801
|
||
|
||
## 2. 遇到某些库编译错误时,在本地修改代码并使用修改后的代码编译
|
||
|
||
正常使用vcpkg install xxxx安装库时,出现编译错误,通过编译日志可以定位到具体的编译错误,但是默认情况下每次install时,都会从压缩包中重新解压一份新的代码到本地临时目录,因此无法对源代码进行修改并使用修复后的代码进行编译安装,此时,只需要在install时,额外指定--editable选项,即可使本次编译不生成临时源码目录(在一个固定的源码目录中),然后可手工编辑修改此目录中源代码,然后再使用install(此时仍需指定--editable选项)安装,这时,就会使用修改后的代码进行编译了...
|
||
通过prompt启动,然后进入vcpkg目录
|
||
VCPKG install 库名 --editable,可以在编译前修改库源码
|
||
|
||
## 3. vcpkg ports内可以修改库的配置,如工程目录,windows SDK版本,以及部分错
|
||
|
||
## 4. 找不到Windows SDK库的错误修改:https://github.com/microsoft/vcpkg/issues/8288
|
||
|
||
## 5. vc错误: `error MSB4115: 函数“exists”只接受标量值,但其参数“$(ForceImportBeforeCppTargets)”的计算结果为`
|
||
|
||
* 报错信息:
|
||
> 1>节点 1 上的项目“xxxxxx\buildtrees\libpq\x64-windows-dbg\libpq.vcxproj”(默认目标)。
|
||
> 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Current.targets(14,11): error MSB4115: 函数“exists”只接受标量值,但其参数“$(ForceImportBeforeCppTargets)”的计算结果为“C:/Users/gz/Desktop/vcpkg-2023.08.09/scripts/buildsystems/msbuild/vcpkg.targets;C:/Users/gz/Desktop/vcpkg-2023.08.09/buildtrees/libpq/x64-windows-dbg/vcpkg-libs.props”,不是标量值。 [xxxxxx\buildtrees\libpq\x64-windows-dbg\libpq.vcxproj]
|
||
> 1>已完成生成项目“xxxxxx\buildtrees\libpq\x64-windows-dbg\libpq.vcxproj”(默认目标)的操作 - 失败。
|
||
* 参考链接:https://github.com/conan-io/conan/issues/7806
|
||
* 解决方案:
|
||
> 修改对应库ports目录内的msvc.cmake文件
|
||
> /p:ForceImportBeforeCppTargets=\"${SCRIPTS}/buildsystems/msbuild/vcpkg.targets\"
|
||
>
|
||
> /p:ForceImportBeforeCppTargets=\"${build_path}/vcpkg-libs.props\"
|
||
|
||
## 5. 编译GDAL 出现 +[](){}; 加号不明确
|
||
|
||
* 错误信息:
|
||
> xxxxxx\buildtrees\gdal\src\v3.7.1-30395dad39\ogr\ogrsf_frmts\openfilegdb\filegdbindex_write.cpp(1298): error C2593: “operator +”不明确
|
||
> xxxxxx\buildtrees\gdal\src\v3.7.1-30395dad39\ogr\ogrsf_frmts\openfilegdb\filegdbindex_write.cpp(1298): note: 可能是“内置 C++ operator+(void (__cdecl *)(std::vector<GByte,std::allocator<_Ty>> &,const __int64 &,int))”
|
||
> with
|
||
> [
|
||
> _Ty=GByte
|
||
> ]
|
||
> xxxxxx\buildtrees\gdal\src\v3.7.1-30395dad39\ogr\ogrsf_frmts\openfilegdb\filegdbindex_write.cpp(1298): note: 或 “内置 C++ operator+(void (__vectorcall *)(std::vector<GByte,std::allocator<_Ty>> &,const __int64 &,int))”
|
||
> with
|
||
> [
|
||
> _Ty=GByte
|
||
> ]
|
||
> xxxxxx\buildtrees\gdal\src\v3.7.1-30395dad39\ogr\ogrsf_frmts\openfilegdb\filegdbindex_write.cpp(1298): note: 尝试匹配参数列表“(OpenFileGDB::FileGDBTable::CreateSpatialIndex::<lambda_0019e43095a67889bd1988df31ec838d>)”时
|
||
* 原因分析:由于C++版本原因,低版本并不支持该转换,因此直接去掉转换即可
|
||
* 解决方法:尝试去掉lambda前面的加号(该加号用于将lambda表达式转为传统函数指针,兼容老代码)
|
||
|
||
## 6. Windows 7 Python 3.8
|
||
|
||
如果用到的库依赖了Python3.8以上的版本,是无法在windows7正常运行的,解决办法是用3.8狸猫换太子,无痛替换掉vcpkg自动下载的python
|
||
貌似打补丁也可以实现让windows7支持3.9.2运行 |