Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to not #define STB_IMAGE_IMPLEMENTATION / STB_IMAGE_WRITE_IMPLEMENTATION #36

Closed
lmdsp opened this issue Aug 28, 2024 · 0 comments
Labels
documentation Improvements or additions to documentation question Further information is requested

Comments

@lmdsp
Copy link

lmdsp commented Aug 28, 2024

As stb_image is quite a popular library, it is quite possible that STB_IMAGE_IMPLEMENTATION and/or STB_IMAGE_WRITE_IMPLEMENTATION macros will already have been set elsewhere, which leads to multiply defined symbols and possibly linker errors.

It would be quite straightforward to modifiy plutovg_surface.c to avoid this, something along the lines of this:

#ifndef PLUTOVG_EXTERNAL_STB_IMAGE_WRITE
#define STB_IMAGE_WRITE_IMPLEMENTATION
#endif // PLUTOVG_EXTERNAL_STB_IMAGE_WRITE

#include "stb_image_write.h"

#ifndef PLUTOVG_EXTERNAL_STB_IMAGE
#define STB_IMAGE_IMPLEMENTATION
#endif // PLUTOVG_EXTERNAL_STB_IMAGE

#include "stb_image.h"

This way we can control wether only stb function prototypes get defined or not and no other part of plutovg is changed.

@sammycage sammycage added question Further information is requested documentation Improvements or additions to documentation labels Aug 28, 2024
sammycage added a commit that referenced this issue Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants