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 ===|
#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]