BtbN / FFmpeg-Builds

MIT License
7.43k stars 1.03k forks source link

How did you compile third-party libraries as --enable-shared? #308

Closed huangjinshe closed 11 months ago

huangjinshe commented 11 months ago

I thought we only could compile static, then it could include some 3rd party libraries. but you could build it as shared and also could include some 3rd-part libraries. could you tell me how? thanks.

huangjinshe commented 11 months ago

When I build it in MingW32 as shared, the final dll files really small, it's good but when I click ffmpeg.exe it shows: xx.dll missing....(like zlib.dll or libfdk-aac.dll ....etc, they always installed in MingW32 by pacman command, the configuration and make command all normal , no error)

BtbN commented 11 months ago

By building them all as static libraries themselves. And cleaning out any shared remnants out of the toolchain. Leaves the linker no choice but to pick the static version.

huangjinshe commented 11 months ago

What I did was installe: mingw32/mingw-w64-i686-openh264 in MingW32, and then add command in configuration:

 --extra-cxxflags='-I/mingw32/include' --extra-ldflags='-L/mingw32/lib`

I thought this will search the .h file and .o file from those folders and compile with ffmpeg together, but turns out it's not. it will still throw error when running ffmpeg.exe: xx.dll missing.

BtbN commented 11 months ago

Not quite sure I follow. I literally build every single dependency manually, including the entire toolchain, specifically tuning it to produce binaries with a minimal set of external dependencies. It got little to do with flags you pass to ffmpeg configure.

huangjinshe commented 11 months ago

Wow...build every single dependency manually? that must be take a lot of time. Could you share them with us (the dependency source code you've already download)? then we could remove something we don't need.
I'm also thank you for answering me.

BtbN commented 11 months ago

You are right now looking at the repository with the entire set of scripts to do so. 90% of its contents deal with buildings the toolchain and dependencies.

huangjinshe commented 11 months ago

OK, I have last question, I did not found you link any 3rd party libraries in the command line from ffmpeg.exe, it just show --enable-xx or disable-xx, how did you let it automatically take the include and lib folder for compile the 3rd party libraries ?

BtbN commented 11 months ago

That's what configure does. It finds external libraries and figures out how to link them and where the headers are stored. Most of them are found via pkg-config, and a few just have hardcoded names.

huangjinshe commented 11 months ago

Thank you for telling me that. Obviously my configure did not do that for me..... looks like I need to check it again.

BtbN commented 11 months ago

That likely means your build environment is not properly set up. Missing pkg-config, mixing in packages for a different arch, and other things.

Any reason you don't just use the scripts provided here, if that's your goal anyway?

huangjinshe commented 11 months ago

To be honest I don't really understand how the scripts running which you provide, also I want to build it as Win32 x86 with less size ( remove some feature I don't need), so I don't think it's really suitable for me without customizing.

BtbN commented 11 months ago

Just delete the stuff you don't want from scripts.d and build away. That's all there is to it really.

huangjinshe commented 11 months ago

It would be really helpful if you could do some video tutorials for this. I have a lot of question when I first met this project, What is this? docker image? or what. How it is running. it required bash and docker? why? what bash do and docker? The ReadMe too simple in main page, simgple eough I don't know what is this. If I understand how it worked, I might already done it.

BtbN commented 11 months ago

All you have to do is run the makeimage.sh and build.sh with your desired variant after making your modifications. I don't see how a video tutorial would be at all useful for that. Just keep in mind that it doesn't work reliably on Windows with MinGW, so I'd strongly recommend running it in WSL.

And yes, you need working docker for this, since it's heavily used for the entire process. And bash is just what all the scripts are written for.

huangjinshe commented 11 months ago

So does that mean:

  1. I change some cusomized configure .
  2. I need to use bash create an docker image.
  3. Use docker run the image, then it's all will done by docker (we also could use -volume link the path for final ffmpeg output folder?

If that's it, this is a really really easy thing. Maybe I was thinking too complex before.

BtbN commented 11 months ago

The entire job of the scripts in this repo is to automate all that. Really, just delete the stuff you don't want from scripts.d, run makeimage.sh with your desired target, and then build.sh with the exact same one.

huangjinshe commented 11 months ago

Sure, I'll try. Thank you again.