Re: includes and binary code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 17 Dec 2004 19:24:53 +0100, soraberri <421246@xxxxxxxxxxxxxxx> wrote:
> I think my problem is a concept failure:
> When I include in my programs a #include <afile.h> I am telling the
> compiler to look for afile.h and paste the code in my program. So far so
> good. But the header file usually only holds definitions and not the
> implementation of the functions, so what I don't understand is how can
> the system (compiler) know where and how to find the library or the
> piece of binary code that actually implements the functions defined in
> the afile.h

You have to tell it.  Some things are linked automatically as the
compiler (actually the linker) already knows where they are.  Other
things you have to tell the linker where the binary files are. 
Usually this is done through some options passed to gcc in a Makefile.
 I believe the options are -l <library> and -L <dir>, where <library>
is a specific library (binary) to like with and <dir> is a path to
look in.

> All this comes because trying to compile some application I get the
> following errors:
> /home/soraberri/Desarrollo/estudioC/estudio_l2test/src/estudio_l2test.c:231:
> undefined reference to `strtoba'
> estudio_l2test.o(.text+0x680):/home/soraberri/Desarrollo/estudioC/estudio_l2test/src/estudio_l2test.c:231:
> undefined reference to `baswap'
> /home/soraberri/Desarrollo/estudioC/estudio_l2test/src/estudio_l2test.c:337:
> undefined reference to `baswap'
> estudio_l2test.o(.text+0xb54):/home/soraberri/Desarrollo/estudioC/estudio_l2test/src/estudio_l2test.c:338:
> undefined reference to `batostr'
> /home/soraberri/Desarrollo/estudioC/estudio_l2test/src/estudio_l2test.c:652:
> undefined reference to `hci_devba'
> estudio_l2test.o(.text+0x14df):/home/soraberri/Desarrollo/estudioC/estudio_l2test/src/estudio_l2test.c:654:
> undefined reference to `str2ba'

This is the linker complaining that it cannot find the actual binary
code for the specified functions.  You need to figure out the
libraries that define these functions and link to them.

> All this functions are actually defined in
> /usr/include/bluetooth/bluetooth.h
> and in the program I try to compile there is this line:
> #include <bluetooth/bluetooth.h>
> 
> I hope this is a very simple question for you
> 
> regards
> 

I don't have those files, so you obviously have some bluetooth stuff
installed that I don't.

Jonathan


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux