1
Graphics / undefined reference to sf::Font::loadFromFile
« on: December 04, 2016, 12:17:13 pm »
code
build log
||=== Build: Debug in test (compiler: GNU GCC Compiler) ===|
E:\Documents and Settings\CodeBlocks Projects\test\main.cpp||In function 'int main()':|
E:\Documents and Settings\CodeBlocks Projects\test\main.cpp|28|warning: suggest parentheses around assignment used as truth value [-Wparentheses]|
E:\SFML-2.4.1\lib\libsfml-graphics-s.a(Text.cpp.obj)||duplicate section `.rdata$_ZTVN2sf8DrawableE[__ZTVN2sf8DrawableE]' has different size|
E:\SFML-2.4.1\lib\libsfml-graphics-s.a(Shape.cpp.obj)||duplicate section `.rdata$_ZTVN2sf8DrawableE[__ZTVN2sf8DrawableE]' has different size|
obj\Debug\main.o:main.cpp|| undefined reference to `sf::Font::loadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
||error: ld returned 1 exit status|
||=== Build failed: 2 error(s), 3 warning(s) (0 minute(s), 26 second(s)) ===|
(click to show/hide)
#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
sf::RenderWindow window(sf::VideoMode(800,600),"My Window");
sf::CircleShape circle(100.0f);
circle.setFillColor(sf::Color::Green);
circle.setPosition(400.0f,300.0f);
sf::Font font;
font.loadFromFile("arial.ttf");
sf::Text text;
text.setFont(font);
text.setString("Hello");
text.setCharacterSize(24);
text.setPosition(100.0f,100.0f);
while(window.isOpen())
{
sf::Event event;
while(window.pollEvent(event))
{
if(event.type = sf::Event::Closed)
{
window.close();
}
window.clear(sf::Color::White);
window.draw(circle);
window.draw(text);
window.display();
}
}
return 0;
}
#include <iostream>
int main()
{
sf::RenderWindow window(sf::VideoMode(800,600),"My Window");
sf::CircleShape circle(100.0f);
circle.setFillColor(sf::Color::Green);
circle.setPosition(400.0f,300.0f);
sf::Font font;
font.loadFromFile("arial.ttf");
sf::Text text;
text.setFont(font);
text.setString("Hello");
text.setCharacterSize(24);
text.setPosition(100.0f,100.0f);
while(window.isOpen())
{
sf::Event event;
while(window.pollEvent(event))
{
if(event.type = sf::Event::Closed)
{
window.close();
}
window.clear(sf::Color::White);
window.draw(circle);
window.draw(text);
window.display();
}
}
return 0;
}
(click to show/hide)
||=== Build: Debug in test (compiler: GNU GCC Compiler) ===|
E:\Documents and Settings\CodeBlocks Projects\test\main.cpp||In function 'int main()':|
E:\Documents and Settings\CodeBlocks Projects\test\main.cpp|28|warning: suggest parentheses around assignment used as truth value [-Wparentheses]|
E:\SFML-2.4.1\lib\libsfml-graphics-s.a(Text.cpp.obj)||duplicate section `.rdata$_ZTVN2sf8DrawableE[__ZTVN2sf8DrawableE]' has different size|
E:\SFML-2.4.1\lib\libsfml-graphics-s.a(Shape.cpp.obj)||duplicate section `.rdata$_ZTVN2sf8DrawableE[__ZTVN2sf8DrawableE]' has different size|
obj\Debug\main.o:main.cpp|| undefined reference to `sf::Font::loadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
||error: ld returned 1 exit status|
||=== Build failed: 2 error(s), 3 warning(s) (0 minute(s), 26 second(s)) ===|