-1

I keep getting these errors:

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

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

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

when I try to compiler my tmxlite project. The only source code files I have in my project are the ones that came with tmxlite.

#include "stdafx.h"
#include <SFML/Graphics.hpp>

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

#include <tmxlite/Map.hpp> 

#include "C:\Program Files (x86)\tmxlite\SFMLExample\src\SFMLOrthogonalLayer.hpp"

#include "FreeFuncs.cpp"
#include "ImageLayer.cpp"
#include "Map.cpp"
#include "miniz.c"
#include "Object.cpp"
#include "ObjectGroup.cpp"
#include "Property.cpp"
#include "TileLayer.cpp"
#include "Tileset.cpp"
#include "pugixml.cpp"

using namespace sf;

int main()
{
        RenderWindow window(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())
        {
            Event event;
            while (window.pollEvent(event))
            {
                if (event.type == Event::Closed)
                    window.close();
            }

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

    return 0;
}

I'm using Visual Studio Community 2017

1 Answers1

0

Add existing src/tmxlite/miniz.* files into you project. Including Map.* only into your project is not enough, you should add all source files into the project.

The better way is if you add the existing project tmxlite.vcxproj into your solution and add this project into the dependencies of your project.

Do not include .cpp files into your sources using #include directive. Add them into your project tree.

273K
  • 29,503
  • 10
  • 41
  • 64
  • Sorry I should have included that with my code here. I have included miniz.h. I still get the same errors. – CheetahBongos Feb 04 '18 at 03:45
  • 1
    No `#include`. Right click on you project in the project view and add existing fires into the project, both .h and .c files. Remove all `#include` of .cpp from your source. – 273K Feb 04 '18 at 03:50
  • So right-click on my project and add all files from src (not the CMakeLists) and src/detail? Do I need the .hpp files or just the .cpp file? – CheetahBongos Feb 04 '18 at 04:13
  • Both header and source files. Do not forget to add .c files too. – 273K Feb 04 '18 at 04:20
  • I don't know what the problem is but it's not working. It gives me hundreds of errors now. – CheetahBongos Feb 04 '18 at 05:04
  • Is it because you did not remove `#include "FreeFuncs.cpp"` and other included .cpp fires? – 273K Feb 04 '18 at 08:12
  • No I removed those. According to another source, I need to build the library to get the .lib files first which I don't know how to do. It comes with a sln file but when I open that in VS and say 'build' it does nothing. – CheetahBongos Feb 04 '18 at 14:59