C++ LNK2019尝试使用tmxlite编译项目时出错
我不断地发现这些错误: LNK2019函数“bool\uuu cdecl tmx::decompress(char const*,class std::vector&,int,int)”中引用的未解析外部符号\u mz\u inflateInit(?decompress@tmx@@你呢$vector@EV?$allocator@E@std@@@std@@hh@Z) LNK2019未解析外部符号_mz_在函数“bool u cdecl tmx::decompress(char const*,class std::vector>&,int,int)”中引用膨胀(?decompress@tmx@@你呢$vector@EV?$allocator@E@std@@@std@@HH@Z) LNK2019函数“bool\uuu cdecl tmx::decompress(char const*,class std::vector>&,int,int)”中引用的未解析外部符号_mz_inflateEnd(?decompress@tmx@@你呢$vector@EV?$allocator@E@std@@@std@@HH@Z) 当我试图编译我的tmxlite项目时。我的项目中仅有的源代码文件是tmxlite附带的C++ LNK2019尝试使用tmxlite编译项目时出错,c++,tiled,tmx,C++,Tiled,Tmx,我不断地发现这些错误: LNK2019函数“bool\uuu cdecl tmx::decompress(char const*,class std::vector&,int,int)”中引用的未解析外部符号\u mz\u inflateInit(?decompress@tmx@@你呢$vector@EV?$allocator@E@std@@@std@@hh@Z) LNK2019未解析外部符号_mz_在函数“bool u cdecl tmx::decompress(char const*,cla
#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;
}
#包括“stdafx.h”
#包括
#包括
#包括
#包括
#包括“C:\ProgramFiles(x86)\tmxlite\SFMLExample\src\SFMLOrthogonalLayer.hpp”
#包括“FreeFuncs.cpp”
#包括“ImageLayer.cpp”
#包括“Map.cpp”
#包括“miniz.c”
#包括“Object.cpp”
#包括“ObjectGroup.cpp”
#包括“Property.cpp”
#包括“tillelayer.cpp”
#包括“Tileset.cpp”
#包括“pugixml.cpp”
使用名称空间sf;
int main()
{
RenderWindow窗口(视频模式(800600),“SFML窗口”);
tmx::Map;
map.load(“assets/demo.tmx”);
地图图层0(地图,0);
地图图层(地图,1);
地图图层wo(地图,2);
while(window.isOpen())
{
事件;
while(window.pollEvent(事件))
{
if(event.type==event::Closed)
window.close();
}
窗口。透明(颜色:黑色);
窗口。绘制(图层零);
窗口绘制(layerOne);
窗口绘制(第二层);
window.display();
}
返回0;
}
我正在使用Visual Studio Community 2017将现有的
src/tmxlite/miniz.*
文件添加到项目中。仅在项目中包含Map.*
是不够的,您应该将所有源文件添加到项目中
更好的方法是将现有项目tmxlite.vcxproj
添加到解决方案中,并将此项目添加到项目的依赖项中
不要使用
#include
指令将.cpp文件包含到源中。将它们添加到您的项目树中。您包括哪些cpp文件?很抱歉,我应该在这里的代码中包含这些文件。我已经包括了miniz.h。我仍然会遇到同样的错误。没有#包括。在项目视图中右键单击您的项目,并将现有火添加到项目中,包括.h和.c文件。从源代码中删除.cpp的所有#include
。因此右键单击我的项目并添加src(而不是CMakeLists)和src/detail中的所有文件?我需要.hpp文件还是只需要.cpp文件?头文件和源文件。别忘了也添加.c文件。我不知道问题出在哪里,但它不起作用。现在它给了我数百个错误。