-
Notifications
You must be signed in to change notification settings - Fork 569
Description
Up until the Loading Models chapter of the tutorial (at https://vulkan-tutorial.com/Loading_models), I've had no issues following along.
After reaching Loading Models, I was able to successfully implement a few changes. As per the "Loading vertices and indices" section, I downloaded TinyObjectLoader v1.0.6, and I included it in my project with #define TINYOBJLOADER_IMPLEMENTATION. and #include <tiny_obj_loader.h>. At this point, my code was compiling and working just fine. Yes, I'm using pizza as a texture here.

But unfortunately, after implementing LoadModel(); or more specifically, Tinyobj's LoadObj(...), I get this error:
g++ -std=c++17 -O2 -I"/home/daxturus/Documents/Vulkan Tutorial/stb/" -I"/home/daxturus/Documents/Vulkan Tutorial/tinyobjloader/" -o Vulkan_Test main.cpp -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
main.cpp: In member function ‘void HelloTriangleApplication::loadModel()’:
main.cpp:1000:30: error: no matching function for call to ‘LoadObj(tinyobj::attrib_t*, std::vectortinyobj::shape_t, std::vectortinyobj::material_t, std::string*, std::string*, const char*)’
1000 | if (!tinyobj::LoadObj(&attrib, &shapes, &materials, &warn, &err, MODEL_PATH.c_str())) {
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from main.cpp:15:
/home/daxturus/Documents/Vulkan Tutorial/tinyobjloader/tiny_obj_loader.h:1395:6: note: candidate: ‘bool tinyobj::LoadObj(attrib_t*, std::vector<shape_t>, std::vector<material_t>, std::string*, const char*, const char*, bool)’
1395 | bool LoadObj(attrib_t attrib, std::vector<shape_t> shapes,
| ^~~~~~~
/home/daxturus/Documents/Vulkan Tutorial/tinyobjloader/tiny_obj_loader.h:1397:26: note: no known conversion for argument 5 from ‘std::string’ {aka ‘std::__cxx11::basic_string’} to ‘const char*’
1397 | const char filename, const char mtl_basedir, bool trianglulate) {
| ~~~~~~~~~~~~^~~~~~~~
/home/daxturus/Documents/Vulkan Tutorial/tinyobjloader/tiny_obj_loader.h:1424:6: note: candidate: ‘bool tinyobj::LoadObj(attrib_t, std::vector<shape_t>, std::vector<material_t>, std::string, std::istream*, MaterialReader*, bool)’
1424 | bool LoadObj(attrib_t attrib, std::vector<shape_t> shapes,
| ^~~~~~~
/home/daxturus/Documents/Vulkan Tutorial/tinyobjloader/tiny_obj_loader.h:1426:28: note: no known conversion for argument 5 from ‘std::string’ {aka ‘std::__cxx11::basic_string’} to ‘std::istream*’ {aka ‘std::basic_istream*’}
1426 | std::istream inStream, MaterialReader readMatFn /= NULL/,
| ~~~~~~~~~~~~~~^~~~~~~~
make: *** [Makefile:7: VulkanTest] Error 1
I thought this was a problem with my own code for a bit, so I went into the example code and double-checked I hadn't made any mistakes. I spent maybe 30 minutes trying to find something I did wrong, but I couldn't find anything I missed or made a mistake on.
Because of this, I decided to try compiling the exact contents of https://vulkan-tutorial.com/code/28_model_loading.cpp, but I still got the exact same error as above. Yes, in both cases, MODEL_PATH, an std::string, was passed into the fifth argument of the LoadModel(...) function using .c_str() to try to convert MODEL_PATH into a const char*. Which doesn't seem to be working, for whatever reason.
Since then, I've tried downgrading TinyObjLoader to versions below V1.0.6, but to no avail. I also tried moving the library from a subfolder in my project's directory to /home/user/libraries/tinyobjloader/, but I still got the same error.
At this point, I am wondering if it's something wrong with my compiler flags (see the first line of the error log above), or something wrong with my system (I am using Debian 12 at the moment). I have no prior experience with Make, and very little experience setting g++ compiler flags, so I have just been using the compiler flags as shown here: https://vulkan-tutorial.com/Development_environment.
I've attached my Makefile below (in .txt format) in case this is the issue. I am compiling the full "28_model_loading.cpp" file given in the tutorial (which I renamed to main.cpp) when I get the error, so this is either an issue with the given code, or I did something wrong outside of the code.
Makefile.txt
Thanks for reading; sorry it's a bit of a long post. Any help with this would be appreciated.