Windows下编译Tangram-ES

源码

先下载源码

1
2
3
4
5
6
7
8
9
PS D:\Code> git clone https://github.com/tangrams/tangram-es.git
Cloning into 'tangram-es'...
remote: Enumerating objects: 64497, done.
remote: Counting objects: 100% (646/646), done.
remote: Compressing objects: 100% (287/287), done.
remote: Total 64497 (delta 317), reused 560 (delta 273), pack-reused 63851
Receiving objects: 100% (64497/64497), 39.53 MiB | 1.73 MiB/s, done.
Resolving deltas: 100% (46340/46340), done.
Updating files: 100% (1050/1050), done.

然后进入源码目录下载依赖仓库

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
cd tangram-es
PS D:\Code\tangram-es> git submodule update --init --recursive
Submodule 'external/benchmark' (https://github.com/google/benchmark) registered for path 'bench/benchmark'
Submodule 'external/SQLiteCpp' (https://github.com/SRombauts/SQLiteCpp.git) registered for path 'core/deps/SQLiteCpp'
Submodule 'external/alfons' (https://github.com/hjanetzek/alfons) registered for path 'core/deps/alfons'
Submodule 'core/dependencies/csscolorparser' (https://github.com/tangrams/css-color-parser-cpp) registered for path 'core/deps/css-color-parser-cpp'
Submodule 'core/include/earcut.hpp' (https://github.com/tangrams/earcut.hpp) registered for path 'core/deps/earcut'
Submodule 'core/dependencies/geojson-vt-cpp' (https://github.com/tangrams/geojson-vt-cpp.git) registered for path 'core/deps/geojson-vt-cpp'
Submodule 'external/harfbuzz-icu-freetype' (https://github.com/tangrams/harfbuzz-icu-freetype.git) registered for path 'core/deps/harfbuzz-icu-freetype'
Submodule 'core/include/isect2d' (https://github.com/tangrams/isect2d.git) registered for path 'core/deps/isect2d'
Submodule 'core/include/variant' (https://github.com/tangrams/variant) registered for path 'core/deps/variant'
Submodule 'external/yaml-cpp' (https://github.com/tangrams/yaml-cpp) registered for path 'core/deps/yaml-cpp'
Submodule 'external/glfw' (https://github.com/glfw/glfw) registered for path 'platforms/common/glfw'
Cloning into 'D:/Code/tangram-es/bench/benchmark'...
Cloning into 'D:/Code/tangram-es/core/deps/SQLiteCpp'...
Cloning into 'D:/Code/tangram-es/core/deps/alfons'...
Cloning into 'D:/Code/tangram-es/core/deps/css-color-parser-cpp'...
Cloning into 'D:/Code/tangram-es/core/deps/earcut'...
Cloning into 'D:/Code/tangram-es/core/deps/geojson-vt-cpp'...
Cloning into 'D:/Code/tangram-es/core/deps/harfbuzz-icu-freetype'...
Cloning into 'D:/Code/tangram-es/core/deps/isect2d'...
Cloning into 'D:/Code/tangram-es/core/deps/variant'...
Cloning into 'D:/Code/tangram-es/core/deps/yaml-cpp'...
Cloning into 'D:/Code/tangram-es/platforms/common/glfw'...
Submodule path 'bench/benchmark': checked out 'e776aa0275e293707b6a0901e0e8d8a8a3679508'
Submodule path 'core/deps/SQLiteCpp': checked out '4e3d36af2d4a612d548f5959532a7b97c9724e6b'
Submodule 'googletest' (https://github.com/google/googletest.git) registered for path 'core/deps/SQLiteCpp/googletest'
Cloning into 'D:/Code/tangram-es/core/deps/SQLiteCpp/googletest'...
Submodule path 'core/deps/SQLiteCpp/googletest': checked out '703bd9caab50b139428cea1aaff9974ebee5742e'
Submodule path 'core/deps/alfons': checked out '26a4dc693ad35609d4909141f763f1bad32e681f'
Submodule path 'core/deps/css-color-parser-cpp': checked out '1771826bc3a868e5e23e3ba6d2a024872218812d'
Submodule path 'core/deps/earcut': checked out '195b2fdae9a354c0f86592f320df4988c896f822'
Submodule 'glfw' (https://github.com/glfw/glfw.git) registered for path 'core/deps/earcut/glfw'
Cloning into 'D:/Code/tangram-es/core/deps/earcut/glfw'...
Submodule path 'core/deps/earcut/glfw': checked out '96cdcec58ac9ed6d6d9c7de26a1fc88a4f948d18'
Submodule path 'core/deps/geojson-vt-cpp': checked out '52c96b66467e9cf154509860a1b5ff936022f957'
Submodule '.mason' (https://github.com/mapbox/mason.git) registered for path 'core/deps/geojson-vt-cpp/.mason'
Cloning into 'D:/Code/tangram-es/core/deps/geojson-vt-cpp/.mason'...
Submodule path 'core/deps/geojson-vt-cpp/.mason': checked out 'fe6185ab2550d54d1581afe430d5c0f753072960'
Submodule path 'core/deps/harfbuzz-icu-freetype': checked out '67b579e42f6afb39646909af33f156a2cfe9d5e4'
Submodule path 'core/deps/isect2d': checked out '2e1a75cee09d9949900e926c61c86505b09205b2'
Submodule path 'core/deps/variant': checked out 'e26e56c3e7d5b819702ff71ee57d82be5b097f65'
Submodule '.mason' (https://github.com/mapbox/mason.git) registered for path 'core/deps/variant/.mason'
Cloning into 'D:/Code/tangram-es/core/deps/variant/.mason'...
Submodule path 'core/deps/variant/.mason': checked out '07179f160b96c72ddedbbe6bf82580d1a1d0091a'
Submodule path 'core/deps/yaml-cpp': checked out '49e11f16c1691a61f89367d8eb7dfa10d9153700'
Submodule path 'platforms/common/glfw': checked out '999f3556fdd80983b10051746264489f2cb1ef16'

依赖包

先按照vcpkg配置与使用配置vcpkg。

进入Tangram-es目录

执行

1
vcpkg install

它会自动安装一切依赖。

编译

1
2
3
mkdir build
cmake -S . -B .\build -G "Visual Studio 16 2019" -DCMAKE_TOOLCHAIN_FILE="<path to vcpkg>\scripts\buildsystems\vcpkg.cmake" # 生成S2019 工程
cmake --build .\build # 编译

自动生成VS工程

VS工程

编译中

编译中

编译完成后在Debug目录可以找到可执行文件

编译结果

导入API KEY,运行程序

运行效果

效果

效果演示

错误

编译报错

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
D:\Code\tangram-es\platforms\common\glfwApp.cpp(706,110): error C2664: “bool ImGui::InputFloat2(const char *,float [],c
onst char *,ImGuiInputTextFlags)”: 无法将参数 3 从“int”转换为“const char *” [D:\Code\tangram-es\build\tangram.vcxproj]
glfwApp.obj : error LNK2019: 无法解析的外部符号 "bool __cdecl ImGui::SliderAngle(char const *,float *,float,float,char const *,i
nt)" (?SliderAngle@ImGui@@YA_NPEBDPEAMMM0H@Z),函数 "void __cdecl Tangram::GlfwApp::showViewportGUI(void)" (?showViewportG
UI@GlfwApp@Tangram@@YAXXZ) 中引用了该符号 [D:\Code\tangram-es\build\tangram.vcxproj]
...
glfwApp.obj : error LNK2019: 无法解析的外部符号 "bool __cdecl ImGui::DebugCheckVersionAndDataLayout(char const *,unsigned __int6
4,unsigned __int64,unsigned __int64,unsigned __int64,unsigned __int64,unsigned __int64)" (?DebugCheckVersionAndDataLayo
ut@ImGui@@YA_NPEBD_K11111@Z),函数 "void __cdecl Tangram::GlfwApp::create(class std::unique_ptr<class Tangram::Platform,st
ruct std::default_delete<class Tangram::Platform> >,int,int)" (?create@GlfwApp@Tangram@@YAXV?$unique_ptr@VPlatform@Tang
ram@@U?$default_delete@VPlatform@Tangram@@@std@@@std@@HH@Z) 中引用了该符号 [D:\Code\tangram-es\build\tangram.vcxproj]
imgui_impl_glfw.obj : error LNK2019: 无法解析的外部符号 "public: void __cdecl ImGuiIO::AddInputCharacter(unsigned int)" (?AddInp
utCharacter@ImGuiIO@@QEAAXI@Z),函数 "void __cdecl ImGui_ImplGlfw_CharCallback(struct GLFWwindow *,unsigned int)" (?ImGui_
ImplGlfw_CharCallback@@YAXPEAUGLFWwindow@@I@Z) 中引用了该符号 [D:\Code\tangram-es\build\tangram.vcxproj]
D:\Code\tangram-es\build\Debug\tangram.exe : fatal error LNK1120: 3 个无法解析的外部命令 [D:\Code\tangram-es\build\tangram.vcxpro
j]

Tangram-es源码自带了imgui代码,vcpkg.json里面也有一个imgui,而且比较新,把vcpkg.json字段删除就可以了。


Windows下编译Tangram-ES
https://feater.top/tangram-es/compile-tangram-es-under-windows/
作者
JackeyLea
发布于
2024年1月4日
许可协议