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

Author Topic: MSVC++ 2010 fatal error LNK1112: module machine type 'x64' conflicts with target  (Read 24082 times)

0 Members and 1 Guest are viewing this topic.

Betaserver

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Hello. I'm trying to install SFML 2.0 for Microsoft Visual C++ 2010. Whenever I try to build some sample code to test whether SFML has been installed properly, I get this error:
fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

 I have looked at many other online resources, but they were either too vague or didn't work. I guess here is the sample code if you want it.

#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;
}

I am running Wndows 7 Professional, 64-Bit

Thanks for reading this  :D If you need more info to debug let me know.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10800
    • View Profile
    • development blog
    • Email
Not sure where you searched, but the error is quite clear: You're trying to link x64 libraries with your x86 compiler, which just doesn't work.
Which SFML package did you download? Did you make sure to switch the compiler of VS to x64?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Betaserver

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
I downloaded SFML for Visual C++ 10 (2010) - 64 bits. I found it on http://www.sfml-dev.org/download/sfml/2.0/. It is the first one down from the top right. And thanks for the fast reply!

Betaserver

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
I am very new to MSVC++, so I do not know how to change my compiler to x64. Could you show me or link me? Thanks

Sqasher

  • Newbie
  • *
  • Posts: 19
    • View Profile
Just google:

http://msdn.microsoft.com/...

Note that the 64-bit tools are not available on the Express versions by default.

Betaserver

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
I can't find the Build menu... am I an idiot? Where is it located?

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
I don't see any mention of the Build menu on that page so I'm not sure it matters.

Also, are you using Express?  If you are and you can't compile for x64 anyway then you should just go download the x86 binaries instead.  Most x86 programs run fine on x64 so it's not that important.

Betaserver

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Well, I switched my target machine to x86 and downloaded and set up the 32-bit version of SFML 2.0. Now, it gives me this error.
1>------ Build started: Project: SFML, Configuration: Debug Win32 ------
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::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: __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::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\Cameron\documents\visual studio 2010\Projects\SFML\Debug\SFML.exe : fatal error LNK1120: 7 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
 

I think I'm making progress. Anyone have any solutions?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10800
    • View Profile
    • development blog
    • Email
Did you read the official tutorial? If not, you really should!

The error above means that you're not linking against the needed libraries (Window & System).
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Betaserver

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Yes, that was my first step. I did skip the C/c++ -> Preprocessor stuff, as I thought that was optional.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Don't "think," read the tutorial carefully.  The preprocessor part is mandatory for static linking and doesn't apply to dynamic linking.

Betaserver

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
I followed the Preprocessor, and it didn't change anything. And the error was my fault partially. I had only put sfml-graphics.lib in the Additional Dependencies. (I think that was my problem.) Now when I put in sfml-window-s-d.lib sfml-system-s-d.lib sfml-network-s-d.lib sfml-audio-s-d.lib, it gives me this error:
fatal error LNK1104: cannot open file 'sfml-window-s-d.lib sfml-system-s-d.lib sfml-network-s-d.lib sfml-audio-s-d.lib'
I'm very confused at this point  :-\

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10800
    • View Profile
    • development blog
    • Email
"cannot open file" = File doesn't exist

Make sure you point to the right directory where the files are actually placed.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Betaserver

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
I very much doubt that. I forgot to mention it in the last post, but when I just have sfml-graphics.lib for example, it gives me the earlier error. I think that it is looking for a file named sfml-graphics-s-d.lib sfml-system-s-d.lib etc. instead of looking for multiple files. Is there a way I should separate each one?

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
You're actually completely right.  You have to use ; instead of spaces to separate the filenames.