undefined reference error

This is a discussion on undefined reference error within the C Programming forums, part of the General Programming Boards category; Dear all , I have one shared library in "/usr/lib/ast/mod/quad.so" where the functions "X1" and "X2" are defined. In header ...

  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    2

    undefined reference error

    Dear all ,
    I have one shared library in "/usr/lib/ast/mod/quad.so"
    where the functions "X1" and "X2" are defined.
    In header file "quad.h" it is declared.
    I have created a "test.c" where X1 and X2 are called
    I have used the following commads for compiling and linking

    #gcc -c test.c
    #gcc -o test.o -L. -Wl,-rpath,/usr/lib/ast/mod/quad.so
    i am getting the error:
    undefined reference to X1
    undefined refernece yo X2

    what all things i have to do to make a proper linking

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    According to the manual, rpath specifies a directory, not a file. Also, you probably don't want test.o to be the output, but the input. I don't remember right now whether the linker needs any special hints about .so files; I would start with
    Code:
    gcc -o test test.o /usr/lib/ast/mod/quad.so
    (since you can put however many input files on a line as you want), and then maybe add a -R linker option if necessary.

  3. #3
    Registered User
    Join Date
    Dec 2008
    Posts
    2
    thank u for ur reply.. i tried that earlier but so may undefined reference errors are coming then .that is why i used -L. option .when it is giving only the function which i called from main program is showing undefined reference errors

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Undefined references to what? Do you have other libraries you need to link in, or something?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 02:17 PM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. using c++ in c code
    By hannibar in forum C Programming
    Replies: 17
    Last Post: 10-28-2005, 10:09 PM
  4. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 05:27 AM
  5. qt help
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 04-20-2002, 10:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21