Кажется, я наткнулся на рассол. Я пытался изменить некоторые функции, которые я сделал, следуя учебному пособию по Vulkan, которое по сути является функцией ниже, но минус параметры функции и тип возвращаемого значения. Все работало просто отлично при создании экземпляра, поэтому я подумал, что с VkDebugUtilsMessengerEXT проблем не возникнет.
Ну, компоновщик не давал мне покоя и говорил мне «Неопределенный символ: _vkCreateDebugUtilsMessengerEXT» и после его подтверждения. не было заголовка l oop проблема или несоответствие типов, я был полностью сбит с толку. Теперь это работает, но только потому, что я сделал это встроенным, что не должно было ничего изменить, верно? Если кто-нибудь может объяснить, почему встраивание изменило что-либо и как заставить его работать нормально, я был бы очень признателен.
VkDebugUtilsMessengerEXT* ApplicationComponentConstructor::setupDebugMessenger(VkInstance* const instance) const
{
if (!enableValidationLayers) return nullptr;
VkDebugUtilsMessengerEXT* newDebugMessenger = new VkDebugUtilsMessengerEXT;
VkDebugUtilsMessengerCreateInfoEXT createInfo {};
createInfo = generateDebugMessengerCreateInfo();
if (vkCreateDebugUtilsMessengerEXT(*instance, &createInfo, nullptr, newDebugMessenger) != VK_SUCCESS)
throw std::runtime_error("Failed to setup debug messenger!");
return newDebugMessenger;
}
Это определение функции находится в файле "componentConstructor. cpp" и является постом. -определение члена класса «ApplicationComponentConstructor» в «componentConstructor.hpp». Вот класс для справки:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdocumentation"
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#ifndef componentConstructor_hpp
#define componentConstructor_hpp
#include <stdio.h>
#include <vector>
#ifdef NDEBUG
const bool enableValidationLayers = false;
#else
const bool enableValidationLayers = true;
#endif
const int WINDOW_WIDTH = 750;
const int WINDOW_HEIGHT = 750;
class ApplicationComponentConstructor
{
public:
friend class GameApplication;
private:
// Start of static helper functions
using VkDUMessageSeverity = VkDebugUtilsMessageSeverityFlagBitsEXT;
using VkDUMessageType = VkDebugUtilsMessageTypeFlagsEXT;
using VkDUMCallBackData = VkDebugUtilsMessengerCallbackDataEXT;
static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(VkDUMessageSeverity messageSeverity, VkDUMessageType messageType, const VkDUMCallBackData* pCallBackData, void* pUserData);
static std::vector<char> readFile(const std::string &fileName);
// End of static helper functions
// INSTANCE CREATION FUNCTIONS
VkInstance* createInstance() const;
// DEBUG MESSENGER CREATION FUNCTIONS
VkDebugUtilsMessengerEXT* setupDebugMessenger(VkInstance* const instance) const;
VkDebugUtilsMessengerCreateInfoEXT generateDebugMessengerCreateInfo() const;
// SURFACE CREATION FUNCTIONS
VkSurfaceKHR* createSurface();
// LOGICAL DEVICE CREATION FUNCTIONS
VkDevice* createLogicalDevice();
};
#endif /* componentConstructor_hpp */
И, наконец, что не менее важно, вот журнал сборки из Xcode:
Showing Recent Messages
Prepare build
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Using build description from memory
Build target VulkanProject of project VulkanProject with configuration Debug
CompileC /Users/ksbilodeau/Library/Developer/Xcode/DerivedData/VulkanProject-gbxmwgztncvnifafqcyuyrehhkxs/Build/Intermediates.noindex/VulkanProject.build/Debug/VulkanProject.build/Objects-normal/x86_64/componentConstructor.o /Users/ksbilodeau/Desktop/Xcode\ Projects/VulkanProject/VulkanProject/componentConstructor.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'VulkanProject' from project 'VulkanProject')
cd /Users/ksbilodeau/Desktop/Xcode\ Projects/VulkanProject
export LANG=en_US.US-ASCII
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -target x86_64-apple-macos10.15 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu++1z -stdlib=libc++ -fmodules -gmodules -fmodules-cache-path=/Users/ksbilodeau/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/Users/ksbilodeau/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wdocumentation -Wunreachable-code -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -DDEBUG=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -g -fvisibility-inlines-hidden -Wno-sign-conversion -Winfinite-recursion -Wmove -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wrange-loop-analysis -Wno-semicolon-before-method-body -Wunguarded-availability -index-store-path /Users/ksbilodeau/Library/Developer/Xcode/DerivedData/VulkanProject-gbxmwgztncvnifafqcyuyrehhkxs/Index/DataStore -iquote /Users/ksbilodeau/Library/Developer/Xcode/DerivedData/VulkanProject-gbxmwgztncvnifafqcyuyrehhkxs/Build/Intermediates.noindex/VulkanProject.build/Debug/VulkanProject.build/VulkanProject-generated-files.hmap -I/Users/ksbilodeau/Library/Developer/Xcode/DerivedData/VulkanProject-gbxmwgztncvnifafqcyuyrehhkxs/Build/Intermediates.noindex/VulkanProject.build/Debug/VulkanProject.build/VulkanProject-own-target-headers.hmap -I/Users/ksbilodeau/Library/Developer/Xcode/DerivedData/VulkanProject-gbxmwgztncvnifafqcyuyrehhkxs/Build/Intermediates.noindex/VulkanProject.build/Debug/VulkanProject.build/VulkanProject-all-target-headers.hmap -iquote /Users/ksbilodeau/Library/Developer/Xcode/DerivedData/VulkanProject-gbxmwgztncvnifafqcyuyrehhkxs/Build/Intermediates.noindex/VulkanProject.build/Debug/VulkanProject.build/VulkanProject-project-headers.hmap -I/Users/ksbilodeau/Library/Developer/Xcode/DerivedData/VulkanProject-gbxmwgztncvnifafqcyuyrehhkxs/Build/Products/Debug/include -I/usr/local/include -I/Users/ksbilodeau/Library/Developer/Xcode/DerivedData/VulkanProject-gbxmwgztncvnifafqcyuyrehhkxs/Build/Intermediates.noindex/VulkanProject.build/Debug/VulkanProject.build/DerivedSources-normal/x86_64 -I/Users/ksbilodeau/Library/Developer/Xcode/DerivedData/VulkanProject-gbxmwgztncvnifafqcyuyrehhkxs/Build/Intermediates.noindex/VulkanProject.build/Debug/VulkanProject.build/DerivedSources/x86_64 -I/Users/ksbilodeau/Library/Developer/Xcode/DerivedData/VulkanProject-gbxmwgztncvnifafqcyuyrehhkxs/Build/Intermediates.noindex/VulkanProject.build/Debug/VulkanProject.build/DerivedSources -F/Users/ksbilodeau/Library/Developer/Xcode/DerivedData/VulkanProject-gbxmwgztncvnifafqcyuyrehhkxs/Build/Products/Debug -F/Library/Frameworks -MMD -MT dependencies -MF /Users/ksbilodeau/Library/Developer/Xcode/DerivedData/VulkanProject-gbxmwgztncvnifafqcyuyrehhkxs/Build/Intermediates.noindex/VulkanProject.build/Debug/VulkanProject.build/Objects-normal/x86_64/componentConstructor.d --serialize-diagnostics /Users/ksbilodeau/Library/Developer/Xcode/DerivedData/VulkanProject-gbxmwgztncvnifafqcyuyrehhkxs/Build/Intermediates.noindex/VulkanProject.build/Debug/VulkanProject.build/Objects-normal/x86_64/componentConstructor.dia -c /Users/ksbilodeau/Desktop/Xcode\ Projects/VulkanProject/VulkanProject/componentConstructor.cpp -o /Users/ksbilodeau/Library/Developer/Xcode/DerivedData/VulkanProject-gbxmwgztncvnifafqcyuyrehhkxs/Build/Intermediates.noindex/VulkanProject.build/Debug/VulkanProject.build/Objects-normal/x86_64/componentConstructor.o
Ld /Users/ksbilodeau/Library/Developer/Xcode/DerivedData/VulkanProject-gbxmwgztncvnifafqcyuyrehhkxs/Build/Products/Debug/VulkanProject normal x86_64 (in target 'VulkanProject' from project 'VulkanProject')
cd /Users/ksbilodeau/Desktop/Xcode\ Projects/VulkanProject
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -target x86_64-apple-macos10.15 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -L/Users/ksbilodeau/Library/Developer/Xcode/DerivedData/VulkanProject-gbxmwgztncvnifafqcyuyrehhkxs/Build/Products/Debug -L/usr/local/lib -L/usr/local/Cellar/glfw/HEAD-e65de29/lib -F/Users/ksbilodeau/Library/Developer/Xcode/DerivedData/VulkanProject-gbxmwgztncvnifafqcyuyrehhkxs/Build/Products/Debug -F/Library/Frameworks -filelist /Users/ksbilodeau/Library/Developer/Xcode/DerivedData/VulkanProject-gbxmwgztncvnifafqcyuyrehhkxs/Build/Intermediates.noindex/VulkanProject.build/Debug/VulkanProject.build/Objects-normal/x86_64/VulkanProject.LinkFileList -Xlinker -object_path_lto -Xlinker /Users/ksbilodeau/Library/Developer/Xcode/DerivedData/VulkanProject-gbxmwgztncvnifafqcyuyrehhkxs/Build/Intermediates.noindex/VulkanProject.build/Debug/VulkanProject.build/Objects-normal/x86_64/VulkanProject_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -stdlib=libc++ -lvulkan.1 -framework vulkan -lglfw.3.4 -Xlinker -dependency_info -Xlinker /Users/ksbilodeau/Library/Developer/Xcode/DerivedData/VulkanProject-gbxmwgztncvnifafqcyuyrehhkxs/Build/Intermediates.noindex/VulkanProject.build/Debug/VulkanProject.build/Objects-normal/x86_64/VulkanProject_dependency_info.dat -o /Users/ksbilodeau/Library/Developer/Xcode/DerivedData/VulkanProject-gbxmwgztncvnifafqcyuyrehhkxs/Build/Products/Debug/VulkanProject
Undefined symbols for architecture x86_64:
"_vkCreateDebugUtilsMessengerEXT", referenced from:
ApplicationComponentConstructor::setupDebugMessenger(VkInstance_T**) const in componentConstructor.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Build failed 4/15/20, 11:39 PM 0.6 seconds
Вот ссылка на учебник, за которым я следовал, если это как-то помогает: https://vulkan-tutorial.com.