Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LNK 2019 error unresolved external symbol #30

Closed
andrewr1991 opened this issue Feb 4, 2018 · 6 comments
Closed

LNK 2019 error unresolved external symbol #30

andrewr1991 opened this issue Feb 4, 2018 · 6 comments

Comments

@andrewr1991
Copy link

andrewr1991 commented Feb 4, 2018

I am trying to use tmxlite for the first time and I keep getting this error:

LNK2019 unresolved external symbol _mz_inflateInit referenced in function "bool __cdecl tmx::decompress(char const *,class std::vector<unsigned char,class std::allocator > &,int,int)" (?decompress@tmx@@YA_NPBDAAV?$vector@EV?$allocator@E@std@@@std@@hh@Z)

I'm using Visual Studio 2017.

I am using the SFML example from the download:

#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Window/Event.hpp>

#include <tmxlite/Map.hpp>

#include "SFMLOrthogonalLayer.hpp"

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");

    tmx::Map map;
    map.load("assets/demo.tmx");

    MapLayer layerZero(map, 0);
    MapLayer layerOne(map, 1);
    MapLayer layerTwo(map, 2);

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

        window.clear(sf::Color::Black);
        window.draw(layerZero);
        window.draw(layerOne);
        window.draw(layerTwo);
        window.display();
    }

    return 0;
}

Can you explain a bit more in detail how to get it up and running with VS Community 2017?

@fallahn
Copy link
Owner

fallahn commented Feb 4, 2018

Assuming you haven't built the library already, open the sln file from the download and build each version you require (debug, release etc). Once you have the resulting .lib files follow the linking instructions here: #20

@andrewr1991
Copy link
Author

I opened the .sln file with visual studio and built the tmxlite project which is part of the tmxlite solution. It only created one .lib file though: 'libtmxlite-s.lib'. Do I need the other file, 'libtmxlite-s-d.lib', to use tmxlite for being able to parse my Tiled map?

@fallahn
Copy link
Owner

fallahn commented Feb 5, 2018

Typically, yes, you would use libtmxlite-s-d.lib in your debug build, although it's not strictly necessary. Use the configuration drop down at the top of visual studio to select 'debug' then rebuild tmxlite to get the debug version.

@andrewr1991
Copy link
Author

andrewr1991 commented Feb 7, 2018

So I was able to create the debug .lib file as in your previous instructions.

I followed the directions from your #20 link. I made the file path to the include folder "C:\Program Files (x86)\tmxlite\tmxlite\include". For the Linker->General->Additional Library Directories, when I built the tmxlite project, it only created 2 .lib files and each was in a separate folder. "libtmxlite-s.lib" in "C:\Program Files (x86)\tmxlite\tmxlite\bin\ReleaseStatic" and "libtmxlite-s-d.lib" in "C:\Program Files (x86)\tmxlite\tmxlite\bin\DebugStatic". So I chose the ReleaseStatic. And lastly, I chose libtmxlite-s.lib, for Linker->Input->Additional Dependencies.

I have attached a snapshot of what happens when I then try to build the SFML example code from the download. I'm sorry to be so much trouble but I really want to make this work.

tiledtestsnap

@fallahn
Copy link
Owner

fallahn commented Feb 7, 2018

OK, still a linker problem, this time it can't find the sfml libs. General rule of thumb with unresolved external errors is to look at the function name after _thiscall and find the library to which it belongs. In this case all the functions start with sf:: - so you just need to link sfml to your project in the same way as tmxlite. There are guides for visual studio on the sfml website.

@andrewr1991
Copy link
Author

Man I finally got it working. So my issue was that I was using the tmxlite static release library, not the debug library. And I also had to run the code in debug mode, not release. I knew something was weird because I had the exact same SFML settings with another project but I wasn't getting the linker errors.

Thank you for all of your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants