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

Author Topic: linking c++ and sfml  (Read 28250 times)

0 Members and 1 Guest are viewing this topic.

LegoMan4

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
linking c++ and sfml
« on: August 25, 2013, 05:05:02 pm »
Hello, i am new member of forum.I am using Visual studio 2010 and sfml 2.1, on windows 7 64 bit.

I followed this tutorial for linking Visual studio and sfml : http://www.sfml-dev.org/tutorials/2.0/start-vc.php

Then when i did it i tried: this program (it is in tutorial) :
Quote
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}




and i got this error:

(ja is projects name) [ja means me in croatian the more you know

Quote
1>------ Build started: Project: ja, Configuration: Debug Win32 ------
1>Build started 25.8.2013. 16:39:04.
1>InitializeBuildStatus:
1>  Touching "Debug\ja.unsuccessfulbuild".
1>ClCompile:
1>  All outputs are up-to-date.
1>ManifestResourceCompile:
1>  All outputs are up-to-date.
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::RenderWindow::~RenderWindow(void)" (__imp_??1RenderWindow@sf@@UAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::CircleShape::~CircleShape(void)" (__imp_??1CircleShape@sf@@UAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::display(void)" (__imp_?display@Window@sf@@QAEXXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::RenderTarget::draw(class sf::Drawable const &,class sf::RenderStates const &)" (__imp_?draw@RenderTarget@sf@@QAEXABVDrawable@2@ABVRenderStates@2@@Z) referenced in function _main
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class sf::RenderStates const sf::RenderStates::Default" (__imp_?Default@RenderStates@sf@@2V12@B)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::RenderTarget::clear(class sf::Color const &)" (__imp_?clear@RenderTarget@sf@@QAEXABVColor@2@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Color::Color(unsigned char,unsigned char,unsigned char,unsigned char)" (__imp_??0Color@sf@@QAE@EEEE@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::close(void)" (__imp_?close@Window@sf@@QAEXXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::pollEvent(class sf::Event &)" (__imp_?pollEvent@Window@sf@@QAE_NAAVEvent@2@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::isOpen(void)const " (__imp_?isOpen@Window@sf@@QBE_NXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Shape::setFillColor(class sf::Color const &)" (__imp_?setFillColor@Shape@sf@@QAEXABVColor@2@@Z) referenced in function _main
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class sf::Color const sf::Color::Green" (__imp_?Green@Color@sf@@2V12@B)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::CircleShape::CircleShape(float,unsigned int)" (__imp_??0CircleShape@sf@@QAE@MI@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::~String(void)" (__imp_??1String@sf@@QAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::RenderWindow::RenderWindow(class sf::VideoMode,class sf::String const &,unsigned int,struct sf::ContextSettings const &)" (__imp_??0RenderWindow@sf@@QAE@VVideoMode@1@ABVString@1@IABUContextSettings@1@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (__imp_??0VideoMode@sf@@QAE@III@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::String(char const *,class std::locale const &)" (__imp_??0String@sf@@QAE@PBDABVlocale@std@@@Z) referenced in function _main
1>c:\users\marn\documents\visual studio 2010\Projects\ja\Debug\ja.exe : fatal error LNK1120: 17 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.12
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

a few pics:











this happens when i change configuration to anything exept release


thanks for helping
« Last Edit: August 25, 2013, 05:51:15 pm by LegoMan4 »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: problem
« Reply #1 on: August 25, 2013, 05:11:34 pm »
Aren't additional dependencies supposed to be separated by ';'? And it's sfml-graphics, not sfml-graphic.

And please edit the title of your post to something more precise; everything here is a "problem".
Laurent Gomila - SFML developer

LegoMan4

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Re: problem
« Reply #2 on: August 25, 2013, 06:03:39 pm »
fixed all, but still get errors ( i fixed ";" only in linker-->input)

Quote
1>------ Build started: Project: ja, Configuration: Debug Win32 ------
1>Build started 25.8.2013. 17:58:30.
1>InitializeBuildStatus:
1>  Touching "Debug\ja.unsuccessfulbuild".
1>ClCompile:
1>  All outputs are up-to-date.
1>ManifestResourceCompile:
1>  All outputs are up-to-date.
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::RenderWindow::~RenderWindow(void)" (__imp_??1RenderWindow@sf@@UAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::CircleShape::~CircleShape(void)" (__imp_??1CircleShape@sf@@UAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::display(void)" (__imp_?display@Window@sf@@QAEXXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::RenderTarget::draw(class sf::Drawable const &,class sf::RenderStates const &)" (__imp_?draw@RenderTarget@sf@@QAEXABVDrawable@2@ABVRenderStates@2@@Z) referenced in function _main
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class sf::RenderStates const sf::RenderStates::Default" (__imp_?Default@RenderStates@sf@@2V12@B)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::RenderTarget::clear(class sf::Color const &)" (__imp_?clear@RenderTarget@sf@@QAEXABVColor@2@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Color::Color(unsigned char,unsigned char,unsigned char,unsigned char)" (__imp_??0Color@sf@@QAE@EEEE@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::close(void)" (__imp_?close@Window@sf@@QAEXXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::pollEvent(class sf::Event &)" (__imp_?pollEvent@Window@sf@@QAE_NAAVEvent@2@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::isOpen(void)const " (__imp_?isOpen@Window@sf@@QBE_NXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Shape::setFillColor(class sf::Color const &)" (__imp_?setFillColor@Shape@sf@@QAEXABVColor@2@@Z) referenced in function _main
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class sf::Color const sf::Color::Green" (__imp_?Green@Color@sf@@2V12@B)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::CircleShape::CircleShape(float,unsigned int)" (__imp_??0CircleShape@sf@@QAE@MI@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::~String(void)" (__imp_??1String@sf@@QAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::RenderWindow::RenderWindow(class sf::VideoMode,class sf::String const &,unsigned int,struct sf::ContextSettings const &)" (__imp_??0RenderWindow@sf@@QAE@VVideoMode@1@ABVString@1@IABUContextSettings@1@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (__imp_??0VideoMode@sf@@QAE@III@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::String(char const *,class std::locale const &)" (__imp_??0String@sf@@QAE@PBDABVlocale@std@@@Z) referenced in function _main
1>C:\Users\Marn\Documents\Visual Studio 2010\Projects\ja\Debug\ja.exe : fatal error LNK1120: 17 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.22
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: linking c++ and sfml
« Reply #3 on: August 25, 2013, 07:33:36 pm »
Did you set the Additional Dependencies for Debug mode as well as Release mode? Your previous screenshots only show them under Release.

By the way, I don't think there is an "SFML_DYNAMIC" macro.  You just leave out "SFML_STATIC" to do dynamic linking.
« Last Edit: August 25, 2013, 07:42:41 pm by Ixrec »

LegoMan4

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Re: linking c++ and sfml
« Reply #4 on: August 25, 2013, 08:58:36 pm »
changes:





Quote
1>------ Build started: Project: ja, Configuration: Debug Win32 ------
1>Build started 25.8.2013. 20:28:56.
1>InitializeBuildStatus:
1>  Touching "Debug\ja.unsuccessfulbuild".
1>ClCompile:
1>  All outputs are up-to-date.
1>  main.cpp
1>ManifestResourceCompile:
1>  All outputs are up-to-date.
1>main.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall sf::RenderWindow::~RenderWindow(void)" (??1RenderWindow@sf@@UAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Window::display(void)" (?display@Window@sf@@QAEXXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::RenderTarget::draw(class sf::Drawable const &,class sf::RenderStates const &)" (?draw@RenderTarget@sf@@QAEXABVDrawable@2@ABVRenderStates@2@@Z) referenced in function _main
1>main.obj : error LNK2001: unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B)
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::RenderTarget::clear(class sf::Color const &)" (?clear@RenderTarget@sf@@QAEXABVColor@2@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::Color::Color(unsigned char,unsigned char,unsigned char,unsigned char)" (??0Color@sf@@QAE@EEEE@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Window::close(void)" (?close@Window@sf@@QAEXXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: bool __thiscall sf::Window::pollEvent(class sf::Event &)" (?pollEvent@Window@sf@@QAE_NAAVEvent@2@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: bool __thiscall sf::Window::isOpen(void)const " (?isOpen@Window@sf@@QBE_NXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Shape::setFillColor(class sf::Color const &)" (?setFillColor@Shape@sf@@QAEXABVColor@2@@Z) referenced in function _main
1>main.obj : error LNK2001: unresolved external symbol "public: static class sf::Color const sf::Color::Green" (?Green@Color@sf@@2V12@B)
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::CircleShape::CircleShape(float,unsigned int)" (??0CircleShape@sf@@QAE@MI@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::RenderWindow::RenderWindow(class sf::VideoMode,class sf::String const &,unsigned int,struct sf::ContextSettings const &)" (??0RenderWindow@sf@@QAE@VVideoMode@1@ABVString@1@IABUContextSettings@1@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (??0VideoMode@sf@@QAE@III@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::String::String(char const *,class std::locale const &)" (??0String@sf@@QAE@PBDABVlocale@std@@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall sf::Shape::~Shape(void)" (??1Shape@sf@@UAE@XZ) referenced in function "public: virtual __thiscall sf::CircleShape::~CircleShape(void)" (??1CircleShape@sf@@UAE@XZ)
1>C:\Users\Marn\Documents\Visual Studio 2010\Projects\ja\Debug\ja.exe : fatal error LNK1120: 16 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:04.35
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

:((

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: linking c++ and sfml
« Reply #5 on: August 25, 2013, 09:01:07 pm »
If you want static debug libraries, you want eg sfml-graphics-s-d, not just sfml-graphics (or sfml-graphics-d for dynamic debug).  And why put the SFML_STATIC macro in?  Did you want static all along?

Please read the tutorial a lot more carefully.  It's very explicit about these things.

LegoMan4

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Re: linking c++ and sfml
« Reply #6 on: August 25, 2013, 09:51:00 pm »
thanks a milion  :D :D but now it says error is because i have x64 bit pc and targeted machine type is x86:

Quote
1>------ Build started: Project: ja, Configuration: Debug Win32 ------
1>Build started 25.8.2013. 21:43:19.
1>InitializeBuildStatus:
1>  Touching "Debug\ja.unsuccessfulbuild".
1>ClCompile:
1>  All outputs are up-to-date.
1>ManifestResourceCompile:
1>  All outputs are up-to-date.
1>sfml-graphics-s-d.lib(RenderStates.cpp.obj) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.75
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Gobbles

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: linking c++ and sfml
« Reply #7 on: August 25, 2013, 09:56:07 pm »
Which version of the library did you download?

LegoMan4

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Re: linking c++ and sfml
« Reply #8 on: August 25, 2013, 10:03:42 pm »
64-bit

Gobbles

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: linking c++ and sfml
« Reply #9 on: August 25, 2013, 10:06:49 pm »
Your trying to build a 32 bit application using a 64 bit library.

LegoMan4

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Re: linking c++ and sfml
« Reply #10 on: August 25, 2013, 10:12:54 pm »
it works :D :D :D :D thank you sooooooo much