Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: I whant to open a ttf file from a directory ...  (Read 4583 times)

0 Members and 3 Guests are viewing this topic.

dkaip

  • Newbie
  • *
  • Posts: 32
    • View Profile
I whant to open a ttf file from a directory ...
« on: January 30, 2010, 10:11:35 am »
Hello. I whant to open a ttf file from a directory and represent same chars.
First i must load ttf file. But compiler(win xp, codeblocks, gcc) says ...

What i wrong?
Thank's
Jim


obj\Debug\main.o||In function `main':|
C:\TMP\14\main.cpp|31|undefined reference to `__imp___ZN2sf4FontC1Ev'|
obj\Debug\main.o||In function `_ZNSt8_Rb_treeIPN2sf11ResourcePtrINS0_4FontEEES4_St9_IdentityIS4_ESt4lessIS4_ESaIS4_EE11_M_put_nodeEPSt13_Rb_tree_nodeIS4_E':|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\stl_construct.h:(.text$_ZN2sf4FontD1Ev[sf::Font::~Font()]+0x6d)||undefined reference to `__imp___ZN2sf5ImageD1Ev'|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\stl_construct.h:(.text$_ZN2sf4FontD1Ev[sf::Font::~Font()]+0x8c)||undefined reference to `__imp___ZN2sf5ImageD1Ev'|
||=== Build finished: 3 errors, 0 warnings ===|
 

Code: [Select]
#include <SFML/System.hpp>
#include <SFML/graphics.hpp>
#include <iostream>
#include <fstream>

//return a std::string copy (not reference) and pass a const-reference
std::string OpenFile( const std::string& filename )
{
    std::ifstream file(filename.c_str(), std::ios::binary | std::ios::ate );
    file.seekg( 0, std::ios::end );
    int length; // initialize length
    length = file.tellg( );
    file.seekg( 0, std::ios::beg );
    char* buffer = new char[ length ];
    file.read( buffer, length );
    file.close( );
    std::string encrypted = buffer;
    delete buffer;
    return encrypted;
}


int main()
{
    sf::Font font;
    std::string file = OpenFile( "myl.ttf" );
    font.LoadFromMemory( file.c_str( ), file.length( ) );


   return 0;
}
[/code]

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
I whant to open a ttf file from a directory ...
« Reply #1 on: January 30, 2010, 12:43:10 pm »
Did you link to libsfml-graphics.a?
Laurent Gomila - SFML developer

dkaip

  • Newbie
  • *
  • Posts: 32
    • View Profile
No
« Reply #2 on: January 30, 2010, 12:57:05 pm »
How, i will do that? Any tutorial about those things?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
I whant to open a ttf file from a directory ...
« Reply #3 on: January 30, 2010, 01:00:57 pm »
Well, if you use a library you're supposed to know (or learn) how to do it, this has to do with your EDI/compiler, not with SFML :)

But anyway it is explained in the SFML tutorials, just have a look at the "getting started" tutorial for Code::Blocks.
Laurent Gomila - SFML developer

dkaip

  • Newbie
  • *
  • Posts: 32
    • View Profile
Ok
« Reply #4 on: January 30, 2010, 01:06:24 pm »
Thank's, i will loo at CB. Have a good day.
Jim

dkaip

  • Newbie
  • *
  • Posts: 32
    • View Profile
I whant to open a ttf file from a directory ...
« Reply #5 on: January 30, 2010, 09:41:35 pm »
In main graphics start up program with codeblocks in build options, in other linker options must put -lsfml-system and in search directories>linker must take the C:\SFML-1.5\lib\mingw directory, and in the compiler stettings>#defines must put SFML_DYNAMIC.
In the program directory must put the sfml-system.dll file to work the program.
-------------------------------------
Now i have the graphics.hpp and i dont know what settings must i do.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
I whant to open a ttf file from a directory ...
« Reply #6 on: January 30, 2010, 10:52:24 pm »
Take everything that involves sfml-system, and replace "system" with "graphics" ;)
Laurent Gomila - SFML developer

dkaip

  • Newbie
  • *
  • Posts: 32
    • View Profile
I whant to open a ttf file from a directory ...
« Reply #7 on: January 31, 2010, 07:02:12 pm »
I did that. So in build>debug>linker settings  i take -lsfml-graphics but nothing. Also i put sfml-graphics.dll and sfml-graphics-d.dll files in prograsm folder, but program breaks. What next?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
I whant to open a ttf file from a directory ...
« Reply #8 on: January 31, 2010, 07:13:16 pm »
Did you define SFML_DYNAMIC?
Laurent Gomila - SFML developer

dkaip

  • Newbie
  • *
  • Posts: 32
    • View Profile
I whant to open a ttf file from a directory ...
« Reply #9 on: January 31, 2010, 09:42:13 pm »
Yes and without ...

Code: [Select]
   sf::Font font;
    std::string file = OpenFile( "Arial.ttf" );
    font.LoadFromMemory( file.c_str( ), file.length( ) );


works fine...
Now what i must put?
If helps i can send the hole project.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
I whant to open a ttf file from a directory ...
« Reply #10 on: January 31, 2010, 10:54:35 pm »
Quote
If helps i can send the hole project.

Yep, that's a good idea :)
Laurent Gomila - SFML developer

 

anything