Thread: gcc compiling and linking problem

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    136

    Question gcc compiling and linking problem

    Hi all,

    I am facing a problem in creating an executable.

    My code compiles fine but while linking with a static library it says undefined reference to "fuctionname".
    Where as instead of creating executable if i am creating a shared library of it then it works fine (i don’t know it will run fine or not, but compiling and creation of .so goes fine).

    Could you help me out of this problem?

    I have heard that shared libraries are permitted to have undefined references. Is it true?

    Thanks in advance.
    S_ccess is waiting for u. Go Ahead, put u there.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    A .so doesn't require all symbols to be resolved, so I'd guess that it simply hides the actual problem until you try to RUN the application that links to the .so.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Dec 2005
    Posts
    136
    ok, thanks for sharing the information.
    I will run the application and see the possible results.

    Any other information will also be appreciable.
    S_ccess is waiting for u. Go Ahead, put u there.

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    It would also help if you let us know what the symbol that is undefined is. One of your symbols, something from the C library, or... ?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Dec 2005
    Posts
    136
    It is from some third party library.
    I am trying to resolve, i will update you once i am done.
    S_ccess is waiting for u. Go Ahead, put u there.

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by maven View Post
    It is from some third party library.
    I am trying to resolve, i will update you once i am done.
    So maybe you need to link your library with that third party library?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User
    Join Date
    Dec 2005
    Posts
    136
    It is solved.

    I was compiling my code with the library only. But there were few conditional comiplation in libarary code, which needs to be configure in a header file. When i compiled the library code with proper configuration then it worked fine.

    By the way, thanks a lot matsp for nice informations!
    S_ccess is waiting for u. Go Ahead, put u there.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Problem Compiling
    By Flakster in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 01:09 AM
  3. Grrr.... SDL Linking Problem
    By 7EVEN in forum Game Programming
    Replies: 5
    Last Post: 08-12-2005, 08:44 PM
  4. simple compiling problem
    By waxydock in forum C++ Programming
    Replies: 2
    Last Post: 03-26-2005, 10:33 AM
  5. gcc 3.2 & linking
    By rotis23 in forum Linux Programming
    Replies: 1
    Last Post: 06-23-2003, 06:46 AM