Thread: Help Please!! - could not find -lgtk-2.0

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    9

    Exclamation Help Please!! - could not find -lgtk-2.0

    Hello, I'm having a problem when i build a project.
    It is the MyMarque example of the chapter 11 of gtk foundations of development.
    here is the log.


    -------------- Build: Debug in MyMarquee ---------------

    Linking console executable: bin\Debug\MyMarquee.exe
    C:\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\ mingw32\bin\ld.exe: could not find -lgtk-2.0
    collect2: ld returned 1 exit status
    Process terminated with status 1 (0 minutes, 0 seconds)
    0 errors, 0 warnings


    just for you to know, i use the gtk+ bundle 2.22.0 win32
    on windows 7 64 bit, and this is the first time i have problems with a project.
    i thought it was because something was missing, but it is not.
    may i need to configure something else in my project

    here is the configurations of the project:

    <Compiler>
    <Add option="-Wall" />
    <Add option="-mms-bitfields" />
    <Add directory="C:\Gtk\gtk-bundle\include" />
    <Add directory="C:\Gtk\gtk-bundle\include\gtk-2.0" />
    <Add directory="C:\Gtk\gtk-bundle\include\cairo" />
    <Add directory="C:\Gtk\gtk-bundle\include\gdk" />
    <Add directory="C:\Gtk\gtk-bundle\include\glib-2.0" />
    <Add directory="C:\Gtk\gtk-bundle\lib\glib-2.0\include" />
    <Add directory="C:\Gtk\gtk-bundle\include\pango-1.0" />
    <Add directory="C:\Gtk\gtk-bundle\lib\gtk-2.0\include" />
    <Add directory="C:\Gtk\gtk-bundle\include\atk-1.0" />
    <Add directory="C:\Gtk\gtk-bundle\include\gdk-pixbuf-2.0" />
    </Compiler>

    <Linker>
    <Add library="gtk-2.0" />
    <Add library="gobject-2.0" />
    <Add library="glib-2.0" />
    <Add directory="C:\Gtk\gtk-bundle\lib" />
    </Linker>


    Hope someone reads and have some time to show me solution
    =D

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Do you have a file called "libgtk-2.0.a" in the directory "C:\Gtk\gtk-bundle\lib"?

    I'm hoping that in the actual compilation the directories are added before the libraries. What happens if you do a make-clean and rebuild?

  3. #3
    Registered User
    Join Date
    Dec 2010
    Posts
    9
    Quote Originally Posted by tabstop View Post
    Do you have a file called "libgtk-2.0.a" in the directory "C:\Gtk\gtk-bundle\lib"?

    I'm hoping that in the actual compilation the directories are added before the libraries. What happens if you do a make-clean and rebuild?
    hi, i already made a clean and rebuild, it did not work.
    i have the file but on windows, libgtk-win32-2.0.dll.a
    i dont know what is the diference between them.
    a dll that is a library.... well, i have to read more about it.
    =P

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Then you need to call it "gtk-win32-2.0.dll" when you add it to your project.

  5. #5
    Registered User
    Join Date
    Dec 2010
    Posts
    9
    Quote Originally Posted by tabstop View Post
    Then you need to call it "gtk-win32-2.0.dll" when you add it to your project.
    hi, thanks for the answer...
    look, i am not an advanced c programmer... for example, it is a little difficult to me to understand well the libraries things on C, this is my first project with with dinamic libraries, and it is not mine, it is only an example of an introduction book... =P
    i am a java programmer, and C is a more difficult level schema for me.

    i added it on the build options of my project, i use code::blocks.

    i added the library to me project
    i tried with gtk-win32-2.0.dll and with libgtk-win32-2.0.dll.a
    but it just gave me the same problem.
    i just wanna remember that the directories are configured correctlly.

    the include:
    C:\Gtk\gtk-bundle\include

    and the lib:
    C:\Gtk\gtk-bundle\lib


    may be i am missing something, but as far as a read about importing libraries, i think it is configured OK.

    i just killed my debian by trying install my vga card drivers, and i did not have the time to solve it. so i have to make this on windows 7.
    may be it is not working ok or I have to make some mandrake moves to make it run.
    i hope you can make it for me.

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    I have no idea if those are the right paths. The right paths are "wherever you installed them on your system", so if those paths exist and include the headers (for /include) and the library files (for /lib) then that's what you should have.

    When you specify a library with -l in GCC it automatically adds "lib" in front and either ".a" or ".so" at the end (generally speaking, ".a" = static library and ".so" = dynamic library) so whatever file you have, take off the lib at the front and the .a/.so at the end and that's the name of the library.

  7. #7
    Registered User
    Join Date
    Dec 2010
    Posts
    9
    Quote Originally Posted by tabstop View Post
    I have no idea if those are the right paths. The right paths are "wherever you installed them on your system", so if those paths exist and include the headers (for /include) and the library files (for /lib) then that's what you should have.

    When you specify a library with -l in GCC it automatically adds "lib" in front and either ".a" or ".so" at the end (generally speaking, ".a" = static library and ".so" = dynamic library) so whatever file you have, take off the lib at the front and the .a/.so at the end and that's the name of the library.
    but i think i did it correctly, it still gave me an message, this time it says this.

    Compiling: mymarquee.c
    mingw32-gcc.exe: -l-O2: linker input file unused because linking not done
    Compiling: main.c
    mingw32-gcc.exe: -l-O2: linker input file unused because linking not done
    Linking executable: bin\Release\MyMarquee.exe
    C:\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\ mingw32\bin\ld.exe: could not find -lgtk-2.0
    collect2: ld returned 1 exit status
    Process terminated with status 1 (0 minutes, 2 seconds)
    0 errors, 0 warnings


    here are the links of some screenshots i took to show how i configure the project.
    to save more time reading from a text, and there one of the path where i installed the gtk too.

    http://img593.imageshack.us/img593/5...inkersetti.jpg
    http://img3.imageshack.us/img3/9173/...ngsotherop.jpg
    http://img31.imageshack.us/img31/9154/gtkdir.jpg
    http://img534.imageshack.us/img534/4...ptionslink.jpg
    http://img63.imageshack.us/img63/746...ptionssear.jpg
    http://img191.imageshack.us/img191/7...ptionssear.jpg



    thank for giving your opinion, now i now what is the difference between .a and .so
    and how the compiler works with the -l flag.

  8. #8
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    If the file is called "libgtk-win32-2.0.dll.a", then the library is called "gtk-win32-2.0.dll", which is what you need to link with.

  9. #9
    Registered User
    Join Date
    Dec 2010
    Posts
    9
    Quote Originally Posted by tabstop View Post
    If the file is called "libgtk-win32-2.0.dll.a", then the library is called "gtk-win32-2.0.dll", which is what you need to link with.
    now i understand how it works.
    the message "could not find -lgtk-2.0" means that, the compiler searched in the directory PATH/lib the file (-l gtk-2.0) where
    the -l appends the "lib" so, it looked up for "libgtk-2.0", and that file dont exist in that directory, because it windows the lib's
    name is gtk-win32-2.0, so to solve that problem, i have to change the name of the library on the project options, the name of the library
    must be gtk-win32-2.0 and not gtk-2.0.
    i did not understood what i read about c projects until you explain me what does the compiler do when it find the -l flag.
    now i am on my work, and i made the changes on it, it is working, but now i have a runtime error.
    i dont know what it is, but i will find out, an error on the the aplication.

    thanks for the patience.

  10. #10
    Registered User
    Join Date
    Dec 2010
    Posts
    9
    Quote Originally Posted by luisvaldes88 View Post

    -------------- Build: Debug in MyMarquee ---------------

    Linking console executable: bin\Debug\MyMarquee.exe
    C:\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\ mingw32\bin\ld.exe: could not find -lgtk-2.0
    collect2: ld returned 1 exit status
    Process terminated with status 1 (0 minutes, 0 seconds)
    0 errors, 0 warnings


    <Linker>
    <Add library="gtk-2.0" /> here is the problem!!!!!!
    <Add library="gobject-2.0" />
    <Add library="glib-2.0" />
    <Add directory="C:\Gtk\gtk-bundle\lib" />
    </Linker> [/COLOR]

    Hope someone reads and have some time to show me solution
    =D
    <Linker>
    <Add library="gtk-win32-2.0" /> the correct lib
    <Add library="gobject-2.0" />
    <Add library="glib-2.0" />
    <Add directory="C:\Gtk\gtk-bundle\lib" />
    </Linker>

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. How to find O of threads ?
    By jabka in forum C Programming
    Replies: 3
    Last Post: 03-11-2008, 12:25 PM
  3. migrate from .Net 2.0 to .Net 3.0
    By George2 in forum C# Programming
    Replies: 3
    Last Post: 07-25-2007, 04:07 AM
  4. how do u find 2nd largest number??
    By juancardenas in forum C Programming
    Replies: 8
    Last Post: 02-14-2003, 08:28 AM
  5. Q: Recursion to find all paths of a maze
    By reti in forum C Programming
    Replies: 7
    Last Post: 11-26-2002, 09:28 AM