akrinke / Font-Stash

A dynamic font glyph cache for OpenGL.
114 stars 18 forks source link

Running Makefile with nmake -f on Windows: fatal error U1033: syntax error : '=' unexpected #12

Closed vexe closed 8 years ago

vexe commented 8 years ago

Also, adding the header files to my project and #including them yield all sorts of linker errors (e.g. the sample code you have in the readme), which is why I tried the Makefile. I thought I could just drop in the header files and include them and things would go cozy, not the case it seems.

Am I missing something?

akrinke commented 8 years ago

To use Font-Stash, copy fontstash.* and stb_truetype.* to your project and include fontstash.h.

The Makefile was written for GNU make on Linux. I guess it needs some changes to work with nmake and you would need sdl-config and pkg-config on Windows. So you probably shouldn't use the Makefile on Windows.

If you want to compile the sample program (main.c) on Windows, you need to install SDL and SDL_image. Then you have to figure out, how to compile a program using these libraries and OpenGL. That depends heavily on your development environment (compiler, editor/IDE). The Makefile can give you some hints, though.

What linker errors do you get?

vexe commented 8 years ago

Thanks for the reply. Yes I included all the headers including Sean's files (4 files in total) I just copy-pasted the sample code you had in the repository under the usage section (not in main.c) and got:

1>Breakout.obj : error LNK2019: unresolved external symbol "struct sth_stash * __cdecl sth_create(int,int)" (?sth_create@@YAPAUsth_stash@@HH@Z) referenced in function "void __cdecl FontTest(void)" (?FontTest@@YAXXZ)
1>Breakout.obj : error LNK2019: unresolved external symbol "int __cdecl sth_add_font(struct sth_stash *,char const *)" (?sth_add_font@@YAHPAUsth_stash@@PBD@Z) referenced in function "void __cdecl FontTest(void)" (?FontTest@@YAXXZ)
1>Breakout.obj : error LNK2019: unresolved external symbol "void __cdecl sth_begin_draw(struct sth_stash *)" (?sth_begin_draw@@YAXPAUsth_stash@@@Z) referenced in function "void __cdecl FontTest(void)" (?FontTest@@YAXXZ)
1>Breakout.obj : error LNK2019: unresolved external symbol "void __cdecl sth_end_draw(struct sth_stash *)" (?sth_end_draw@@YAXPAUsth_stash@@@Z) referenced in function "void __cdecl FontTest(void)" (?FontTest@@YAXXZ)
1>Breakout.obj : error LNK2019: unresolved external symbol "void __cdecl sth_draw_text(struct sth_stash *,int,float,float,float,char const *,float *)" (?sth_draw_text@@YAXPAUsth_stash@@HMMMPBDPAM@Z) referenced in function "void __cdecl FontTest(void)" (?FontTest@@YAXXZ)
1>C:\Users\pc\Documents\Visual Studio 2015\Projects\Breakout\Debug\Breakout.exe : fatal error LNK1120: 5 unresolved externals

Running Visual Studio 2015 Community Edition with OpenGL, GLEW and GLFW all setup correctly.

akrinke commented 8 years ago

This looks like you are compiling your code as C++. Could you try wrapping fontstash.h in extern "C" { } like in the following commit: lsmoura/Font-Stash@ab33e3c5e93943b86e3295f5a09c290a674ce4f4

vexe commented 8 years ago

That worked, thanks!