-   Programming (
-   -   Linker Error (

dim79 06-27-2003 10:53 AM

Linker Error
Hello Friends,

I m facing problem while running Kylix Application
Following are the details:

I had downloaded Speex (Audio Codec) Library and installed it on my Linux (RedHat 7.2) machine.It got installed properly and library files (,, got installed in /usr/lib directory. Now i had specified all include nd library paths in Kylix. When i use "speex.h" (part of speex audio codec library) in my source code then my program gets complied successfully. But when i run the same program i get linker error exception as follows

[linker error] Unresolved external 'speex_bits_init' referenced from xyz.o

Here xyz.o is one of my project file and 'speex_bits_init' is a function (part of speex library) and i using many other functions like this from same library. Now i guess problem is Kylix is unable to load the speex library. I also tried setting environment variables like LD_LIBRARY_PATH etc. Still facing problem with linker error.

Can anyone help me out and let me know how to solve this linker error problem. I would be greateful to you.

Thanx in advance.


acid_kewpie 06-27-2003 11:00 AM

Please do not post the same thread in more than one forum. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.

Dark_Helmet 06-28-2003 09:53 AM

I don't have the greatest experience with linking to external libraries, but I'll give it a shot. From what I understand, setting LD_LIBRARY_PATH does not help except at runtime. You must manually tell the compiler to link the library in at compile-time. Take the math library for instance. Suppose I this source file:

#include <stdio.h>
#include <math.h>

int main()
  double value;
  double square_root;

  value = 16.0;

  square_root = sqrt(value);

  printf("The square root is: %f\n", value);

This command results in:
$ gcc -o do_sqrt do_sqrt.c
/tmp/ccmTGmHd.o: In function `main':
/tmp/ccmTGmHd.o(.text+0x28): undefined reference to `sqrt'
collect2: ld returned 1 exit status

Until I give the compiler the '-lm' command to link in the math library, it won't work. Similarly, I imagine you'll have to do something like:

gcc -o my_app -lspeex my_app.c

Again, I may be way off base, but that would seem logical to me.

All times are GMT -5. The time now is 01:45 AM.