Achilles-96 / freetype-gl

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

Build fails on Windows 7 using Visual Studio 2010 and CMake 2.8.8 #20

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When trying to build the latest revision on Windows 7 Professional (64bit, if 
this is important) using Visual Studio 2010 (Professional) and CMake 2.8.8 I 
encounter several errors. Both 32bit and 64bit builds fail.

1. Using a clean svn-update, CMake will initially fail:

Check for working C compiler using: Visual Studio 10
Check for working C compiler using: Visual Studio 10 -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler using: Visual Studio 10
Check for working CXX compiler using: Visual Studio 10 -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Found OpenGL: opengl32  
NOT FOUND: Libstdc++ is not installed. It is needed by demo-atb-agg.c
Configuring done

This is interesting, as the libstdc++-check should be disabled. However, this 
can be "solved" by commenting out the other lines concerning demo-atb-agg.c

2. After working around issue 1., the following output is produced by CMake:

Check for working C compiler using: Visual Studio 10
Check for working C compiler using: Visual Studio 10 -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler using: Visual Studio 10
Check for working CXX compiler using: Visual Studio 10 -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Found OpenGL: opengl32  
Configuring done
Generating done

When loading the generated project files, building the freetype-gl lib will 
fail (loading "Project.sln"). Error messages:

c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error 
C2054: expected '(' to follow 'WINGDIAPI'
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error 
C2085: 'APIENTRY' : not in formal parameter list

According to 
http://www.opengl.org/archives/resources/faq/technical/gettingstarted.htm this 
is caused by not including <windows.h> before <gl.h>. By following this tip (by 
modifying texture-atlas.c and , the second issue can be eliminated.

3. After solving the first two problems, the C-compiler floods the console with 
syntax errors. Apparently he doesn't like the following line from 
texture-atlas.c

texture_atlas_t *self = (texture_atlas_t *) malloc( sizeof(texture_atlas_t) );

Error code: error C2143: syntax error: missing ';' before 'type'

A quick Google search told me that Visual Studio's C compiler hates it when you 
declare and define a variable in the same line. So I changed the project 
settings to "Compile as C++".

4. After massively reducing the errors, I noticed that the include directory 
for freetype is not set by default. After pointing to the directory included in 
the latest revision, this error disappeared.

5. After solving the errors above, I encountered an error I cannot solve yet. 
For some reason, Visual C++ doesn't know several (most) of the OpenGL-functions 
used, despite <GL/gl.h> being correctly included. Oddly it does know some of 
them.

Example:

glDeleteBuffers is unknown.
glDrawElements is known.

Original issue reported on code.google.com by denga...@gmail.com on 1 May 2012 at 1:52

GoogleCodeExporter commented 8 years ago
Sorry for the long delay and thanks a lot for the detailed report.

glDeleteBuffers is available only if the GL version is 1.5 or greater. Do you 
know what is your GL version ? If it is high enough, this might be a problem 
with the GL headers. You might to test with the GLEW library (pretty standard) 
and report if it works (don't forget to call glewInit at some point).

Original comment by Nicolas.Rougier@gmail.com on 23 May 2012 at 5:45

GoogleCodeExporter commented 8 years ago
For Visual Studio support, the project really needs to be converted to either 
C90 or C++, as C99 isn't supported.  I, too, am in the process of translating 
the project for use in my project.  I am using GLEW and have no GL-related 
errors.

Original comment by acr...@gmail.com on 24 May 2012 at 3:45

GoogleCodeExporter commented 8 years ago

Is there a way to "trick" CMake in using c++ instead of c on Windows ?

Original comment by Nicolas.Rougier@gmail.com on 24 May 2012 at 7:37

GoogleCodeExporter commented 8 years ago
The /TP compiler option forces the compiler to compile everything as C++.

Original comment by acr...@gmail.com on 24 May 2012 at 9:42

GoogleCodeExporter commented 8 years ago
Is the problem fixed with the current version ?

Original comment by Nicolas.Rougier@gmail.com on 19 Jul 2012 at 8:54

GoogleCodeExporter commented 8 years ago

Original comment by Nicolas.Rougier@gmail.com on 17 Sep 2012 at 7:18

GoogleCodeExporter commented 8 years ago
I've been hitting the library earned Windows.
In the Visual Studio project properties specify that compile the C++ source. In 
Borland Studio I had to rename extension file c to cpp.
Change platform.h,platform.c - rename proc round(float v) to proc round2(float 
v);
Change vertex-attribute.h,vertex-attribute.c -rename GLenum GL_TYPE( char ctype 
) to GLenum GL_TYPE2( char ctype );

opengl.h:
    #include <Windows.h>
    #include <GL/glew.h> //download this library from inet
    #include <GL/wglew.h>
    #include <GLUT/glut.h> // changed according to your path of glut.h 

and in demo add initialization glew:
int main( int argc, char **argv )
{
    GLenum glew_status = glewInit();
    if (GLEW_OK != glew_status)
    {
     printf("Error_my: %s",glewGetErrorString(glew_status));
     return;
    }

    if (!GLEW_VERSION_2_0)
    {
     printf("No support for OpenGL 2.0 found");
     return;
    }

Original comment by vadim1...@gmail.com on 3 Oct 2012 at 9:37