multiple def errors
frutas-fruit opened this issue · 3 comments
I'm trying to add the nanovg src's to a c++ project. My project currently uses a lib which already has stb_freetype.h
inlined in it. But this is causing some multiple def linker errors, as nanovg also depends on these stb libs:
.....//nanovg/src/stb_image.h:4271: multiple definition of `stbi_convert_iphone_png_to_rgb'; CMakeFiles/binary.dir/src/main.cpp.o:main.cpp:(.text+0x1b4c0): first defined here
/usr/bin/ld: lib/nanovg/libnanovg.a(nanovg.c.o): in function `stbi_info':
.....//nanovg/src/stb_image.h:6423: multiple definition of `stbi_info'; CMakeFiles/binary.dir/src/main.cpp.o:main.cpp:(.text+0x1b4d0): first defined here
/usr/bin/ld: lib/nanovg/libnanovg.a(nanovg.c.o): in function `stbi_info_from_file':
.....//nanovg/src/stb_image.h:6433: multiple definition of `stbi_info_from_file'; CMakeFiles/binary.dir/src/main.cpp.o:main.cpp:(.text+0x1b610): first defined here
/usr/bin/ld: lib/nanovg/libnanovg.a(nanovg.c.o): in function `stbi_info_from_memory':
.....//nanovg/src/stb_image.h:6445: multiple definition of `stbi_info_from_memory'; CMakeFiles/binary.dir/src/main.cpp.o:main.cpp:(.text+0x1b720): first defined here
/usr/bin/ld: lib/nanovg/libnanovg.a(nanovg.c.o): in function `stbi_info_from_callbacks':
Any ideas of a clean solution to this issue?
FYI I am also including these headers once in my project:
#include <nanovg.h>
#define NANOVG_GL3_IMPLEMENTATION
#include <nanovg_gl.h>
And I have not explicitly defined any stb headers anywhere in my project
Did you define STB_IMAGE_IMPLEMENTATION
in your project? It has already defined in nanovg.c So you can try to remove it from nanovg.c It should work
Or try add STB_IMAGE_STATIC
in nanovg.c
It has already defined in nanovg.c So you can try to remove it from nanovg.c It should work
Awesome, yeah commented out STB_IMAGE_IMPLEMENTATION
and STB_TRUETYPE_IMPLEMENTATION
and it works well now! Cheers!