Building Polyscope as a shared library on Windows

未关闭
#330 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
cmake, cpp

调研方向

从 src/CMakeLists.txt 中的 shared-library 目标开始,然后结合 GLM 构建设置检查 deps/imgui/CMakeLists.txt 和 deps/stb/CMakeLists.txt。运行 Windows shared-library 构建并确定已批准的依赖项/导出配置;在没有未解析符号的情况下完成链接即表示完成。

由索引模型根据 Issue 内容生成。

描述

On Windows, I managed to build polyscope as a shared library with a couple of changes:

  1. Export all symbols for polyscope
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -374,4 +374,7 @@
 set_target_properties(polyscope PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
 add_definitions(-DNOMINMAX)
+set_target_properties(polyscope PROPERTIES
+  WINDOWS_EXPORT_ALL_SYMBOLS ON
+)
 
 # Include settings
  1. Force imgui as static. Again, it would search for a .lib file but no symbols are exported.
--- a/deps/imgui/CMakeLists.txt
+++ b/deps/imgui/CMakeLists.txt
@@ -63,5 +63,5 @@
 
   add_library(
-          imgui
+          imgui STATIC
           ${SRCS}
           )

Alternative: Export all symbols like 1.

  1. Force stb as static. Otherwise, it would search for a non-existent .lib file because no symbols are exported.
--- a/deps/stb/CMakeLists.txt
+++ b/deps/stb/CMakeLists.txt
@@ -1,5 +1,5 @@
 # Create a library for the viewer code
 add_library(
-    stb
+    stb STATIC
     stb_impl.cpp
 )

I tried exporting all symbols but it did not work. I would get missing symbols:

[build] screenshot.cpp.obj : error LNK2001: unresolved external symbol "int stbi_write_png_compression_level" (?stbi_write_png_compression_level@@3HA)
  1. Tell glm to not build a library. It is header-only anyway:
set(GLM_BUILD_LIBRARY OFF CACHE BOOL "Use GLM as header-only" FORCE)

It is not optimal to export all symbols on Windows, but it works. Dropping this here for others to use.

Open to make a PR but I would rather figure out the approved method first 😄

主要语言
C++
星标
2.2k
派生
242
平均合并
11 分钟
30 天内合并 PR
1

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

nmwsharp/polyscope 的其他 Issue

查看 nmwsharp/polyscope 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。