1

I want to build GLFW from the source in CLion. It succeeded in building the GLFW lib but it always fails to build target 'vulkan' with the error log below.

"E:\ide\CLion 2017.2.1\bin\cmake\bin\cmake.exe" --build E:\tool\glfw-3.2.1 --target vulkan -- -j 2
[ 92%] Built target glfw
Scanning dependencies of target vulkan
[ 92%] Building C object tests/CMakeFiles/vulkan.dir/vulkan.c.obj
E:\tool\glfw-3.2.1\tests\vulkan.c: In function 'myalloc':
E:\tool\glfw-3.2.1\tests\vulkan.c:1671:5: warning: implicit declaration of function 'aligned_alloc' [-Wimplicit-function-declaration]
     return aligned_alloc(alignment, size);
     ^
E:\tool\glfw-3.2.1\tests\vulkan.c:1671:5: warning: return makes pointer from integer without a cast
[100%] Linking C executable vulkan.exe
Warning: resolving _vkEndCommandBuffer@4 by linking to _vkEndCommandBuffer
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
Warning: resolving _vkQueueSubmit@20 by linking to _vkQueueSubmit
Warning: resolving _vkQueueWaitIdle@4 by linking to _vkQueueWaitIdle
Warning: resolving _vkFreeCommandBuffers@20 by linking to _vkFreeCommandBuffers
Warning: resolving _vkAllocateCommandBuffers@12 by linking to _vkAllocateCommandBuffers
Warning: resolving _vkBeginCommandBuffer@8 by linking to _vkBeginCommandBuffer
Warning: resolving _vkCmdPipelineBarrier@40 by linking to _vkCmdPipelineBarrier
Warning: resolving _vkCmdBeginRenderPass@12 by linking to _vkCmdBeginRenderPass
Warning: resolving _vkCmdBindPipeline@16 by linking to _vkCmdBindPipeline
Warning: resolving _vkCmdBindDescriptorSets@36 by linking to _vkCmdBindDescriptorSets
Warning: resolving _vkCmdSetViewport@16 by linking to _vkCmdSetViewport
Warning: resolving _vkCmdSetScissor@16 by linking to _vkCmdSetScissor
Warning: resolving _vkCmdBindVertexBuffers@20 by linking to _vkCmdBindVertexBuffers
Warning: resolving _vkCmdDraw@20 by linking to _vkCmdDraw
Warning: resolving _vkCmdEndRenderPass@4 by linking to _vkCmdEndRenderPass
Warning: resolving _vkCreateSemaphore@16 by linking to _vkCreateSemaphore
Warning: resolving _vkDestroySemaphore@16 by linking to _vkDestroySemaphore
Warning: resolving _vkCreateImageView@16 by linking to _vkCreateImageView
Warning: resolving _vkCreateImage@16 by linking to _vkCreateImage
Warning: resolving _vkGetImageMemoryRequirements@16 by linking to _vkGetImageMemoryRequirements
Warning: resolving _vkAllocateMemory@16 by linking to _vkAllocateMemory
Warning: resolving _vkBindImageMemory@28 by linking to _vkBindImageMemory
Warning: resolving _vkGetImageSubresourceLayout@20 by linking to _vkGetImageSubresourceLayout
Warning: resolving _vkMapMemory@36 by linking to _vkMapMemory
Warning: resolving _vkUnmapMemory@12 by linking to _vkUnmapMemory
Warning: resolving _vkDestroyImage@16 by linking to _vkDestroyImage
Warning: resolving _vkFreeMemory@16 by linking to _vkFreeMemory
Warning: resolving _vkGetPhysicalDeviceFormatProperties@12 by linking to _vkGetPhysicalDeviceFormatProperties
Warning: resolving _vkCmdCopyImage@36 by linking to _vkCmdCopyImage
Warning: resolving _vkCreateSampler@16 by linking to _vkCreateSampler
Warning: resolving _vkCreateBuffer@16 by linking to _vkCreateBuffer
Warning: resolving _vkGetBufferMemoryRequirements@16 by linking to _vkGetBufferMemoryRequirements
Warning: resolving _vkBindBufferMemory@28 by linking to _vkBindBufferMemory
Warning: resolving _vkCreateDescriptorSetLayout@16 by linking to _vkCreateDescriptorSetLayout
Warning: resolving _vkCreatePipelineLayout@16 by linking to _vkCreatePipelineLayout
Warning: resolving _vkCreateRenderPass@16 by linking to _vkCreateRenderPass
Warning: resolving _vkCreateShaderModule@16 by linking to _vkCreateShaderModule
Warning: resolving _vkCreatePipelineCache@16 by linking to _vkCreatePipelineCache
Warning: resolving _vkCreateGraphicsPipelines@28 by linking to _vkCreateGraphicsPipelines
Warning: resolving _vkDestroyPipelineCache@16 by linking to _vkDestroyPipelineCache
Warning: resolving _vkDestroyShaderModule@16 by linking to _vkDestroyShaderModule
Warning: resolving _vkCreateDescriptorPool@16 by linking to _vkCreateDescriptorPool
Warning: resolving _vkAllocateDescriptorSets@12 by linking to _vkAllocateDescriptorSets
Warning: resolving _vkUpdateDescriptorSets@20 by linking to _vkUpdateDescriptorSets
Warning: resolving _vkCreateFramebuffer@16 by linking to _vkCreateFramebuffer
Warning: resolving _vkCreateCommandPool@16 by linking to _vkCreateCommandPool
Warning: resolving _vkDeviceWaitIdle@4 by linking to _vkDeviceWaitIdle
Warning: resolving _vkEnumerateInstanceLayerProperties@8 by linking to _vkEnumerateInstanceLayerProperties
Warning: resolving _vkEnumerateInstanceExtensionProperties@12 by linking to _vkEnumerateInstanceExtensionProperties
Warning: resolving _vkCreateInstance@12 by linking to _vkCreateInstance
Warning: resolving _vkEnumeratePhysicalDevices@12 by linking to _vkEnumeratePhysicalDevices
Warning: resolving _vkEnumerateDeviceLayerProperties@12 by linking to _vkEnumerateDeviceLayerProperties
Warning: resolving _vkEnumerateDeviceExtensionProperties@16 by linking to _vkEnumerateDeviceExtensionProperties
Warning: resolving _vkGetInstanceProcAddr@8 by linking to _vkGetInstanceProcAddr
Warning: resolving _vkGetPhysicalDeviceProperties@8 by linking to _vkGetPhysicalDeviceProperties
Warning: resolving _vkGetPhysicalDeviceQueueFamilyProperties@12 by linking to _vkGetPhysicalDeviceQueueFamilyProperties
Warning: resolving _vkCreateDevice@16 by linking to _vkCreateDevice
Warning: resolving _vkGetDeviceProcAddr@8 by linking to _vkGetDeviceProcAddr
Warning: resolving _vkGetDeviceQueue@16 by linking to _vkGetDeviceQueue
Warning: resolving _vkGetPhysicalDeviceMemoryProperties@8 by linking to _vkGetPhysicalDeviceMemoryProperties
Warning: resolving _vkDestroyFramebuffer@16 by linking to _vkDestroyFramebuffer
Warning: resolving _vkDestroyDescriptorPool@16 by linking to _vkDestroyDescriptorPool
Warning: resolving _vkDestroyCommandPool@16 by linking to _vkDestroyCommandPool
Warning: resolving _vkDestroyPipeline@16 by linking to _vkDestroyPipeline
Warning: resolving _vkDestroyRenderPass@16 by linking to _vkDestroyRenderPass
Warning: resolving _vkDestroyPipelineLayout@16 by linking to _vkDestroyPipelineLayout
Warning: resolving _vkDestroyDescriptorSetLayout@16 by linking to _vkDestroyDescriptorSetLayout
Warning: resolving _vkDestroyBuffer@16 by linking to _vkDestroyBuffer
Warning: resolving _vkDestroyImageView@16 by linking to _vkDestroyImageView
Warning: resolving _vkDestroySampler@16 by linking to _vkDestroySampler
Warning: resolving _vkDestroyDevice@8 by linking to _vkDestroyDevice
Warning: resolving _vkDestroySurfaceKHR@16 by linking to _vkDestroySurfaceKHR
Warning: resolving _vkDestroyInstance@8 by linking to _vkDestroyInstance
CMakeFiles\vulkan.dir/objects.a(vulkan.c.obj):vulkan.c:(.text+0x37a3): undefined reference to `aligned_alloc'
collect2.exe: error: ld returned 1 exit status
tests\CMakeFiles\vulkan.dir\build.make:98: recipe for target 'tests/vulkan.exe' failed
mingw32-make.exe[3]: *** [tests/vulkan.exe] Error 1
CMakeFiles\Makefile2:1162: recipe for target 'tests/CMakeFiles/vulkan.dir/all' failed
mingw32-make.exe[2]: *** [tests/CMakeFiles/vulkan.dir/all] Error 2
CMakeFiles\Makefile2:1174: recipe for target 'tests/CMakeFiles/vulkan.dir/rule' failed
mingw32-make.exe[1]: *** [tests/CMakeFiles/vulkan.dir/rule] Error 2
Makefile:514: recipe for target 'vulkan' failed
mingw32-make.exe: *** [vulkan] Error 2

At first I think it doesn't use the C11 in building but it also doesn't work after I added set(CMAKE_C_STANDARD 11) to the CMakeLists.txt.

Env: GLFW-3.2.1, CLion 2017.2.2, CMake 3.8.2 and MinGW 3.20.

xsun2001
  • 11
  • 1
  • 3
  • aligned_alloc should be in the stdlib.h you are using. Can find it in there? Hidden behind any interesting #ifdef perhaps? – Andreas Sep 17 '17 at 13:34
  • @Andreas Sorry to drag on for such a long time before returning. I am using the offical source code and it seems that they all imported correctly.`#ifndef _MSC_VER #define _ISOC11_SOURCE /* for aligned_alloc() */ #endif #include #include #include #include #include ` It the head of vulcan.c – xsun2001 Sep 23 '17 at 05:03
  • Ok good. I was asking about the stdlib.h content though, not vulkan.c/h. Looking at my own VS env I can´t find the aligned_alloc declaration. Have you looked at this: https://stackoverflow.com/questions/29247065/compiler-cant-find-aligned-alloc-function – Andreas Sep 23 '17 at 15:46
  • Yes, my ```stdlib.h``` in the MinGW has no `aligned_alloc`. But it already has `#define _ISOC11_SOURCE`. Is that meaning I cannot build the 'vulkan' test in MinGW? – xsun2001 Sep 24 '17 at 05:11
  • seem so :-( you could try declare it before #include vulkan.h and then implement it yourself: https://stackoverflow.com/questions/16376942/best-cross-platform-method-to-get-aligned-memory – Andreas Sep 24 '17 at 11:10

0 Answers0