Eclipse can't link to kernel32.lib

14,086

Solution 1

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.

Solution 2

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 *

Solution 3

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)

Share:
14,086
Itamar
Author by

Itamar

My name is Itamar , I'm mostly interested in PHP, MySql and jQuery, always willing to be exposed to new programming languages and attitudes.

Updated on August 03, 2022

Comments

  • Itamar
    Itamar almost 2 years

    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.

  • Kiril Kirov
    Kiril Kirov over 11 years
    A quote would make your answer a lot better.
  • Itamar
    Itamar over 11 years
    The problem is that there isn't any "Tool Settings" tab under C/C++ Build ( I use eclipse indigo ) @mux
  • Itamar
    Itamar over 11 years
    @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