[LC++]Linkinkg with my own library

Boszormenyi Laszlo boszorme at mazsola.iit.uni-miskolc.hu
Thu Aug 2 00:01:38 UTC 2001


Hi!

 As I would like to answer all of the three helps, I included them in this
letter.

On Wed, 1 Aug 2001, John F. Dumas wrote:

>    Ok, so you've made a shared library 'libWebhelper.so' and you're trying
> to use it.  You say: 'I can not compile the lines:'
 Yes, even if 'ld' sees my lib. It complains about the '_start' label.

>    Webhelper parser;
>    parser.parseQuery();
>
>    Which to me sounds like your program doesn't even get to the link
> phase but rather fails on the compile.  Does your library have a header
> file (maybe Webhelper.h) that you need to include in the code that uses
> your library class?
 Sure, I have a header file, included into try.cpp :
--  Webhelper.h  --
#ifndef __WEBHELPER_H
#define __WEBHELPER_H
#include <string>
#include <vector.h>

class Webhelper {
public:
	Webhelper(void);
	~Webhelper(void);
	vector<string> parseQuery(void);
};
#endif
-- end of header --
 Should I write out the scope? Like Webhelper::Webhelper() ?

>    As for linking, when you link you'll need to tell your program where
> the lib is (at link time) as in ...
>
>    gcc -o myProgram someFile.o -L/where/the/so/is -lWebhelper
 I do almost the same, but ofcourse with g++:
     g++ -Wall -I/path/to/the/header try.cpp -o try -L/path/to/the/lib -lWebhelper

>    And you'll need to tell it where the lib is at run time (which
> can be done via setting LD_LIBRARY_PATH or doing ldconfig, like you did).
 Sure, but I still can not link:
/tmp/ccquezqDL.o: In function `main':
[...] undefined reference to `Webhelper::Webhelper(void)'
etc. Ofcourse without the -L/path/to/the/lib I get library can not be
found, with it unresolved symbols. Strange, as I also checked out for the
impossible situation: there is an other lib with the same name. Ofcourse
there is no other library in the way.

> Easy enough ...
 I thought there is a direct function call, like strpos() or something.
PHP and Java tricked me. Ok, thanks!

On Wed, 1 Aug 2001, Erik Mouw wrote:

> Don't try to reinvent the way to create shared libraries, but use the
> knowledge of the people who created libtool. This should do the trick:
 The prob that I can not be sure that libtool is installed. Also it does
not work as you wrote. :-(

>   libtool --mode=compile g++ -O2 -Wall -c foo.cc
>   libtool --mode=link g++ -O2 -o libfoo.la -rpath /tmp foo.lo
 It says it can not handle Webhelper.o, as it is not libtool made. :-? I
deleted it with all the other created files, but I still get the same
error. Well, g++ -shared is the standard way to pruduce a library under
GNU/Linux systems, isn't it? I have Debian testing.

On Wed, 1 Aug 2001, Julien Patrick Claassen wrote:

> Szia Laszlo!
 Szia Julien! Do you speak hungarian? :-)

> Then I would see one mistake. The destructor ~webhelper must not have any
> parameter! I don't know if void is allowed, but I don't think so.
 Me neither, just the linker(?) said that:
/tmp/ccquezqDL.o: undefinded reference to `Webhelper::~Webhelper(void)'
 Anyway, first everything was without void. Now everything is void, but I
will check (only) the destructor without void.

Thanks all, I hope I will be able to make it. In case of not, shall I post
the source to the list? I am a new member and do not know if it is allowed
to post small attachements.
Bye, Laszlo




More information about the tuxCPProgramming mailing list