8

I've installed Eclipse CDT so I'll be able to write and compile C code.

The compilation progress fails and the following error appears:

LNK1104 : cannot open file kernel32.lib

I've been searching for this file in my computer and found out it appears in some folders,

C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib

How could I "refer" eclipse to one of this certain paths so the kernel32.lib file will be found and I'll be able to compile and run C files?

EDIT Thanks to @mux answer the LNK1104 : cannot open file kernel32.lib is now gone , but a new error appears now : LNK1104 : cannot open file 'C:\Program.lib' . Once again, any suggestion will be helpful.

Keith Thompson
  • 254,901
  • 44
  • 429
  • 631
Itamar
  • 524
  • 1
  • 9
  • 21

5 Answers5

11

i wasted a lot of time on this... this is the answer you are searching for

In Eclipse > Project > Properties > Paths and Symbols > Libraries tab, enclose the path to the library in single quotes:

'C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\Kernel32.Lib'

There would be a warning that the path does not exist, but it should be gone after you rebuild your project.

Shivendra
  • 1,542
  • 2
  • 22
  • 35
7

I've the same problem, I've fixed because of installed Microsoft Visual Studio 2010 on my computer:

  1. Right click on your C/C++ project -> Properties -> C/C++ Build -> Environment
  2. In LIB, click on the Button Edit on the right side
  3. Add ;C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib <---- ; to separate the first auto detected path"

* Must be on the both Debug and Release configuration : else you'll get the same error *

lolando
  • 1,721
  • 1
  • 18
  • 22
naoufelabs
  • 133
  • 3
  • 9
2

you need to add the path to the library to your project, from the FAQ

Go to Your Project's Properties by right clicking on project's name and selecting properties. Click on "C/C++ Build". Under Tool Settings Tab, click on Directories. Click on The Add Button and Select FileSystem. Select the folder with C/C++ libraries. Apply and then Ok. The new library is included.

Edit:

The wiki seems outdated, but I did find the options relevant to linking here:

C/C++ Build->Settings->Tool Settings tab

you should add the include paths for headers (if any) to the compiler Includes and the libraries to the linker options Libraries(-l) and the library path to Library Search path (-L)

iabdalkader
  • 17,009
  • 4
  • 47
  • 74
  • A quote would make your answer a lot better. – Kiril Kirov Oct 30 '12 at 09:31
  • The problem is that there isn't any "Tool Settings" tab under C/C++ Build ( I use eclipse indigo ) @mux – Itamar Oct 30 '12 at 09:38
  • @mux , thanks for the answer, the kernel32.lib error is now gone , but a new error came up : now 'C:\Program.obj' is missing. any ideas ? Thanks again – Itamar Oct 30 '12 at 09:59
0

Go to:
"Project Properties>c/c++ Build>Settings>c++ Linker>Libraries"
Add library kernel32 and set search path to your library or set LIBRARY_PATH environment variable.

LucianMLI
  • 183
  • 1
  • 11
0

For "LNK1104 : cannot open file kernel32.lib" error you need to include path to kernel32.lib in Eclipse > Project > Properties > Paths and Symbols > Libraries tab

For LNK1104: cannot open file 'C:\Program.obj' error you need to make sure the path you provided earlier is inside single quote('). Reference

Hope this solves your problem.

Community
  • 1
  • 1
saha
  • 97
  • 8