knik0 / faac

Freeware Advanced Audio Coder faac mirror
https://sourceforge.net/projects/faac/
Other
180 stars 60 forks source link

vs2017 build, error #29

Closed tom-chen-cn closed 5 years ago

tom-chen-cn commented 5 years ago

open the "project\msvc\faac.sln" with vs2017 ,build project err:“....\libfaac\aacquant.c”: No such file or directory

fabiangreffrath commented 5 years ago

Should be fixed now.

tom-chen-cn commented 5 years ago

still can't build libfaac project. errMsg ex: 1>f:\github\faac\libfaac\frame.c(35): error C2065: “PACKAGE_VERSION”: 未声明的标识符 1>f:\github\faac\libfaac\frame.c(35): error C2099: 初始值设定项不是常量 1>f:\github\faac\libfaac\quantize.c(249): error C2088: “-”: 对于 union 非法 1>f:\github\faac\libfaac\quantize.c(249): error C2168: “_mm_max_ps”: 内部函数的实参太少 1>f:\github\faac\libfaac\quantize.c(250): error C2088: “=”: 对于 union 非法 1>f:\github\faac\libfaac\quantize.c(251): error C2088: “=”: 对于 union 非法 1>f:\github\faac\libfaac\quantize.c(253): error C2088: “+=”: 对于 union 非法 1>f:\github\faac\libfaac\quantize.c(158): error C2099: 初始值设定项不是常量

fabiangreffrath commented 5 years ago

@FoxesChen Any chance to provide these error messages in English?

@vividos Could you have a look, please?

tom-chen-cn commented 5 years ago

1>f:\github\faac\libfaac\frame.c(35): error C2065: “PACKAGE_VERSION”: undeclared identifier 1>f:\github\faac\libfaac\frame.c(35): error C2099: Initial settings are not constants 1>f:\github\faac\libfaac\quantize.c(249): error C2088: “-”: for union illegal 1>f:\github\faac\libfaac\quantize.c(249): error C2168: “_mm_max_ps”: inner function param too little 1>f:\github\faac\libfaac\quantize.c(250): error C2088: “=”: for union illegal 1>f:\github\faac\libfaac\quantize.c(251): error C2088: “=”: for union illegal 1>f:\github\faac\libfaac\quantize.c(253): error C2088: “+=”: for union illegal 1>f:\github\faac\libfaac\quantize.c(158): error C2099: Initial settings are not constants

vividos commented 5 years ago

I'll take a look in the evening, maybe the visual studio project files are outdated again, or the PACKAGE_VERSION can't be read from the configure.ac file.

fabiangreffrath commented 5 years ago

1>f:\github\faac\libfaac\frame.c(35): error C2065: “PACKAGE_VERSION”: undeclared identifier 1>f:\github\faac\libfaac\frame.c(35): error C2099: Initial settings are not constants

PACKAGE_VERSION is not defined for non-Autoconf builds.

1>f:\github\faac\libfaac\quantize.c(249): error C2088: “-”: for union illegal 1>f:\github\faac\libfaac\quantize.c(249): error C2168: “_mm_max_ps”: inner function param too little 1>f:\github\faac\libfaac\quantize.c(250): error C2088: “=”: for union illegal 1>f:\github\faac\libfaac\quantize.c(251): error C2088: “=”: for union illegal 1>f:\github\faac\libfaac\quantize.c(253): error C2088: “+=”: for union illegal

Seems to be some broken erithmetic with the __m128 data type.

1>f:\github\faac\libfaac\quantize.c(158): error C2099: Initial settings are not constants

There seems to be a logic error in that line. I guess to only compile it with GCC >= 4.6 and not clang it should read

#if !defined(__clang__) && defined(__GNUC__) && (GCC_VERSION >= 40600)
fabiangreffrath commented 5 years ago

Seems to be some broken erithmetic with the __m128 data type.

Reverting parts of this commit might help: https://github.com/knik0/faac/commit/02037bc1e50947fa252ffde7318bb48565dc62e4

tom-chen-cn commented 5 years ago

@vividos you means i install vs tools lost some config, so that vs can't read the config file? because i build project with mingw, success.

vividos commented 5 years ago

About PACKAGE_VERSION: @knik0 added a tool to faad2 to read the package version from autoconf files and write it to a win32_ver.h: https://github.com/knik0/faad2/tree/master/utils/win32 faac doesn't have that tool, so it doesn't compile frame.c. I could port over that tool if you want.

Next issue is in input.c: https://github.com/knik0/faac/blob/master/frontend/input.c#L293 bufi is of type void, and a value from isize is added to that pointer. MSVC complains because it isn't defined how far the pointer should be advanced; I guess this is a C++ issue (.c files are compiled as C++) and could be fixed by either changing bufi to `char` or by forcing MSVC to compile as C.

The remaining issues are in quantize.c, where SSE2 code is used which doesn't compile with MSVC. I guess someone with expertise in SSE2 code on MSVC has to look at this.

fabiangreffrath commented 5 years ago

I could port over that tool if you want.

Yes, please!

either changing bufi to char* or by forcing MSVC to compile as C.

Let's please change the pointer type. So, void pointers are treated like char pointers in pointer arithmetics in C but not in C++?

The remaining issues are in quantize.c, where SSE2 code is used which doesn't compile with MSVC. I guess someone with expertise in SSE2 code on MSVC has to look at this.

I have already found a commit that I could revert in the critical parts and still hopefully achieve the same results.

fabiangreffrath commented 5 years ago

So, void pointers are treated like char pointers in pointer arithmetics in C but not in C++?

Only in GCC:

In GNU C, addition and subtraction operations are supported on pointers to void and on pointers to functions. This is done by treating the size of a void or of a function as 1.

https://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Pointer-Arith.html

vividos commented 5 years ago

I didn't exactly for the C language, but in C++ arithmetic with void* isn't valid.

fabiangreffrath commented 5 years ago

@FoxesChen @vividos Could you please check that the latest commits fixed compilation with MSVC without breaking anything?

vividos commented 5 years ago

Compiling worked for me now. I'm using Visual Studio 2019, but the conversation when opening a 2017 project is straight-forward (the wizard does everything). I also encoded a test wav file with faac.exe and an AAC file was produced that seems to be playing correct.

fabiangreffrath commented 5 years ago

Phew, thanks!

vividos commented 5 years ago

You're welcome!