How to link external library

Alvin Beach abeach at deepvision.ca
Tue Mar 8 13:48:40 GMT 2005


On March 8, 2005 08:20 am, Petr Hlozek wrote:
> Dne út 8. března 2005 00:15 Alvin Beach napsal(a):
> > On March 7, 2005 05:01 pm, Petr Hlozek wrote:
> > > #include <hamlib/rigclass.h>
> > > int main(int argc, char *argv[])
> > > {
> > > 	Rig myRig = Rig(RIG_MODEL_DUMMY);
> > >
> > > 	try {
> > > 		myRig.open();
> > >
> > > The problem is that compiler doesn't find declaration of class Rig.
> > > This declaration is in rigclass.h. This file is in /usr/include/hamlib.
> > > Could you help me how to make "visible" declaration of Rig for
> > > compiler? I spend with this long time without succes.
> >
> > You need to specify the hamlib library in the Automanager. Open the
> > Automake manager on the right. Right click on the binary and select
> > Options. In the Libraries tab add -l<name of hamlib library> (e.g.
> > -lhamlib).
>
> Thanks for help but it still doesn't work. I added library to Link
> libraries outsite the project. I added -lhamlib.
> I got:
>
> if g++ -DHAVE_CONFIG_H -I. -I/home/ok2cqr/kdevelop/hamradio/src -I.. -O0
> -g3 -MT hamradio.o -MD -MP -MF ".deps/hamradio.Tpo" -c -o
> hamradio.o /home/ok2cqr/kdevelop/hamradio/src/hamradio.cpp; then mv -f
> ".deps/hamradio.Tpo" ".deps/hamradio.Po"; else rm -f ".deps/hamradio.Tpo";
> exit 1; fi
> /bin/sh ../libtool --mode=link g++ -O0 -g3 -o hamradio hamradio.o -lhamlib
> mkdir .libs
> g++ -O0 -g3 -o hamradio hamradio.o /usr/lib/libhamlib.so -ldl -lm
> hamradio.o(.text+0x12b): In function `main':
> /home/ok2cqr/kdevelop/hamradio/src/hamradio.cpp:36: undefined reference to
> `Rig::Rig(int)'
> hamradio.o(.text+0x13a):/home/ok2cqr/kdevelop/hamradio/src/hamradio.cpp:39:
> undefined reference to `Rig::open()'
>
> I tried Build->Clean project and run Automake + configure + build again.
> Still nothing. :-(.
> Any idea?

Hmmm, looks like it found the library as I don't see any "hamlib not found" 
messages. Does hamlib define a namespace? If so, you may need to add "using 
namespace XXX;" where XXX is hamlib's namespace.

This is just a shot in the dark.

-- 
Alvin
Please reply to only this mailing-list. Thanks.

-
to unsubscribe from this list send an email to kdevelop-request at kdevelop.org with the following body:
unsubscribe ťyour-email-addressŤ



More information about the KDevelop mailing list