freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ft-devel] impossble trouble installing free type on Vis C++


From: mikau16
Subject: [ft-devel] impossble trouble installing free type on Vis C++
Date: Tue, 8 Jul 2008 15:45:57 -0700 (PDT)

I seem entirely incapable of successfully installing freetype 2 on my system.
I'm currently trying to install it on my Visual C++ 9.0 Express Edition
compiler. There was a very clear and straight forward walk-through here:
http://libagar.org/docs/compile-msvc.html.en for how to do it using two
different methods. I've tried both, and I've also tried installing it on
other compilers. 

After installing, i try to compile and link this program, which I obtained
here: http://www.freetype.org/freetype2/docs/tutorial/step1.html

here is the complete program:


// freetypebin.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <ft2build.h>
#include FT_FREETYPE_H

#include <stdio.h>
#include <string.h>
#include <math.h>





#define WIDTH   640
#define HEIGHT  480


/* origin is the upper left corner */
unsigned char image[HEIGHT][WIDTH];


/* Replace this function with something useful. */

void
draw_bitmap( FT_Bitmap*  bitmap,
             FT_Int      x,
             FT_Int      y)
{
  FT_Int  i, j, p, q;
  FT_Int  x_max = x + bitmap->width;
  FT_Int  y_max = y + bitmap->rows;


  for ( i = x, p = 0; i < x_max; i++, p++ )
  {
    for ( j = y, q = 0; j < y_max; j++, q++ )
    {
      if ( i < 0      || j < 0       ||
           i >= WIDTH || j >= HEIGHT )
        continue;

      image[j][i] |= bitmap->buffer[q * bitmap->width + p];
    }
  }
}


void
show_image( void )
{
  int  i, j;


  for ( i = 0; i < HEIGHT; i++ )
  {
    for ( j = 0; j < WIDTH; j++ )
      putchar( image[i][j] == 0 ? ' '
                                : image[i][j] < 128 ? '+'
                                                    : '*' );
    putchar( '\n' );
  }
}


int
main( int     argc,
      char**  argv )
{
  FT_Library    library;
  FT_Face       face;

  FT_GlyphSlot  slot;
  FT_Matrix     matrix;                 /* transformation matrix */
  FT_Vector     pen;                    /* untransformed origin  */
  FT_Error      error;

  char*         filename;
  char*         text;

  double        angle;
  int           target_height;
  int           n, num_chars;


  if ( argc != 3 )
  {
    fprintf ( stderr, "usage: %s font sample-text\n", argv[0] );
    exit( 1 );
  }

  filename      = argv[1];                           /* first argument    
*/
  text          = argv[2];                           /* second argument   
*/
  num_chars     = strlen( text );
  angle         = ( 25.0 / 360 ) * 3.14159 * 2;      /* use 25 degrees    
*/
  target_height = HEIGHT;

  error = FT_Init_FreeType( &library );              /* initialize library
*/
  /* error handling omitted */

  error = FT_New_Face( library, argv[1], 0, &face ); /* create face object
*/
  /* error handling omitted */

  /* use 50pt at 100dpi */
  error = FT_Set_Char_Size( face, 50 * 64, 0,
                            100, 0 );                /* set character size
*/
  /* error handling omitted */

  slot = face->glyph;

  /* set up matrix */
  matrix.xx = (FT_Fixed)( cos( angle ) * 0x10000L );
  matrix.xy = (FT_Fixed)(-sin( angle ) * 0x10000L );
  matrix.yx = (FT_Fixed)( sin( angle ) * 0x10000L );
  matrix.yy = (FT_Fixed)( cos( angle ) * 0x10000L );

  /* the pen position in 26.6 cartesian space coordinates; */
  /* start at (300,200) relative to the upper left corner  */
  pen.x = 300 * 64;
  pen.y = ( target_height - 200 ) * 64;

  for ( n = 0; n < num_chars; n++ )
  {
    /* set transformation */
    FT_Set_Transform( face, &matrix, &pen );

    /* load glyph image into the slot (erase previous one) */
    error = FT_Load_Char( face, text[n], FT_LOAD_RENDER );
    if ( error )
      continue;                 /* ignore errors */

    /* now, draw to our target surface (convert position) */
    draw_bitmap( &slot->bitmap,
                 slot->bitmap_left,
                 target_height - slot->bitmap_top );

    /* increment pen position */
    pen.x += slot->advance.x;
    pen.y += slot->advance.y;
  }

  show_image();

  FT_Done_Face    ( face );
  FT_Done_FreeType( library );

  return 0;
}


Linking always fails. Here's the message I get in return:


------ Build started: Project: freetypebin, Configuration: Debug Win32
------
Linking...
freetypebin.obj : error LNK2019: unresolved external symbol
_FT_Done_FreeType referenced in function _main
freetypebin.obj : error LNK2019: unresolved external symbol _FT_Done_Face
referenced in function _main
freetypebin.obj : error LNK2019: unresolved external symbol _FT_Load_Char
referenced in function _main
freetypebin.obj : error LNK2019: unresolved external symbol
_FT_Set_Transform referenced in function _main
freetypebin.obj : error LNK2019: unresolved external symbol
_FT_Set_Char_Size referenced in function _main
freetypebin.obj : error LNK2019: unresolved external symbol _FT_New_Face
referenced in function _main
freetypebin.obj : error LNK2019: unresolved external symbol
_FT_Init_FreeType referenced in function _main
C:\Documents and Settings\Rav\My Documents\Visual Studio
2008\Projects\freetypebin\Debug\freetypebin.exe : fatal error LNK1120: 7
unresolved externals
Build log was saved at "file://c:\Documents and Settings\Rav\My
Documents\Visual Studio
2008\Projects\freetypebin\freetypebin\Debug\BuildLog.htm"
freetypebin - 8 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


I've been wanting to install freetype for use with Font drawing in OpenGL,
which i'm presently learning, but I've spent weeks trying to get it to work,
without success. 

and yes, I've included the path to the library file in my project settings
and all that.
-- 
View this message in context: 
http://www.nabble.com/impossble-trouble-installing-free-type-on-Vis-C%2B%2B-tp18350705p18350705.html
Sent from the Freetype - Dev mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]