Log in

View Full Version : How to make a static build of MediaInfo (no DLL)


LoRd_MuldeR
4th June 2009, 16:36
Hi. I try to make a static build of MediaInfo (the CLI version) that doesn't rely on an external "MediaInfo.DLL" file.

What I did so far is:
1. I built the static library (MediaInfo.lib) file. This seems to have succeeded, although the file seems pretty small. Only 128 KB. The DLL is much bigger!
2. In the MediaInfo CLI project I replaced the "MEDIAINFO_DLL" preprocessor definition with "MEDIAINFO_STATIC"
3. Furthermore I added "MediaInfo.lib" to additional dependencies in the Linker section and I added the required include directory to the Linker.

What I get is this:
1>Linking...
1>Core.obj : error LNK2001: unresolved external symbol __imp__MediaInfoList_Delete@4
1>Core.obj : error LNK2001: unresolved external symbol __imp__MediaInfoList_New@0
1>Core.obj : error LNK2001: unresolved external symbol __imp__MediaInfoList_Open@12
1>Core.obj : error LNK2001: unresolved external symbol __imp__MediaInfoList_Get@28
1>Core.obj : error LNK2001: unresolved external symbol __imp__MediaInfoList_Close@8
1>Core.obj : error LNK2001: unresolved external symbol __imp__MediaInfoList_Inform@12
1>Core.obj : error LNK2001: unresolved external symbol __imp__MediaInfoList_Option@12
1>Win32\Release\MediaInfo.exe : fatal error LNK1120: 7 unresolved externals

Any ideas? I'm on VS2008 and I use the project files provided by MediaInfo. Building the shared CLI version works fine :confused:

Kurtnoise
4th June 2009, 17:20
why would you do that ? Anyway, you should ask this directly to Zenitram in the SF forum...

2/ you don't need to do that. Just remove "MEDIAINFO_DLL".
1/ & 3/ dunno why. Did you use the trunk version ?

btw, Here is a static build (http://www.mediafire.com/?wzhgmdv01yz).

LoRd_MuldeR
4th June 2009, 17:31
why would you do that ?

...because my tool LameXP uses MediaInfo. It uses various CLI tools, but MediaInfo is the only one that needs an additional DLL. That's why I'd prefer a statically linked build ;)

1/ & 3/ dunno why. Did you use the trunk version ?

I used the v0.7.16 release version.

btw, Here is a static build.

Thank you! Did you make that build? If so, any hints on what you did? If not, where did you find it?

Kurtnoise
4th June 2009, 17:39
Did you make that build?
yes I did...0.7.17 beta. Check the version. ;)

If so, any hints on what you did?
I removed MEDIAINFO_DLL in the Preprocessor settings, added MediaInfo.lib as additional dependancies in the Linker settings, added Zlib.lib as additional dependancies in the MediaInfoLib project.

LoRd_MuldeR
4th June 2009, 17:48
yes I did...0.7.17 beta. Check the version. ;)

I noticed the version. But it didn't say who had built it :D

I removed MEDIAINFO_DLL in the Preprocessor settings, added MediaInfo.lib as additional dependancies in the Linker settings, added Zlib.lib as additional dependancies in the MediaInfoLib project.

Ah, nice :)

I added "zlib.lib" to the linker, removed the "MEDIAINFO_STATIC" definition and it worked! That definition obviously made the linker fail :rolleyes:

:thanks:

Zenitram
5th June 2009, 10:04
I don't read all the forums in the world, so the best way is to use the MediaInfo forum.
Anyway:

2. In the MediaInfo CLI project I replaced the "MEDIAINFO_DLL" preprocessor definition with "MEDIAINFO_STATIC"

static libs are not provided because of the different possibilities with the Microsoft C/C++ libraries (shared/static, Debug/Release...), but if you work with static libs, you can without too much problem compile the MediaInfo.lib static.

Kurnoise has made what is the best.
MEDIAINFO_STATIC is maybe not the best #define, it does NOT mean you will have only one file at the end, but that the DLL will be staticly linked to the program.
- MEDIAINFO_DLL --> Load at runtime, the program can run even without the DLL (optional DLL)
- MEDIAINFO_STATIC --> Load before the program runs, the program can't be launched without the DLL.
- (nothing) static link, no DLL.

I will try to provide a better documentation about this.

LoRd_MuldeR
5th June 2009, 21:05
I don't read all the forums in the world, so the best way is to use the MediaInfo forum.
Anyway:



static libs are not provided because of the different possibilities with the Microsoft C/C++ libraries (shared/static, Debug/Release...), but if you work with static libs, you can without too much problem compile the MediaInfo.lib static.

Kurnoise has made what is the best.
MEDIAINFO_STATIC is maybe not the best #define, it does NOT mean you will have only one file at the end, but that the DLL will be staticly linked to the program.
- MEDIAINFO_DLL --> Load at runtime, the program can run even without the DLL (optional DLL)
- MEDIAINFO_STATIC --> Load before the program runs, the program can't be launched without the DLL.
- (nothing) static link, no DLL.

I will try to provide a better documentation about this.

Thank you for the info! In the meantime I got what I needed. I wrongly used MEDIAINFO_STATIC indeed.

Probably better names would be "MEDIAINFO_DLL_RUNTIME", "MEDIAINFO_DLL_STATIC" and "MEDIAINFO_DLL_NONE", with the latter being used if none is defined.

Keep up the great work :thanks:

(BTW: My next step would have been to look for help at the MediaInfo forum)

Zenitram
14th June 2009, 14:27
Probably better names would be "MEDIAINFO_DLL_RUNTIME", "MEDIAINFO_DLL_STATIC" and "MEDIAINFO_DLL_NONE", with the latter being used if none is defined.

I replaced, for next version or already in SVN, MEDIAINFO_DLL and MEDIAINFO_STATIC for more explicit MEDIAINFO_DLL_RUNTIME and MEDIAINFO_DLL_STATIC
(no need of definition for no DLL, this is the default)

LoRd_MuldeR
14th June 2009, 15:16
I replaced, for next version or already in SVN, MEDIAINFO_DLL and MEDIAINFO_STATIC for more explicit MEDIAINFO_DLL_RUNTIME and MEDIAINFO_DLL_STATIC
(no need of definition for no DLL, this is the default)

Nice :thanks:

By the way: May I ask why you provide only "Runtime DLL" builds of the CLI version? Wouldn't "static" builds be more idiot-proof ???

Zenitram
14th June 2009, 15:24
By the way: May I ask why you provide only "Runtime DLL" builds of the CLI version? Wouldn't "static" builds be more idiot-proof ???

If I listen everyone, I would do ~1000 different packages (and even more for the GUI ;-) )
Some people prefer the DLL version, some other prefer a static link, some other want a light package even when they merge CLI and GUI (1 DLL, too light interfaces).
I do the quicker for me (compilation of 1 DLL, and 2 interfaces beside), and an exe + dll is usualy not a problem (both files are packaged in the third-party installer, or more typical only the DLL is packaged, and the third-party tool call directly the DLL)

LoRd_MuldeR
14th June 2009, 15:31
I see the reason why a DLL can be helpful when using two interfaces in parallel. But I think the majority of people will either use CLI or GUI. Or they build a custom GUI, either on top of the DLL or the CLI.

Personally I prefer statically linked binaries. The less dependencies, the less can go wrong and the more "portable" your application is.

But it's your decision of course. Now that my initial problem was solved it's not too much work for me to make a static build of Mediainfo.exe myself. So that's perfectly fine for me...