Giter Club home page Giter Club logo

Comments (10)

pedro-w avatar pedro-w commented on July 26, 2024

Are you debugging from within VS? Check the working directory (from memory it's Project Properties -> Debugging -> Working Directory) because your relative path resources/test.tmx will be found starting from there.

from tmxlite.

MCS09 avatar MCS09 commented on July 26, 2024

Are you debugging from within VS? Check the working directory (from memory it's Project Properties -> Debugging -> Working Directory) because your relative path resources/test.tmx will be found starting from there.

My issue isn't that the path can't be found (I tried opening the file with fstream just to check and it loads correctly), it's that at some point when I call the load() method, the path ends up being an empty string, so the error in the console doesn't print any path, unlike in the ParseTest project.

from tmxlite.

pedro-w avatar pedro-w commented on July 26, 2024

Sorry, I misunderstood what you meant by 'file path goes missing'. That is weird, on the face of it, it looks impossible *

bool Map::load(const std::string& path)
{
reset();
//open the doc
pugi::xml_document doc;
auto result = doc.load_file(path.c_str());
if (!result)
{
Logger::log("Failed opening " + path, Logger::Type::Error);
Logger::log("Reason: " + std::string(result.description()), Logger::Type::Error);
return false;
}

Can you set a breakpoint on the map.load("resources/test.tmx"); line and then 'step into'? Can you share a complete (minimal) project where this happens? Potentially it could be some header/implementation mismatch, I'm not sure and maybe better wait until the experts show up!

* I've said this many times before !

from tmxlite.

fallahn avatar fallahn commented on July 26, 2024

Could possibly be a mismatch in debug/release builds? If you're not using any external libraries (zstd etc) you can easily add the source for tmxlite directly to your project, which will help setting break points (and remove any potential build config mismatching)

from tmxlite.

MCS09 avatar MCS09 commented on July 26, 2024

Sorry, I misunderstood what you meant by 'file path goes missing'. That is weird, on the face of it, it looks impossible *

bool Map::load(const std::string& path)
{
reset();
//open the doc
pugi::xml_document doc;
auto result = doc.load_file(path.c_str());
if (!result)
{
Logger::log("Failed opening " + path, Logger::Type::Error);
Logger::log("Reason: " + std::string(result.description()), Logger::Type::Error);
return false;
}

Can you set a breakpoint on the map.load("resources/test.tmx"); line and then 'step into'? Can you share a complete (minimal) project where this happens? Potentially it could be some header/implementation mismatch, I'm not sure and maybe better wait until the experts show up!

  • I've said this many times before !

This is the project I'm working on. I can't set a breakpoint in Map.cpp because I'm using tmxlite as a dynamic library (at least I think that's what I did), so the .cpp is not in the same project.

\

Could possibly be a mismatch in debug/release builds? If you're not using any external libraries (zstd etc) you can easily add the source for tmxlite directly to your project, which will help setting break points (and remove any potential build config mismatching)

I could use the source files if I still can't get it to work, but since I've done it like that before (not me really, since it was a group project and I wasn't the one who installed the libraries), I thought I could do it the same way here.

from tmxlite.

MCS09 avatar MCS09 commented on July 26, 2024

I could use the source files if I still can't get it to work, but since I've done it like that before (not me really, since it was a group project and I wasn't the one who installed the libraries), I thought I could do it the same way here.

Ok, I couldn't try it until now and turns out I actually don't know how to use the source files (I thought I only had to copy and paste the tmxlite/src files into my project folder). Care if I ask how should I do it?

On the other hand, I'm sill trying to figure out how to install tmxlite as a dynamic library. I've checked this, this and this posts just in case. Since I'm on Windows, I can't completely follow the last one, and as far as I know, I've done the few things on the second one, but since I can't compile the tmxlite project nor the project generated with CMakeLists.txt in the tmxlite folder, I'm not sure if those libraries are completely functional.

from tmxlite.

fallahn avatar fallahn commented on July 26, 2024

The simplest way is to copy the src and include directories from the tmxlite folder to your project folder. Then (taking this random project I have as an example) right click Source Files and Add Existing -> then select all the *.cpp and *.c files:

Untitled-1

Untitled-2

Then update your project properties to add the new include path:
Untitled-3

Remember to update both Debug and Release builds, and remove any paths to the existing external library.

from tmxlite.

MCS09 avatar MCS09 commented on July 26, 2024

Thanks for the explanation! It seems to work if I use the source files, so I'm guessing I did something wrong when installing tmxlite as an external library, probably when generating the dlls. Correct me if I'm wrong, but all I had to do was use CMake to generate the project in CMakeLists.txt and compile it, right? Because when I try to compile the ALL_BUILD and ZERO_CHECK projects, I get an error that says "Access denied", when I try to compile the INSTALL one I get "The system couldn't find the specified file" and when I try to compile the tmxlite project I ghet that "tmxlite.dll isn't a valid Win32 application". Any clues on why this is happening?

from tmxlite.

fallahn avatar fallahn commented on July 26, 2024

OK, glad that works!
So the first couple of errors, I can't really help with - there may be a bug in the Visual Studio build with CMake - I usually only use CMake for linux/mac etc. The last error is that the debugger is trying to launch and run the resulting dll - although it's not an exe so it throws that error.

There is a Visual Studio solution included with the tmxlite repository, which is what I usually work with, so you ought to have more luck with that. There are a few build options which might need explaining though, to get you off on the right foot.

Firstly, make sure you have the correct architecture selected for your project. By default the solution uses x64 but you'll need to change this if you're creating a 32-bit project. (Although unless you have a specific need for 32-bit I personally always choose x64 for everything)

Untitled-1

You'll also need to build BOTH Debug and Release versions. This will create libtmxlite-d.lib/dll and libtmxlite.lib/dll respectively. You then also have to make sure to link the correct version to the correct build settings in your own project.

Untitled-2

If you don't do this there won't be a compile error, but you will get strange runtime behaviour - and I suspect this is the source of your original bug (the missing file path).

It is also possible, using the configuration settings, to create a static library.

Untitled-3

This will only compile to libtmxlite-s-d.lib/libtmxlite-s.lib (no dll) and linking this will mean the tmxlite code is compiled into your executable as if you had included the source directly - there's no need to include any dll files.

HTH! 😁

from tmxlite.

MCS09 avatar MCS09 commented on July 26, 2024

Oh, yeah, I forgot to mention that I also tried with the solution in the repository. I got to generate the libraries (which I thought weren't the ones I needed because they were named libtmxlite.lib/dll and not just tmxlite.lib/dll as I had seen in other project). with no compilation errors, but I still got the "tmxlite.dll isn't a valid Win32 application" message for each of them.

If I try linking it to my existing project, I have the same issue and the file path ends up being an empty string. I also tried linking it to a new project just in case, but then I get an "Access violation reading location" compilation error from vcruntime140.dll

from tmxlite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.