Open MattCS09 opened 1 year ago
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.
Are you debugging from within VS? Check the working directory (from memory it's
Project Properties -> Debugging -> Working Directory
) because your relative pathresources/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.
Sorry, I misunderstood what you meant by 'file path goes missing'. That is weird, on the face of it, it looks impossible *
https://github.com/fallahn/tmxlite/blob/2ac30553ceea838966829da22777cc31458db56d/tmxlite/src/Map.cpp#L58-L70
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 !
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)
Sorry, I misunderstood what you meant by 'file path goes missing'. That is weird, on the face of it, it looks impossible *
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.
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.
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:
Then update your project properties to add the new include path:
Remember to update both Debug and Release builds, and remove any paths to the existing external library.
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?
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)
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.
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.
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! 😁
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
I've tried installing tmxlite into a project I've created (I'm using Visual Studio 2022) and all the includes seem to work fine, but every time I try to load a map this way:
\ I get this in the console:
\ If I try to do the same in the ParseTest project and load an unexisting map, I get this, which makes sense because the directory doesn't exist:
\ It seems like the issue is that the file path goes missing at some point, but I can't keep track of where it happens since the Map.cpp file isn't in the include files and I don't know how to add a breaking point to an external file. \ I was wondering if I messed up the installation or something, since had a hard time generating the .libs and .dlls of the library. I also tried using the .libs and .dlls of a project where tmxlite worked fine, but I still had the same issue, so I don't really know what's causing it.