google / shaderc

A collection of tools, libraries, and tests for Vulkan shader compilation.
Other
1.84k stars 361 forks source link

Trouble linking pre-compiled lib from AppVeyor (VS 2017) #566

Closed Crisspl closed 5 years ago

Crisspl commented 5 years ago

I'm having trouble linking shaderc_combined.lib to our project on MSVC x64 (Visual Studio 2017). I got the binary from AppVeyor as you suggested in README. However I'm getting linker errors about stuff from shaderc.h (interestingly all c++-linkage stuff [things from shaderc.hpp] seems to be linked perfectly fine as I don't get any errors about those).

I tried to link pre-compiled binary because I got an impression that your build system is designed strictly for Linux. Maybe I'll try to build it myself tomorrow, but I feel it's not going to be easy.

Error   LNK2019 unresolved external symbol shaderc_compiler_initialize referenced in function "public: __cdecl shaderc::Compiler::Compiler(void)" (??0Compiler@shaderc@@QEAA@XZ)    meshloaders D:\code\cpp\IrrlichtBAW\build\examples_tests\06.MeshLoaders\Irrlicht_debug.lib(IGLSLCompiler.obj)   1   
Error   LNK2019 unresolved external symbol shaderc_compiler_release referenced in function "public: __cdecl shaderc::Compiler::~Compiler(void)" (??1Compiler@shaderc@@QEAA@XZ)  meshloaders D:\code\cpp\IrrlichtBAW\build\examples_tests\06.MeshLoaders\Irrlicht_debug.lib(IGLSLCompiler.obj)   1   
Error   LNK2019 unresolved external symbol shaderc_compile_options_initialize referenced in function "public: __cdecl shaderc::CompileOptions::CompileOptions(void)" (??0CompileOptions@shaderc@@QEAA@XZ)   meshloaders D:\code\cpp\IrrlichtBAW\build\examples_tests\06.MeshLoaders\Irrlicht_debug.lib(IGLSLCompiler.obj)   1   
Error   LNK2019 unresolved external symbol shaderc_compile_options_release referenced in function "public: __cdecl shaderc::CompileOptions::~CompileOptions(void)" (??1CompileOptions@shaderc@@QEAA@XZ) meshloaders D:\code\cpp\IrrlichtBAW\build\examples_tests\06.MeshLoaders\Irrlicht_debug.lib(IGLSLCompiler.obj)   1   
Error   LNK2019 unresolved external symbol shaderc_compile_options_set_generate_debug_info referenced in function "public: void __cdecl shaderc::CompileOptions::SetGenerateDebugInfo(void)" (?SetGenerateDebugInfo@CompileOptions@shaderc@@QEAAXXZ)    meshloaders D:\code\cpp\IrrlichtBAW\build\examples_tests\06.MeshLoaders\Irrlicht_debug.lib(IGLSLCompiler.obj)   1   
Error   LNK2019 unresolved external symbol shaderc_compile_into_spv referenced in function "public: class shaderc::CompilationResult<unsigned int> __cdecl shaderc::Compiler::CompileGlslToSpv(char const *,unsigned __int64,enum shaderc_shader_kind,char const *,char const *,class shaderc::CompileOptions const &)const " (?CompileGlslToSpv@Compiler@shaderc@@QEBA?AV?$CompilationResult@I@2@PEBD_KW4shaderc_shader_kind@@00AEBVCompileOptions@2@@Z)   meshloaders D:\code\cpp\IrrlichtBAW\build\examples_tests\06.MeshLoaders\Irrlicht_debug.lib(IGLSLCompiler.obj)   1   
Error   LNK2019 unresolved external symbol shaderc_result_release referenced in function "public: __cdecl shaderc::CompilationResult<unsigned int>::~CompilationResult<unsigned int>(void)" (??1?$CompilationResult@I@shaderc@@QEAA@XZ) meshloaders D:\code\cpp\IrrlichtBAW\build\examples_tests\06.MeshLoaders\Irrlicht_debug.lib(IGLSLCompiler.obj)   1   
Error   LNK2019 unresolved external symbol shaderc_result_get_length referenced in function "public: unsigned int const * __cdecl shaderc::CompilationResult<unsigned int>::cend(void)const " (?cend@?$CompilationResult@I@shaderc@@QEBAPEBIXZ) meshloaders D:\code\cpp\IrrlichtBAW\build\examples_tests\06.MeshLoaders\Irrlicht_debug.lib(IGLSLCompiler.obj)   1   
Error   LNK2019 unresolved external symbol shaderc_result_get_bytes referenced in function "public: unsigned int const * __cdecl shaderc::CompilationResult<unsigned int>::cbegin(void)const " (?cbegin@?$CompilationResult@I@shaderc@@QEBAPEBIXZ)  meshloaders D:\code\cpp\IrrlichtBAW\build\examples_tests\06.MeshLoaders\Irrlicht_debug.lib(IGLSLCompiler.obj)   1   
LoganDark commented 2 years ago

I'm currently having this exact issue ("unresolved external symbol shaderc_compiler_initialize" & friends) and the fact that this issue was closed without comment troubles me.

shaderc worked fine on macOS & Linux but for some reason getting it to work on Windows eludes me. Maybe that's just a testament to how stupid the OS is.

Edit: I was able to fix it by setting VULKAN_SDK instead of trying to manually set the link search path, which AFAIK is an environment variable of the bindings I'm using and not the shaderc library itself. Just in case anyone else comes across this...

Stanlyhalo commented 2 years ago

@LoganDark What do you mean VULKAN_SDK? I tried linking to the include directory via my project properties which allows myself to code and include the shaderc.hpp file... but compiling I have this same issue... So what your saying is to setup that variable name in my laptop's environment variables and have it go to the directory of what now? a .lib or the include?

LoganDark commented 2 years ago

@LoganDark What do you mean VULKAN_SDK? I tried linking to the include directory via my project properties which allows myself to code and include the shaderc.hpp file... but compiling I have this same issue... So what your saying is to setup that variable name in my laptop's environment variables and have it go to the directory of what now? a .lib or the include?

Assuming Windows, the Vulkan SDK is usually installed to somewhere like C:\VulkanSDK\1.3.204.1, which is where I pointed my VULKAN_SDK to.

Note that normally you can set environment variables in your IDE (or in PowerShell via New-Item), but if you do it in the system environment variables configuration (i.e. the one you will find in the Start menu), you'll have to log out and log back in for it to take effect.

Stanlyhalo commented 2 years ago

@LoganDark I'm already using Vulkan and have been for a while... I'm using the msvc's compiler built into Visual Studio. I also have the environment variable already setup, yet I continue to get the error. In VS, I setup the c++ include link to the include folder and the linker library set to the lib folder. Yet it still does not work.

LoganDark commented 2 years ago

@LoganDark I'm already using Vulkan and have been for a while... I'm using the msvc's compiler built into Visual Studio. I also have the environment variable already setup, yet I continue to get the error. In VS, I setup the c++ include link to the include folder and the linker library set to the lib folder. Yet it still does not work.

Can't help you there unfortunately, since I am using the Rust shaderc crate. Sorry :(