I've got a simple program:
#include <GL/gl.h>
#include <GLFW/glfw3.h>
#include <cglm/cglm.h>
#include <ft2build.h>
#include FT_FREETYPE_H
int main(void){
/* Initializing fonts */
FT_Library ft;
if(FT_Init_FreeType(&ft)) {
fprintf(stderr, "Failed initializing Freetype\n");
return -1;
}
/* * * * * * * * * * * */
return 0;
}
Which I compile with:
i686-w64-mingw32-gcc game.c -lglfw3dll -lopengl32 -lfreetype -lmingw32 -lgdi32 -luser32 -lkernel32 -lpthread -lm $(pkg-config --cflags freetype2 | sed "s//usr///usr/i686-w64-mingw32//g") -O3 -o Game
There seems to be an error at the time of linking the program:
/usr/lib/gcc/i686-w64-mingw32/11.2.0/../../../../i686-w64-mingw32/bin/ld: /tmp/ccYBzSJN.o:main.c:(.text.startup+0x13e): undefined reference to `FT_Init_FreeType'
How can I fix this?
I'm pretty sure
sed "s//usr///usr/i686-w64-mingw32//g"won't work. Maybesed "s?/usr/usr/i686-w64-mingw32??g" might work, but I recommend you usepkg-config --define-prefix --cflags freetype2without sed, to letpkg-config` figure out the correct path.Also, you are compiling and linking with one line, so you will also need to add the linker flags (
pkg-config --define-prefix --libs freetype2).So try something like this: