nmwsharp / nmwsharp/polyscope

Building Polyscope as a shared library on Windows

Ouverte
#330 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
C++
Étoiles
2.2k
Forks
242
Merge moyen
11 min
PR mergées (30 j)
1

Description

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 😄

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par la cible de bibliothèque partagée dans src/CMakeLists.txt, puis examinez deps/imgui/CMakeLists.txt et deps/stb/CMakeLists.txt avec le paramètre de build de GLM. Exécutez le build de la bibliothèque partagée sous Windows et déterminez la configuration approuvée des dépendances/de l’exportation ; c’est terminé lorsque l’édition de liens s’effectue sans symboles non résolus.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
cmake, cpp
Domaine
build-system, operating-systems
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.