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

MSVC linking issue with std.zlib #306

Closed
CyberShadow opened this issue Mar 11, 2013 · 6 comments
Closed

MSVC linking issue with std.zlib #306

CyberShadow opened this issue Mar 11, 2013 · 6 comments
Labels

Comments

@CyberShadow
Copy link
Contributor

import etc.c.zlib;
void main() { deflateInit(null, 0); }

Output:

phobos-ldc.lib(inftrees.obj) : error LNK2019: unresolved external symbol __report_rangecheckfailure referenced in function inflate_table
test2.exe : fatal error LNK1120: 1 unresolved externals

(Using LDC.zip Kai posted here)

@redstar
Copy link
Member

redstar commented Mar 11, 2013

How did you compile it? I put the code into file zipbug.d and compiled it with ldc2 zipbug.d. It created a zipbug.exe without a problem.

@CyberShadow
Copy link
Contributor Author

The same way... Maybe it depends on the VC version?

@redstar
Copy link
Member

redstar commented May 9, 2013

Seems to depend on the VC version. I use VisualStudio 2012. I have a report that the link error occurs with the linker from VisualStudio 2008.
(inftrees.c is from the zlib source. Likely related to differnt CRTs.)

@DanKonigsbach
Copy link

In the Solution Explorer, look at the project that you're linking (not the library) and see if the entry is marked "(Visual Studio 2010)". If so, they you will have to choose between updating that project to Visual Studio 2012 (or later) or turning off compiler option /GS (Buffer Security Check) in that project and all of the libraries from which it pulls in code.

Normally in Visual Studio 2012, the linker uses the "Microsoft Visual Studio 11.0" C libraries. However, if your project is identified as "(Visual Studio 2010)", the linker uses the "Microsoft Visual Studio 10.0" instead.

In Visual Studio 2012 and later, the /GS option generates calls to __report_rangecheckfailure. (See http://blogs.msdn.com/b/sdl/archive/2012/01/26/enhancements-to-gs-in-visual-studio-11.aspx for a detailed description.) In the "Microsoft Visual Studio 11.0" libraries, __report_rangecheckfailure, is in msvcrt[d].lib, but it does not appear at all in the "Microsoft Visual Studio 10.0" libraries. Hence, a "(Visual Studio 2010)" project that uses code built with /GS under Visual Studio 2012 will get an unresolved external reference to __report_rangecheckfailure.

So, your choices are to upgrade your project to Visual Studio 2012 (from the main menu Project | Upgrade VC++ projects…) or to forgo compiler option /GS (in the project's Property Pages, select Configuration Properties | C/C++ | Code Generation, and set Buffer Security Check to No (/GS-).)

redstar pushed a commit that referenced this issue Sep 27, 2014
@kinke
Copy link
Member

kinke commented Oct 18, 2014

@redstar I guess this can be closed then.

@redstar
Copy link
Member

redstar commented Oct 19, 2014

Works in version 0.15.0.

@redstar redstar closed this as completed Oct 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants