Wednesday, May 2, 2018

What is LAME?

Lame is an MPEG Audio Layer 3 encoder (mp3) licensed under GPL.
Kudos to  Mike Cheng who started this development back in 1998.  However, in its current form Mark Taylor is the leader for LAME.
Today LAME is considered as best mp3 encoder at mid-high bit rates and at VBR. There are many projects that use LAME including famous WinAMP, many of the native operating systems.
Source is available for download at http://lame.sourceforge.net/download.php
LAME is only distributed in source code form. Many of the OS are supporting LAME compilation, which includes Windows, DOS, GNU/Linux, MacOS X, *BSD, Solaris, HP-UX, Tru64, Unix, AIX, Irix, NeXTStep, and so on..

to build the source code, one can follow the below

- Download the source and extract and navigate to the folder.
- Execute the below steps

$ ./configure
$ make
$ sudo make install


as part of the ./configure script execution, it creates make file for all of them mainly to notice for libmp3lame for i386, vector, dll, ACM, MacOS X, VS etc.

config.status: creating Makefile
config.status: creating libmp3lame/Makefile
config.status: creating libmp3lame/i386/Makefile
config.status: creating libmp3lame/vector/Makefile
config.status: creating frontend/Makefile
config.status: creating mpglib/Makefile
config.status: creating doc/Makefile
config.status: creating doc/html/Makefile
config.status: creating doc/man/Makefile
config.status: creating include/Makefile
config.status: creating Dll/Makefile
config.status: creating misc/Makefile
config.status: creating dshow/Makefile
config.status: creating ACM/Makefile
config.status: creating ACM/ADbg/Makefile
config.status: creating ACM/ddk/Makefile
config.status: creating ACM/tinyxml/Makefile
config.status: creating lame.spec
config.status: creating mac/Makefile
config.status: creating macosx/Makefile
config.status: creating macosx/English.lproj/Makefile
config.status: creating macosx/LAME.xcodeproj/Makefile
config.status: creating vc_solution/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
The source in zip form is only 1.3 Mb.

But make command resulted in below error

single_module -Wl,-exported_symbols_list,.libs/libmp3lame-symbols.expsym
Undefined symbols for architecture x86_64:
  "_lame_init_old", referenced from:
     -exported_symbol[s_list] command line option
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [libmp3lame.la] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

Tried to compile using Xcode, but that was giving config.h is not found.
Gave the correct path reference to config.h and the error becomes similar to the terminal compilation, below

Undefined symbols for architecture x86_64:
  "_init_xrpow_core_sse", referenced from:
      _init_xrpow_core_init in quantize.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

so, the issue is in linking phase. The compilation is all good.

Looked at the ld command options, which displayed like this below. So all of the architectures are supported.

 ld -v
@(#)PROGRAM:ld  PROJECT:ld64-305
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
LTO support using: LLVM version 9.0.0, (clang-900.0.39.2) (static support for 21, runtime is 21)
TAPI support using: Apple TAPI version 900.0.15 (tapi-900.0.1

Now tried to comment the below lines and apparently that makes a successful build.

//#if defined(HAVE_XMMINTRIN_H)
//    if (gfc->CPU_features.SSE)
//        gfc->init_xrpow_core = init_xrpow_core_sse;
//#endif
//#ifndef HAVE_NASM
//#ifdef MIN_ARCH_SSE
//    gfc->init_xrpow_core = init_xrpow_core_sse;
//#endif
//#endif

So, the problem is really init_xrpow_core_sse. Then I stumbled upon the last link in this and this guy has also mentioned the same and mentions it to be due to the --host parameter.

Darwin myssytemcreds 17.2.0 Darwin Kernel Version 17.2.0: Fri Sep 29 18:27:05 PDT 2017; root:xnu-4570.20.62~3/RELEASE_X86_64 x86_64

from the makefile, it looked like below

host = x86_64-apple-darwin17.2.0
host_alias =
host_cpu = x86_64
host_os = darwin17.2.0
host_vendor = apple



references:
http://lame.sourceforge.net/index.php
https://gist.github.com/trevorsheridan/1948448
https://stackoverflow.com/questions/21255976/how-to-solve-undefined-symbol-init-xrpow-core-sse-when-linking-lame-mp3-encode

No comments:

Post a Comment