memononen / nanovg

Antialiased 2D vector drawing library on top of OpenGL for UI and visualizations.
zlib License
5.06k stars 767 forks source link

building into a shared library #662

Open nextdayy opened 11 months ago

nextdayy commented 11 months ago

hi, I recently tried to build nanovg as a shared library by changing the type to SharedLib in the file, and creating a nanovg_gl2.c file which included the files, but it would fail to build. (missing glFramebuffer stuff)

I am mainly unsure of what actually needs to be included if all I want is the nanovg API and the opengl 2 implementation (all the other stuff like GLFW I don't need)

I am attempting to compile it so I can use it with JNA to access the API, and any help would be appreciated (I have looked at the other similar issue by the way) Many thanks.

vinjn commented 10 months ago

Are you using it on Android?

nextdayy commented 10 months ago

no, just trying to build for JNA. we are specifically targeting Linux, MacOS, MacOS ARM, and Windows. I was trying to build on Linux.

vinjn commented 10 months ago

Ok - glFramebuffer stuff is not part of nanovg, it's covered by libraries like glew, did you built the library aginst glew?

nextdayy commented 10 months ago

yeah, I'm not sure how I'd build against glew into JNA - firstly when I tried with it with glew, it wouldn't work as shared library, but also, I don't know how to do it with glew in the JNA (I guess I'd need to include glew as well?)

vinjn commented 10 months ago

Yes, you need to include glew

dylanxyz commented 8 months ago

You may look at the scripts i wrote in build_tarballs.jl, which builds nanovg as a shared library to be used from the julia language.

Additionally, i converted the premake file to a CMake one. You can see it here: CMakeLists.txt. There are also some patches for some headers missing, but this may vary depending on the platform you're building for.