Sly14 / freetype-gl

Automatically exported from code.google.com/p/freetype-gl
Other
0 stars 0 forks source link

Compiling with MinGW/MSys #49

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I ran into some problems when building the gl-3.0 branch (MinGW-64 under MSys):

1. round() is defined multiple times.
2. It doesn't link GLEW nor GLUT.

Why have you chosen to not link glew when building in windows? I had to add it 
to the makefile so it would link.

Is GLUT actually used for the library, or is it just for some of the demos? I 
don't actually have it on this computer, but the makefile didn't err, even 
though it wasn't found. It just silently ignored it, and the linker complained 
about unresolved symbols.

I'd rather not fiddle around with the CMakeLists.txt myself, because I'm still 
learning how this build system works.

Original issue reported on code.google.com by jlod...@gmail.com on 18 Mar 2013 at 4:08

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I can confirm the problem with round(). A quick fix/hack is to change it to 
take and return a double instead of float -- so it matches the existing library 
definition. Look in platform.c/h.

Cross compatibility is a bit of a mess since freetype-gl is written in C99 
(which has round() I believe), so for MSVC a definition is needed (since it has 
no C99-support) but not so for MinGW -- but the only distinction currently is 
between Windows/MacOS/Linux which doesn't account for this.

So a more proper fix is probably to surround round() with a "#if 
_MSC_VER"-block, keeping the surrounding "#if defined(_WIN32)||defined(_WIN64)" 
so strndup() is still added for both MSVC and MinGW.

Alternatively, maybe it's -- in general -- better to do all such distinctions 
on the compiler level and disregard OS completely? So the rule becomes 
something like "assume C99 on GCC, everything else is a special case with 
ifdefs for different compilers".

Original comment by cforf...@gmail.com on 23 Mar 2013 at 12:27

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Oh, and yeah GLUT is only for the demos. GLEW could probably be linked (I've 
submitted a patch to Nicolas which does this, and also fixes the linking of 
GLUT), but there's still the issue of differentiating between MSVC and MinGW 
versions of non-binary compatible libraries (which GLEW was for me -- I think 
it linked the bundled GLUT successfully however).

In general I think is probably a good idea to (re-)build all the external 
libraries yourself however -- even if it technically works there could still be 
some hidden issues. For instance, MSVC warns "LINK : warning LNK4098: 
defaultlib 'LIBCMT' conflicts with use of other libs; use 
/NODEFAULTLIB:library" if I use the bundled FreeType. Probably because it was 
linked with /MT instead of /MD. By compiling all of them myself I can be sure 
they're compatible. In this case, for GLEW/FreeType/(GLUT), it's very quick a 
painless as well, so there's really no reason not to.

Original comment by cforf...@gmail.com on 23 Mar 2013 at 12:53

GoogleCodeExporter commented 8 years ago
I managed to fix all issues. I just noticed that most errors were caused by 
minor mistakes in the CMakeLists.txt:

*GLUT_GLUT_LIBRARY should be GLUT_LIBRARY.
*FREETYPE_INCLUDE_DIRS is used even though it's never defined.

Original comment by jlod...@gmail.com on 24 Mar 2013 at 9:34

GoogleCodeExporter commented 8 years ago
Only warning I'm getting is the following:

freetype-gl/vertex-buffer.c:238:17: warning: cast from pointer to integer of 
different size [-Wpointer-to-int-cast]
                 (long) self->attributes[i]->pointer);

It's being cast to long as an argument to printf("%ld"), why not just use %p 
instead?

Original comment by jlod...@gmail.com on 24 Mar 2013 at 9:41

GoogleCodeExporter commented 8 years ago
I fixed the warning.
Should I close this issue then ?

Original comment by Nicolas.Rougier@gmail.com on 29 Mar 2013 at 7:25

GoogleCodeExporter commented 8 years ago
The main reason I opened this issue was because the cmakefile didn't work 
properly with msys/mingw.

For instance, on windows, it just includes the libraries in the windows folder, 
I think it should at least check first if find_package finds the libraries.
And also, there's the round() problem I mentioned in the first post.

If those issues are resolved, you can close this with a clean conscience. :)

Original comment by jlod...@gmail.com on 29 Mar 2013 at 11:43

GoogleCodeExporter commented 8 years ago
This is the error I'm getting:
In file included from d:/Dev/lib/freetype-gl/texture-font.c:45:0:
d:/Dev/lib/freetype-gl/platform.h:61:11: error: conflicting types for 'round'
     float round (float v);

Post #2 suggests a fix.

Original comment by jlod...@gmail.com on 29 Mar 2013 at 11:54

GoogleCodeExporter commented 8 years ago
Done !

Original comment by Nicolas.Rougier@gmail.com on 30 Mar 2013 at 12:18