Skip to content
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.

Linker errors when compiling with Visual Studio #277

Open
waltdestler opened this issue Feb 7, 2018 · 1 comment
Open

Linker errors when compiling with Visual Studio #277

waltdestler opened this issue Feb 7, 2018 · 1 comment

Comments

@waltdestler
Copy link

I am unable to compile any configuration using Visual Studio 2012 because I get the following linker errors:

12>BlockCompressor.obj : error LNK2019: unresolved external symbol "float __cdecl nv::compress_etc1(class nv::Vector4 * const,float * const,class nv::Vector3 const &,void *)" (?compress_etc1@nv@@YAMQAVVector4@1@QAMABVVector3@1@PAX@Z) referenced in function "public: virtual void __thiscall nv::CompressorETC1::compressBlock(class nv::Vector4 * const,float * const,struct nvtt::CompressionOptions::Private const &,void *)" (?compressBlock@CompressorETC1@nv@@UAEXQAVVector4@2@QAMABUPrivate@CompressionOptions@nvtt@@PAX@Z)
12>BlockCompressor.obj : error LNK2019: unresolved external symbol "float __cdecl nv::compress_etc2(class nv::Vector4 * const,float * const,class nv::Vector3 const &,void *)" (?compress_etc2@nv@@YAMQAVVector4@1@QAMABVVector3@1@PAX@Z) referenced in function "public: virtual void __thiscall nv::CompressorETC2_RGB::compressBlock(class nv::Vector4 * const,float * const,struct nvtt::CompressionOptions::Private const &,void *)" (?compressBlock@CompressorETC2_RGB@nv@@UAEXQAVVector4@2@QAMABUPrivate@CompressionOptions@nvtt@@PAX@Z)
12>CompressorDXT5_RGBM.obj : error LNK2001: unresolved external symbol "float __cdecl nv::compress_etc2(class nv::Vector4 * const,float * const,class nv::Vector3 const &,void *)" (?compress_etc2@nv@@YAMQAVVector4@1@QAMABVVector3@1@PAX@Z)
12>BlockCompressor.obj : error LNK2019: unresolved external symbol "float __cdecl nv::compress_eac(class nv::Vector4 * const,float * const,int,int,bool,void *)" (?compress_eac@nv@@YAMQAVVector4@1@QAMHH_NPAX@Z) referenced in function "public: virtual void __thiscall nv::CompressorETC2_R::compressBlock(class nv::Vector4 * const,float * const,struct nvtt::CompressionOptions::Private const &,void *)" (?compressBlock@CompressorETC2_R@nv@@UAEXQAVVector4@2@QAMABUPrivate@CompressionOptions@nvtt@@PAX@Z)
12>CompressorDXT5_RGBM.obj : error LNK2001: unresolved external symbol "float __cdecl nv::compress_eac(class nv::Vector4 * const,float * const,int,int,bool,void *)" (?compress_eac@nv@@YAMQAVVector4@1@QAMHH_NPAX@Z)
12>BlockCompressor.obj : error LNK2019: unresolved external symbol "float __cdecl nv::compress_etc2_eac(class nv::Vector4 * const,float * const,class nv::Vector3 const &,void *)" (?compress_etc2_eac@nv@@YAMQAVVector4@1@QAMABVVector3@1@PAX@Z) referenced in function "public: virtual void __thiscall nv::CompressorETC2_RGBA::compressBlock(class nv::Vector4 * const,float * const,struct nvtt::CompressionOptions::Private const &,void *)" (?compressBlock@CompressorETC2_RGBA@nv@@UAEXQAVVector4@2@QAMABUPrivate@CompressionOptions@nvtt@@PAX@Z)
12>CompressorDXT5_RGBM.obj : error LNK2019: unresolved external symbol "void __cdecl nv::decompress_etc(void const *,class nv::Vector4 * const)" (?decompress_etc@nv@@YAXPBXQAVVector4@1@@Z) referenced in function "float __cdecl nv::compress_etc2_rgbm(class nv::Vector4 * const,float * const,float,void *)" (?compress_etc2_rgbm@nv@@YAMQAVVector4@1@QAMMPAX@Z)
12>Surface.obj : error LNK2001: unresolved external symbol "void __cdecl nv::decompress_etc(void const *,class nv::Vector4 * const)" (?decompress_etc@nv@@YAXPBXQAVVector4@1@@Z)
12>Context.obj : error LNK2019: unresolved external symbol "public: __thiscall nv::KtxHeader::KtxHeader(void)" (??0KtxHeader@nv@@QAE@XZ) referenced in function "public: bool __thiscall nvtt::Compressor::Private::outputHeader(enum nvtt::TextureType,int,int,int,int,int,bool,struct nvtt::CompressionOptions::Private const &,struct nvtt::OutputOptions::Private const &)const " (?outputHeader@Private@Compressor@nvtt@@QBE_NW4TextureType@3@HHHHH_NABU1CompressionOptions@3@ABU1OutputOptions@3@@Z)
12>Surface.obj : error LNK2019: unresolved external symbol "void __cdecl nv::decompress_etc_eac(void const *,class nv::Vector4 * const)" (?decompress_etc_eac@nv@@YAXPBXQAVVector4@1@@Z) referenced in function "public: bool __thiscall nvtt::Surface::setImage2D(enum nvtt::Format,enum nvtt::Decoder,int,int,void const *)" (?setImage2D@Surface@nvtt@@QAE_NW4Format@2@W4Decoder@2@HHPBX@Z)
12>C:\Users\Walt\Documents\Code\nvidia-texture-tools\project\vc12\\Debug.Win32\bin\nvtt.dll : fatal error LNK1120: 7 unresolved externals

I have made no changes to any files.

I have attached the full build output.

nvtt build output.txt

@StefanBruens
Copy link
Contributor

I think this is some stupidity on the side of MSVC:

In each of the mismatching function types, MSVC used a type of class nv::Vector4 * const for nv::Vector[16].

The correct type for the parameter would be nv::Vector4 * (without const), as the "array of V4" decays to "pointer to V4". Why it adds a "const" to the pointer is unknown to me and violating the C++ standard, which states topmost cv-qualifiers have to be removed from the function signature.

Interestingly it does this only if the array element type is not cv-qualified (i.e. const Vector4[16] correctly decays to const Vector4 *). Thats the reason only the symbols in CompressorETC can not be found.

There are three possible workarounds/solutions:

  • redeclare the prototypes to decompress_etc(const void *, Vector4 *)
  • pass a pointer to the first array element, i.e. call decompress_etc(block, &colors[0])
  • use std::array<Vector4, 16>& as parameter

The last one is the only typesafe variant, as this actually encodes the array size in the function parameter list, nv::decompress_etc_eac(void const*, std::array<nv::Vector4, 16ul>&)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants