I am setting up dev env for Vulkan on OS X,via MoltenVK wrapper. I use Xcode IDE.
- I downloaded VulkanSDK from lunarG website.
Configured the includes.
Added (copied)
libvulkan.1.1.121.dylib
,libvulkan.1.dylib
into the project ,then added those into Build Phases -> Link Binary With Libraries of the target.
The sample code is:
#include <vulkan/vulkan.h>
#include <GLFW/glfw3.h>
#include <stdlib.h>
#include <stdio.h>
VkInstance instance;
void createInstance() {
VkApplicationInfo appInfo = {};
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
appInfo.pApplicationName = "Hello Triangle";
appInfo.applicationVersion = VK_MAKE_VERSION(1, 1, 0);
appInfo.pEngineName = "No Engine";
appInfo.engineVersion = VK_MAKE_VERSION(1, 1, 0);
appInfo.apiVersion = VK_API_VERSION_1_1;
VkInstanceCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
createInfo.pApplicationInfo = &appInfo;
uint32_t glfwExtensionCount = 0;
const char** glfwExtensions;
glfwExtensions = glfwGetRequiredInstanceExtensions(&glfwExtensionCount);
createInfo.enabledExtensionCount = glfwExtensionCount;
createInfo.ppEnabledExtensionNames = glfwExtensions;
createInfo.enabledLayerCount = 0;
if (vkCreateInstance(&createInfo, nullptr, &instance) != VK_SUCCESS)
{
printf("failed to create instance!");
}
}
int main(int argc, const char * argv[]) {
createInstance();
return 0;
}
I receive no linker errors.
When I launch the app, I keep getting:
dyld: Library not loaded: @rpath/libvulkan.1.dylib Referenced from: /Users/xxxxx/Library/Developer/Xcode/DerivedData/VulkanApp-aybsxkpxiqbshfebkfpcwaoiuige/Build/Products/Debug/VulkanApp Reason: image not found
Then Xcode presents me with the following disassembly:
My hardware setup is:
MacBook Pro. macOS 10.14.6
Two GPUs:
- Radeon Pro 555
- Intel HD Graphics 630
I got the same issue and the solution for me was to clear the content of Subpath in Xcode -> Targets -> Build Phases -> Copy files.