Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using zlib and freetype static libraries causes LNK2005/LNK4006 #13

Closed
blackandwhitebg opened this issue Feb 25, 2023 · 3 comments
Closed

Comments

@blackandwhitebg
Copy link

Hi,
When linking both lib files (freetype.lib and zlib.lib) from a single project, I get errors because parts of zlib are integrated in freetype.lib:

1>zlib.lib(inflate.obj) : warning LNK4006: inflateEnd already defined in freetype.lib(ftgzip.obj); second definition ignored
1>zlib.lib(inflate.obj) : warning LNK4006: inflate already defined in freetype.lib(ftgzip.obj); second definition ignored
1>zlib.lib(inflate.obj) : warning LNK4006: inflateInit2_ already defined in freetype.lib(ftgzip.obj); second definition ignored
1>zlib.lib(inflate.obj) : warning LNK4006: inflateReset2 already defined in freetype.lib(ftgzip.obj); second definition ignored
1>zlib.lib(inflate.obj) : warning LNK4006: inflateReset already defined in freetype.lib(ftgzip.obj); second definition ignored
1>zlib.lib(inflate.obj) : warning LNK4006: inflateResetKeep already defined in freetype.lib(ftgzip.obj); second definition ignored

I found a workaround, which is compiling with /FORCE:MULTIPLE.
Is there a cleaner way to solve the problem?
Thank you

@blackandwhitebg blackandwhitebg changed the title Using freetype and zlib causes LNK4006 error Using freetype and zlib causes LNK2005/LNK4006 Feb 25, 2023
@ubawurinna
Copy link
Owner

/FORCE:MULTIPLE will only hide the problem. Your application might crash unexpectedly if the wrong function is called.
A simple way to solve the problem is to use the import library and dll in the release dll folder, because in this case the inflatexxx functions are not exported.

@ubawurinna ubawurinna changed the title Using freetype and zlib causes LNK2005/LNK4006 Using zlib and freetype static libraries causes LNK2005/LNK4006 Feb 28, 2023
@ubawurinna
Copy link
Owner

ubawurinna commented Feb 28, 2023

It seems to be a bug in the freetype sources when compiling static libraries under Windows.
I modified the source and now the zlib functions are not exported anymore.

@blackandwhitebg Can you try the libraries in commit 7e8053a ?

@blackandwhitebg
Copy link
Author

Thank you for your response.
Yes, this works. The issue can be closed.

(Since using the lib is most likely the preferred way for people who don't want any external dependencies, I would only add a suggestion for future releases to include different libs with /MT and /MD compilations, so whoever wants just a single executable, not depending on anything else at all can use the /MT compilation)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants