Skip to main content
Topic: Compiling Lame (Read 4983 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Compiling Lame

Hi all,where can i found the latest source code of Lame,and how can i compile it under Win XP?

Thank you for your answers 

Compiling Lame

Reply #1 will give you the links to the latest and other versions of the source code.

If you have MSVC6, you'll find the project files already provided. You'll also find a number of Makefiles for other compilers but I don't know whether they are up to date and fully functional. If you want to compile with the assembler speed optimisations, you'll also need nasm (Netwide Assembler) available here: Place the nasmw.exe in the libmp3lame directory and it will be found and used by MSVC project.
My compiles and utilities are at

Compiling Lame

Reply #2
Has anyone built LAME with MinGW / Cygwin with nasm enabled successfully recently?

I have tried with 3.96.1 and latest CVS, but it fails while building the executable (get the following error):

gcc -Wall -pipe -g -O4 -march=athlon-xp -mfpmath=sse,387 -fomit-frame-pointer -funroll-loops -ffast-math -o lame.exe main.o get_audio.o lametime.o parse.o portableio.o timestatus.o brhist.o  ../libmp3lame/.libs/libmp3lame.a -lm -lwsock32
../libmp3lame/.libs/libmp3lame.a(util.o)(.text+0x2251): In function `has_MMX':
c:/lame/libmp3lame/util.c:614: undefined reference to `has_MMX_nasm'
../libmp3lame/.libs/libmp3lame.a(util.o)(.text+0x2261): In function `has_3DNow':
c:/lame/libmp3lame/util.c:624: undefined reference to `has_3DNow_nasm'
../libmp3lame/.libs/libmp3lame.a(util.o)(.text+0x2271): In function `has_SSE':
c:/lame/libmp3lame/util.c:634: undefined reference to `has_SSE_nasm'
../libmp3lame/.libs/libmp3lame.a(util.o)(.text+0x2281): In function `has_SSE2':
c:/lame/libmp3lame/util.c:644: undefined reference to `has_SSE2_nasm'
../libmp3lame/.libs/libmp3lame.a(takehiro.o)(.text+0x2401): In function `huffman_init':
c:/lame/libmp3lame/takehiro.c:1326: undefined reference to `choose_table_MMX'
../libmp3lame/.libs/libmp3lame.a(fft.o)(.text+0x5b4): In function `init_fft':
c:/lame/libmp3lame/fft.c:278: undefined reference to `fht_3DN'
make[2]: *** [lame.exe] Error 1
make[2]: Leaving directory `/c/lame/frontend'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/c/lame'
make: *** [all] Error 2

If you have had success, it would be great if you could post what software versions you used amd you had to make any modifications to the Makefiles etc.

Compiling Lame

Reply #3
I don't know what Makefiles you used, but the error messages hint that you haven't linked the nasm generated object files to libmp3lame.a.

Compiling Lame

Reply #4
Well for starters your gcc optomisations are really bad

-O4 -march=athlon-xp -mfpmath=sse,387 -fomit-frame-pointer -funroll-loops -ffast-math

-O4 is just plain wrong, -O3 is the highest you can go

-mfpmath=sse,387 -ffast-math can break maths functions and currently (gcc 3.4.3) produce slower code

-funroll-loops  Unroll loops whose number of iterations can be determined at compile time or upon entry to the loop. -funroll-loops implies both -fstrength-reduce and -frerun-cse-after-loop. This option makes code larger, and may or may not make it run faster.


Just so you know :-)

try -O2(or O3, but O2 is generally better) -mtune=athlon-xp (or march, but if I remember correctly mtune implies march and mcpu is depreciated) -pipe -fomit-frame-pointer

hope that helps with the optimisations

Compiling Lame

Reply #5
I was using ./configure under MSYS to generate the Makefile, this works without using nasm, but not with.

Anyways after some more playing around I managed to use the Makefile.unix successfully (so I was just being stupid really.  'copy' is not a recognised function under msys, so it was initially failing at the first hurdle.  Simply manually copying ConfigMS.h to config.h via Windows Explorer solved it - so easy!)

Khaine, thanks for the pointers re GCC optimisations.  A handy bonus for posting my error message was I was able to get feedback on the flags I used!  I probed the manual a little myself, and these are my findings.  -funroll-loops doesn't seem to be worth the effort, and -ffast-math seems to add unnecessary dangers (quote: "can result in incorrect output for programs which depend on an exact implementation of IEEE or ISO rules/specifications for math functions").  Also, I've seen various people saying not to go above -O3, so from now on I'll stick to that.

However, it the manual did say that -mfpmath=sse "should be considerably faster in majority of cases", and it suggested that -malign-double and -maccumulate-outgoing-args should increase speed too.

To this end, I compiled Lame with the following flags (note that -march implies -mcpu, and also I'm using GCC version 3.2.3):

-Wall -pipe -O3 -march=athlon-xp -mfpmath=sse -malign-double -maccumulate-outgoing-args -fomit-frame-pointer

I compared it for speed against John33's 3.97a6 build on Rarewares at -V 2 on a 1h15m file:

Mine:      9:56 encode time,  7.4454x play/CPU
John33:  8:47 encode time,  8.4161x play/CPU

But, it's no fun using someones elses compile is it 

EDIT:  I also tried with just -Wall -pipe -O3 -march=athlon-xp -fomit-frame-pointer as you suggested.  It came out as an encode time of 9:10, and 8.0616x play/CPU.  Consider it lesson learned about GCC flags!

Compiling Lame

Reply #6
But, it's no fun using someones elses compile is it 
[a href="index.php?act=findpost&pid=265935"][{POST_SNAPBACK}][/a]

Be very careful, that's where I started!!!!!!!!
My compiles and utilities are at

SimplePortal 1.0.0 RC1 © 2008-2018