Thread: Locate library files for functions that are undefined referenced to

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    159

    Locate library files for functions that are undefined referenced to

    Hi,
    I often miss this or that when specifying library files used in my program, resulting in some functions undefined referenced to during linking. This still happens even when I use "gcc `pkg-config --cflags --libs libraryname` -o my-prgm my-prgm.c" or look up in some documents of the library. The latter often makes me lost and suspect if I am too stupid to find the info I need. I believe this by no means only happens to me. So what's your strategy or tricks to locate the library files you need?
    Thanks in advance!

  2. #2
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    937
    -lname indicates that the linker knows where to find a file called libname.lib, or libname.a, or libname.whatever

    Do a search for those files. I suppose, from your code, that you'd be looking for liblibraryname.*
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    What that means is that you need to know what library the function is in. To use the example from your last thread, not all GTK functions are in glib. Some are in gthread, some are in gmodule, etc. I don't know if GTK has their act together enough to have man pages; if so, that's ideal -- just do "man functionname" and it will tell you what library the function is in. Otherwise you'll have to check the docs that came with the library you're trying to use.

  4. #4
    Registered User
    Join Date
    Jan 2009
    Posts
    159
    What I meant to ask is, given a function that is undefined referenced to, which library file to link not where a specific library file is. A library usually can have several library files. Unfortunately several libraries by default may have their library files stored under the same directory. This make me feel hard to not miss single library file, even though I know they are stored under which directory and even use pkg-config as "gcc `pkg-config --cflags --libs libraryname` -o my-prgm my-prgm.c".

    Is it always true that a library normally have some part in their document telling which library file is associated with which functions?

    How do you know which library file to link for a given function?

  5. #5
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by lehe View Post
    Is it always true that a library normally have some part in their document telling which library file is associated with which functions?
    Yes. Otherwise it is, as you noted, impossible to use the library.

  6. #6
    Registered User
    Join Date
    Jan 2009
    Posts
    159
    Thanks tabstop! I am trying to get the man page.

  7. #7
    Registered User
    Join Date
    Jan 2009
    Posts
    159
    Now my questions become: generally, how to install the man page of a library and how to use it if it is installed?

    For example, if I have built and installed two libraries libjpeg and libpng on my system. Whenever I type "man libpng", I will get an overview of this library, but I don't know how to get the description for one of its functions. When I type "man libjpeg", I get nothing except "No manual entry for libjpeg".

    Thank you!

  8. #8
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    man libpng is long, really really long, so everything might be in there, somewhere (I didn't read much of it). If you get to the bottom you can see what other man pages are associated. I don't have man libjpeg on my system either, but Google does. (It only has a Sun version, so the maintainers of the library may not have converted the docs into man format. And given that no one appears to have done much with it since 1998? Probably not going to get added either.)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 10-09-2007, 02:37 PM
  2. Replies: 1
    Last Post: 06-24-2005, 09:45 AM
  3. Replies: 4
    Last Post: 11-12-2002, 06:26 AM
  4. odd errors from msvc std library files
    By blight2c in forum C++ Programming
    Replies: 6
    Last Post: 04-30-2002, 12:06 AM
  5. Replies: 0
    Last Post: 01-07-2002, 05:08 PM