Windows compiling open source code method: testing and process of lame.exe file

Windows compiling open source code method about the testing and process of lame.exe file

  • Final result (PS: If you are not familiar with using markdown, remember to add a space after the pound sign to trigger)
  • Cause: foobar2000 requires lame.exe during format conversion. However I can only find [source code. This is what people say:](https://sourceforge.net/projects/lame/)
    • There’s no other way, so let’s do it.
  • Idea: 1: Try compiling the executable file exe on Linux
    • [This method is called cross-compilation, and a cross-compiler is required](https://weepingdogel.github.io/posts/Try to compile exe executable files under linux/)
  • Idea 2: Use a project management tool (or IDE) to compile and run.
    • Analogy to Linux principles
  • Idea 3: Use Cygwin. (There are many similar ones. It just imitates Linux and I won’t go into details here)
  • Idea 4: Use wsl, which is similar to Linux. Cross compilation is still required.
  • There are many instructions after INSTALL. Building the software on Windows with free compilers. Quite similar. I won’t say any more.
  • The summary is to strictly follow the documentation. Understand the differences between Linux and Windows. And know the commonalities of compilation.
  • I would also like to know for example how python code compiles into an executable file. This seems to require the use of pyinstaller, [there is an article with instructions. ](https://zhuanlan.zhihu.com/p/162237978)
  • one more thing

Final result (PS: If you are not familiar with using markdown, remember to add a space after the pound sign to trigger)

PS C:\Users\zjc20\source> cd .\lame-3.100\
PS C:\Users\zjc20\source\lame-3.100> nmake.exe .\Makefile.MSVC

Microsoft (R) Program Maintenance Utility Version 14.34.31937.0
Copyright (C) Microsoft Corporation. All rights reserved.

-------------------------------------------------- -------------------
building LAME featuring RH
 +ASM
 + MMX
using MS COMPILER
 + optimizing for Pentium II/III
 + using Single precision
-------------------------------------------------- -------------------
Pass GTK=YES to build the frame analyzer. (requires installed GTK)

libmp3lame\i386\cpu_feat.nas
'nasmw' is not recognized as an internal or external command,
operable program or batch file.
NMAKE: fatal error U1077: 'nasmw' : return code '0x1'
Stop.
PS C:\Users\zjc20\source\lame-3.100> copy .\configMS.h config.h
PS C:\Users\zjc20\source\lame-3.100> nmake -f .\Makefile.MSVC comp=msvc asm=no

Microsoft (R) Program Maintenance Utility Version 14.34.31937.0
Copyright (C) Microsoft Corporation. All rights reserved.

-------------------------------------------------- -------------------
building LAME featuring RH
using MS COMPILER
 + optimizing for Pentium II/III
 + using Single precision
-------------------------------------------------- -------------------
Pass GTK=YES to build the frame analyzer. (requires installed GTK)
Pass ASM=YES to build the assembler optimizations

bitstream.c
encoder.c
fft.c
gain_analysis.c
id3tag.c
lame.c
newmdct.c
psymodel.c
quantify.c
quantify_pvt.c
xmm_quantize_sub.c
set_get.c
vbrquantize.c
reservoir.c
tables.c
takehiro.c
util.c
mpglib_interface.c
VbrTag.c
presets.c
version.c

--- LAME MP3 ENCODING LIBRARY UPTODATE ---

common.c
dct64_i386.c
decode_i386.c
layer1.c
layer2.c
layer3.c
tabinit.c
interface.c

--- HIP DECODING LIBRARY UPTODATE ---


--=* .\output\libmp3lame-static.lib ready *=--

main.c
get_audio.c
parse.c
timestatus.c
lametime.c
console.c
brhist.c

---COMMON FRONTEND STUFF UPTODATE ---

lame_main.c
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Copyright (C) Microsoft Corporation. All rights reserved.


--=* .\output\lame.exe ready *=--


--=* lame.exe uptodate *=--

PS C:\Users\zjc20\source\lame-3.100>

You can see that the source code was successfully compiled into an exe, which is an executable file
In this example, the instructions in the INSTALL file in the lame source file are complete. So after configuring the environment, you can compile. Mainly I learned a lot.
I have been operating on Linux before. Linux has better support for source code. I also checked the reason and I will put a link later. But after arriving at the window system, it becomes a headache.
The reasons are:
One is: I mostly use the interpreted language: python on windows, and the language is relatively simple, so I just need to configure the python environment. But for example, when implementing the source code of a relatively large project, if you use Python alone, just follow the instructions in the readme. There is integration. As long as the environment configuration is correct, it is not a big problem, because usually it only needs to be done on Linux. However, when it comes to outputting a Windows executable file, I have not tried it. I have done it before. When C++ and C are used, devC++ is used. Just write it directly and then compile and run it.
Second, I don’t know much about the window system. The Windows system is quite complicated, even for a newbie like me. Therefore, it is relatively simple to write, compile, and run in Linux. Things like make and cofigure are relatively simple. Now look at the difference between Linux and window:

Unlike the Linux series operating systems, the Windows native environment does not provide a C/C++ language source program compilation and execution tool chain similar to gcc and Clang. IDEs (Integrated Development Environments) running on Windows, such as CodeBlocks, generally use MinGW (Minimalist GNU for Windows) configuration to simulate the development environment under Linux for development under Windows.
But under Windows, the MSVC (Microsoft Visual C/C++) compiler works better with the development environment and code editor. For a more flexible code editor, we can download and integrate Microsoft’s Visual C/C++ compiler into the code.
Third: I habitually use VScode, and VScode is just a notepad-like thing with no actual functions, so I can only configure it constantly. In other words, I am more accustomed to working on the command line. “The more I play, the more I like to play.” Like gcc, I can still do some relatively simple compilation. Once I get to the makefile, or click on the sh file, I haven’t tried it. Although my understanding of these files is: they are like scripts and commands. It is a form of automation. But I really don’t understand it. I always feel that it is closely related to the underlying computer. Moreover, there are really many configs and makefiles in this project: if I didn’t look at the INSTALL file, I really wouldn’t know what it means.

C:.
│ acinclude.m4
│ aclocal.m4
│API
│ ChangeLog
│ compile
│ config.guess
│ config.h.in
│ config.log
│ config.rpath
│ config.sub
│ configMS.h
│ configure
│ configure.in
│ COPYING
│DEFINES
│ depcomp
│ HACKING
│ INSTALL
│ install-sh
│ INSTALL.configure
│ lame.bat
│ lame.spec
│ lame.spec.in
│ LICENSE
│ltmain.sh
│ Makefile.am
│ Makefile.am.global
│ Makefile.in
│ Makefile.MSVC
│ Makefile.unix
│ missing
│ README
│ README.WINGTK
│ STYLEGUIDE
│ testcase.mp3
│ testcase.wav
│ TODO
│USAGE
│
├───.vs
│ │ slnx.sqlite
│ │ VSWorkspaceState.json
│ │
│ └───lame-3.100
│ ├───FileContentIndex
│ │ │ b4658905-267a-40dc-a6ab-7ec6f8b836c3.vsidx
│ │ │ read.lock
│ │ │
│ │ └───merges
│ └───v17
├───ACM
│ │ ACM.cpp
│ │ ACM.h
│ │ acm.rc
│ │ ACMStream.cpp
│ │ ACMStream.h
│ │ adebug.h
│ │ AEncodeProperties.cpp
│ │ AEncodeProperties.h
│ │DecodeStream.cpp
│ │DecodeStream.h
│ │ lame.ico
│ │ lameACM.def
│ │LameACM.inf
│ │ lame_acm.xml
│ │ main.cpp
│ │ Makefile.am
│ │ Makefile.in
│ │readme.txt
│ │ resource.h
│ │ TODO
│ │
│ ├───ADbg
│ │ADbg.cpp
│ │ADbg.h
│ │ Makefile.am
│ │ Makefile.in
│ │
│ ├───ddk
│ │ Makefile.am
│ │ Makefile.in
│ │ msacmdrv.h
│ │
│ └───tinyxml
│ changes.txt
│ dox
│ makedistlinux
│ makedistwin.bat
│ Makefile.am
│ Makefile.in
│ Makefile.tinyxml
│readme.txt
│ tinyxml.cpp
│ tinyxml.h
│ tinyxmlerror.cpp
│ tinyxmlparser.cpp
│xmltest.cpp
│
├───debian
│ │ .cvsignore
│ │ changelog
│ │ compat
│ │ control
│ │ copyright
│ │ lame.doc-base
│ │ lame.docs
│ │ lame.install
│ │ lame.manpages
│ │ libmp3lame-dev.install
│ │ libmp3lame0.install
│ │ Makefile.am
│ │ Makefile.in
│ │ rules
│ │ watch
│ │
│ ├───CVS
│ │ Entries
│ │ Repository
│ │Root
│ │
│ └───source
│ │ format
│ │
│ └───CVS
│ Entries
│ Repository
│Root
│
├───Dll
│ BladeMP3EncDLL.c
│ BladeMP3EncDLL.def
│ BladeMP3EncDLL.h
│Example.cpp
│LameDLLInterface.htm
│ Makefile.am
│ Makefile.in
│ Makefile.mingw32
│MP3export.pas
│ README
│
├───doc
│ │ Makefile.am
│ │ Makefile.in
│ │
│ ├───html
│ │ about.html
│ │ abr.html
│ │ cbr.html
│ │ contact.html
│ │ contributors.html
│ │ detailed.html
│ │ history.html
│ │ index.html
│ │ introduction.html
│ │ links.html
│ │ list.html
│ │ Makefile.am
│ │ Makefile.in
│ │ ms_stereo.html
│ │ usage.html
│ │ vbr.html
│ │
│ └───man
│ lame.1
│ Makefile.am
│ Makefile.in
│
├───dshow
│ aboutprp.cpp
│ aboutprp.h
│elogo.ico
│Encoder.cpp
│Encoder.h
│iaudioprops.h
│ Makefile.am
│ Makefile.in
│Mpegac.cpp
│Mpegac.def
│Mpegac.h
│Property.rc
│PropPage.cpp
│PropPage.h
│PropPage_adv.cpp
│PropPage_adv.h
│ README
│ REG.CPP
│ REG.H
│ resource.h
│UIDS.H
│
├───frontend
│ amiga_mpega.c
│ brhist.c
│ brhist.h
│ console.c
│ console.h
│ depcomp
│get_audio.c
│ get_audio.h
│ gpkplotting.c
│ gpkplotting.h
│ gtkanal.c
│ gtkanal.h
│ lametime.c
│ lametime.h
│ lame_main.c
│ main.c
│ main.h
│ Makefile.am
│ Makefile.in
│ mp3rtp.c
│ mp3x.c
│ parse.c
│ parse.h
│rtp.c
│rtp.h
│ timestatus.c
│ timestatus.h
│
├───include
│ lame.def
│ lame.h
│ libmp3lame.sym
│ Makefile.am
│ Makefile.in
│
├───libmp3lame
│ │ bitstream.c
│ │ bitstream.h
│ │ depcomp
│ │ encoder.c
│ │ encoder.h
│ │ fft.c
│ │ fft.h
│ │ gain_analysis.c
│ │ gain_analysis.h
│ │ id3tag.c
│ │ id3tag.h
│ │ l3side.h
│ │ lame-analysis.h
│ │ lame.c
│ │ lame.rc
│ │ lameerror.h
│ │ lame_global_flags.h
│ │ logoe.ico
│ │machine.h
│ │ Makefile.am
│ │ Makefile.in
│ │ mpglib_interface.c
│ │ newmdct.c
│ │ newmdct.h
│ │ presets.c
│ │ psymodel.c
│ │ psymodel.h
│ │quantize.c
│ │quantize.h
│ │ quantize_pvt.c
│ │ quantize_pvt.h
│ │ reservoir.c
│ │ reservoir.h
│ │ set_get.c
│ │ set_get.h
│ │ tables.c
│ │ tables.h
│ │ takehiro.c
│ │ util.c
│ │ util.h
│ │ vbrquantize.c
│ │ vbrquantize.h
│ │ VbrTag.c
│ │ VbrTag.h
│ │ version.c
│ │ version.h
│ │
│ ├───i386
│ │ choose_table.nas
│ │ cpu_feat.nas
│ │ fft.nas
│ │ fft3dn.nas
│ │ fftfpu.nas
│ │ fftsse.nas
│ │ ffttbl.nas
│ │ Makefile.am
│ │ Makefile.in
│ │nasm.h
│ │ scalar.nas
│ │
│ └───vector
│ lame_intrin.h
│ Makefile.am
│ Makefile.in
│ xmm_quantize_sub.c
│
├───mac
│ .DS_Store
│ LAME.mcp
│ LAME_Carbon_Debug.pch
│ LAME_Carbon_Final.pch
│ LAME_Classic_Debug.pch
│ LAME_Classic_Final.pch
│MacDLLMain.c
│ Makefile.am
│ Makefile.in
│Precompile_Common.h
│
├───macosx
│ │ Info.plist
│ │ LAME_Prefix.pch
│ │ Makefile.am
│ │ Makefile.in
│ │
│ ├───English.lproj
│ │ InfoPlist.strings
│ │ Makefile.am
│ │ Makefile.in
│ │
│ └───LAME.xcodeproj
│ Makefile.am
│ Makefile.in
│ project.pbxproj
│
├───misc
│abx.c
│ath.c
│ auenc
│ depcomp
│Lame.vbs
│ lame4dos.bat
│ lameGUI.html
│ lameid3.pl
│ Makefile.am
│ Makefile.in
│ mk_mp3.sh
│ mlame
│mlame_corr.c
│ mugeco.sh
│scalartest.c
│
├───mpglib
│ AUTHORS
│ common.c
│ common.h
│dct64_i386.c
│dct64_i386.h
│decode_i386.c
│decode_i386.h
│ depcomp
│ huffman.h
│ interface.c
│ interface.h
│ l2tables.h
│ layer1.c
│ layer1.h
│ layer2.c
│ layer2.h
│ layer3.c
│ layer3.h
│ Makefile.am
│ Makefile.in
│ mpg123.h
│mpglib.h
│ README
│ tabinit.c
│ tabinit.h
│
└───vc_solution
        arch_nasm.vsprops
        arch_sse2.vsprops
        arch_x87.vsprops
        Makefile.am
        Makefile.in
        vc9_lame.sln
        vc9_lame_acm.vcproj
        vc9_lame_acm_adbg.vcproj
        vc9_lame_acm_tinyxml.vcproj
        vc9_lame_clients.sln
        vc9_lame_config.vsprops
        vc9_lame_dll.vcproj
        vc9_lame_dll_example.vcproj
        vc9_lame_dshow.vcproj
        vc9_lame_lame.vcproj
        vc9_lame_mp3rtp.vcproj
        vc9_lame_mp3x.vcproj
        vc9_lame_test.vcproj
        vc9_libmp3lame.vcproj
        vc9_libmp3lame_dll.vcproj
        vc9_mpglib.vcproj
        vc9_nasm.rules

================================================ ========================
Building the software on *NIX platforms using configure:
================================================== =====================
Run the following commands:

% ./configure
% make
% make install

For a complete list of options, try "./configure --help"
Some of the more usefull options:
================================================ ========================
Building the software on Windows with MSVC:
(or MSVC + 3rd party C compiler such as ICL)
================================================== =====================
There are MSVC project files, and a Makefile.MSVC included with the
project. For production use, be sure to compile a "Release" target,
with the "maximum speed" compile option, and #define NDEBUG.

It is possible to compile the GTK frame analyzer under windows, see
README.WINGTK

Various build options can be set in configMS.h

Note: project files for building lame.exe seem to be broken or not
quite compatable with MSVC6. The most reliable way to build lame and
lame_enc.dll is to run the .bat script (comes with MSVC6) which sets
up your VC environment to work from the command line, and then:

copy configMS.h config.h
nmake -f Makefile.MSVC comp=msvc asm=no

Project files for the dll, ACM codec and directshow filter
seem to be in better sahpe.

Cause: foobar2000 requires lame.exe during format conversion. However I can only find the source code. This is what people say:

LAME is an educational tool to be used for learning about MP3 encoding.

The goal of the LAME project is to improve the psycho acoustics, quality and speed of MP3 encoding.

Note: we provide source code only!

Features
Source code only!!!

There is no other way, so let’s do it.

Idea: 1: Try compiling the executable file exe on Linux

The environmental requirements on Linux don’t seem to be that confusing.

This method is called cross-compilation, and a cross-compiler is required

The method has not been tried

Idea 2: Use a project management tool (or IDE) to compile and run.

Analogy to Linux principles

In the Angband directory, first, run the configuration script provided with the source code:

$ ./configure

This step will scan your system for Angbanddependencies required to build correctly. Some dependencies are so basic that your computer won’t run without them, while others are specialized. At the end of the process, the script will give you a report on what it found.

Once everything is configured, run the make command:
$ make
This usually takes a while, but it provides a lot of visual feedback so you’ll know the code is being compiled.

The last step is to install the code you just compiled. There is nothing magical about the installation code. All it does is copy a lot of files into very specific directories. This is true whether you compile from source or run a fancy graphical installation wizard. Because this code will be copied to a system-wide directory, you must have root (administrative) permissions, which is granted by the sudo command.
$ sudo make install
1
In other words: these are the principles. Start seeing the difference.
Fortunately, the documentation is very clear:
How to get MSVC:
?Generally speaking, obtaining MSVC is achieved through Microsoft Visual Studio. For general application scenarios, we do not need to download the complete IDE but only need to download the MSVC C++ generation tool under a single component and the Windows 10 SDK. (MSVC C++ generation tool includes the entire compilation and linking tool chain and most function libraries and header files; Windows 10 SDK only provides other necessary library files and header files)
developer powershell for vs 2022
To follow INSTALL: Building the software on *NIX platforms using configure
then. Just run it.

Idea 3: Use Cygwin. (There are many similar ones. It just imitates Linux so I won’t go into details)

Idea 4: Use wsl, which is similar to Linux. Cross compilation is still required.

There are many instructions after INSTALL. Building the software on Windows with free compilers. Quite similar. I won’t say any more.

The summary is to strictly follow the documentation. Understand the differences between Linux and Windows. And know the commonalities of compilation.

During the writing process, I experimented with many Markdown formats. It can be considered as something gained.

I would also like to know for example how python code compiles into an executable file. This seems to require the use of pyinstaller, there is an article with instructions.

So be it. tired.

one more thing

A vertical progress bar without code is really annoying. tired.


  1. https://linux.cn/article-14033-1.html#:~:text=Specifically, you need a compiler. A compiler (such as GCC or LLVM) can turn source code like this: #include using,”hello world”; } into machine language, the instructions that the CPU uses to process information.