opus icon indicating copy to clipboard operation
opus copied to clipboard

Floating Point libraries failing to build when targeting Fixed Point support only. MSVC 2017 v141

Open theyyg opened this issue 1 year ago • 3 comments

I'm trying to build the opus library from source. My target is Windows 10.0.17763.0 x64 using the v141 (Visual Studio 2017) toolset. My use case needs to decode a 16-bit fixed-point opus.

I was able to generate the opus library and several accompanying projects when using OPUS_ENABLE_FLOAT_API=ON. I was also able to build without problems.

Then, I started configuring for my desired build. I disabled this option (as we're not using floating point) and enabled OPUS_FIXED_POINT=ON. Visual Studio projects were generated without issue, but when trying to build, I received this error.

`

------ Build All started: Project: opus, Configuration: x64-Debug ------ [1/5] Building C object CMakeFiles\opus.dir\silk\float\x86\inner_product_FLP_avx2.c.obj FAILED: CMakeFiles/opus.dir/silk/float/x86/inner_product_FLP_avx2.c.obj C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\HostX64\x64\cl.exe /nologo -DCUSTOM_MODES -DDISABLE_DEBUG_FLOAT -DDISABLE_FLOAT_API -DDLL_EXPORT -DENABLE_HARDENING -DFIXED_POINT=1 -DHAVE_CONFIG_H -DHAVE_LRINT -DHAVE_LRINTF -DOPUS_BUILD -DOPUS_HAVE_RTCD -DOPUS_X86_MAY_HAVE_AVX2 -DOPUS_X86_MAY_HAVE_SSE -DOPUS_X86_MAY_HAVE_SSE2 -DOPUS_X86_MAY_HAVE_SSE4_1 -DOPUS_X86_PRESUME_SSE -DOPUS_X86_PRESUME_SSE2 -DUSE_ALLOCA -D_CRT_SECURE_NO_WARNINGS -Dopus_EXPORTS -I......\include -I. -I......\ -I......\dnn -I......\celt -I......\silk -I......\silk\fixed /DWIN32 /D_WINDOWS /Zi /Ob0 /Od /RTC1 -MDd /w44244 /w44305 /w44267 /GS /arch:AVX2 /showIncludes /FoCMakeFiles\opus.dir\silk\float\x86\inner_product_FLP_avx2.c.obj /FdCMakeFiles\opus.dir\ /FS -c ......\silk\float\x86\inner_product_FLP_avx2.c D:\dev\git\opus\opus\silk\float\x86\inner_product_FLP_avx2.c(33): fatal error C1083: Cannot open include file: 'SigProc_FLP.h': No such file or directory ninja: build stopped: subcommand failed.

Build All failed. `

It appears to try and compile some of the floating point code when targeting fixed point, but the headers are not included. I'm a novice with CMake, so I'm looking for some guidance. I'll dive in and try to track down the problem in the meantime.

Additional Info/Context:

I'm not currently working with the absolute latest code. My revision is at commit 20568812 * README related osce fixes III from 3 weeks ago. I will update and see if it's still an issue.

I have verified this using the built-in tools for a CMake project in Visual Studio 2019 (VS 2019) and with the command prompt also using the CMake version shipping with 2019. If needed, I will also post the output when running in command prompt as it doesn't use ninja and provides more verbose errors. Using VS 2017 was not an options as the accompanying CMake version is too old. The project which needs to use opus is managed with VS 2017, but I intend to build with the v141 toolset and move the built library.

theyyg avatar May 22 '24 17:05 theyyg

As a work around, removing 'inner_product_FLP_avx2.c' from the generated project allows the library to build successfully. I'll see if I can find where in the CMake files that the this file is included in the opus project.

theyyg avatar May 22 '24 17:05 theyyg

maybe something like?

if(NOT OPUS_FIXED_POINT)
    add_sources_group(opus silk ${silk_sources_float_avx2})
endif()

xnorpx avatar May 22 '24 17:05 xnorpx

Yep, I've created a pull request. I went the other direction though:

if (OPUS_ENABLE_FLOAT_API)
  add_sources_group(opus silk ${silk_sources_float_avx2})
endif()

https://github.com/xiph/opus/pull/349

theyyg avatar May 22 '24 18:05 theyyg