lnk1104: cannot open 'LIBC.lib' LINK [closed]
Asked Answered
E

3

7

After writing a shader using GLee to my OpenGL project and compiling, I received the error LNK1104: cannot open file 'LIBC.lib'. I've tried adding it and ignoring it as others suggested, but not nothing resolved the issue. Is there an alternative way to solve this that I've missed?

Eldenelder answered 12/4, 2013 at 7:42 Comment(0)
P
21

Here are several possible solutions:

  1. This may due to code generation conflict. If your libc.lib's thread support is different then your project's settings, this may be causing the problem. If so, right click project, then go to properties->C++->code generation->Runtime Library and change the value to Multi-threaded(MT).

  2. Your libc.lib may not support multi threading. Right click project, then go to properties->Linker->Input->Additional Dependencies and change libc.lib to libcmt.lib

  3. Your application statically link multiple copies of the same library. Right click project, then go to properties->Linker->Input->Ignore Specific Library and add libc.lib

  4. Maybe your project needs this lib, but your system doesn't have it. In that case, you have to download the .lib file from Microsoft and add the path of where you downloaded it by right clicking project, then going to properties->Linker->General->Additional Library directories.

Preference answered 12/4, 2013 at 8:23 Comment(1)
Thanks for the insight. My runtime library was set to (MD). Searched Runtime Library documentation and found msvcrtd.lib and added it to the library dependencies along with ignoring LIBC.lib. Now my program compiles like it's suppose to again.Eldenelder
A
3

I had this problem in MS VC++ 2012 Express with Windows SDK 7.1.

I found this solution from the DISLIN developers :

  (i) in MS VC++\Project\<YourProject> Properties pull-down...
 (ii) <YourProject>Property Pages\Ignore Specific Default Libraries : libc.lib
(iii) <YourProject>Property Pages\Additional Dependencies\Edit : libcmt.lib

Bingo!

Argeliaargent answered 10/6, 2016 at 13:55 Comment(0)
D
0

Solution in two steps:

Step 1: Include the Microsoft Visual legacy library called legacy_stdio_definitions.lib in your project: Either add it to "properties>Linker>Input>Additional Dependencies" or add this directive to your header #pragma comment(lib, "legacy_stdio_definitions.lib") Either way is fine.

Step 2: Ask the linker to ignore LIBC.lib, which is coded as requirement inside your imported modules, using this Directive #pragma comment(linker, "/NODEFAULTLIB:LIBC.lib") . This would be like promissing the linker that you will provide the symbols it wants from LIBC.lib elsewhere, i.e. legacy_stdio_definitions.lib.

For those of you who are curious why ? The standard C runtime (CRT) library is a mere docuement ( or The official paid ISO version of it) that provides the specifications of what a CRT librairie must be like. Then, compilers try to develop their own implementations of the document that satisfy these specifications so that they can be considered "standard C Runtime Libraries". One of these compilers is MSVC, made by Microsoft, which is the one you are using under Microsoft Visual Studio Plateform. You, me and many others use the Microst implementations of the docuemnt above(chapter 7), which are libc.lib as a single-thread static implementation, libcmt.lib as a multi-thread static implementation, and msvcrt as a multi-thread dynamic implementation (for the record, MSVC has never had a single-thread dynamic implementation because it doesn't have some promissing performance). After, back in 2015, Microsoft introduced two new implementations: universal crt (ucrt) that can be used by other compilers, and its MSVC-specific parallel counterpart vcruntime. Both have replaced all the previous ones (i.e. libc, libcmt, msvcrt) and covered all needs for static and dynamic linking.

The time line for CRT libraries and their routines that one may need to take note of with regard to our question is the following:

Static libs:

  • 1993: Introduction of the first version of Libc.lib.
  • 2003: Release of the last version of libc.lib. No more new versions afterward of single-thread crt on visual studio platform.
  • 2005: Release of libcmt.lib, and complete suppression of libc.lib from the visual studio plateform. Most of the symbols exported by LIBC.lib are present on libcmt, but some are deprecated like sprintf, strcpy and so that became sprintf_s, strcpy_s and so on.
  • 2013-2015: Introduction of the new implementation, universal crt and its MSVC-specific parallel counterpart vcruntime. These CRTs replaced the libcmt.lib and msvcrt.lib, but this time didn't suppress them for backward compatibility reasons. That's why you find the options /MT /MTD, MDd inside "properties>C/C++>Code Generation". Plus, legacy_stdio_definitions.lib got introduced, which enabled us to 'redirect' the deprecated symbols to the supported ones without refactoring our source code. This legacy lib also fills the gap with libc.lib that libcmt didn't, such as adding the symbols for the deprecated sprintf and sscanf and so.

Dynamic libs:

  • 1994: Introduction of the first version of msvcrt.lib (import library, not as static one).

  • 2003: Release of the famous msvcr71.dll that got the name from visual studio 7.1 that was released also in 2003.

  • 2005: The release of msvcr80.dll, which deprecated different symbols used to be present on msvcr71.dll.

  • 2013-2015: The same as in the static lib case herewith.

Dunn answered 21/8, 2024 at 15:54 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.