Gerhard Herbig wrote:
>
> Hi Greg,
> you wrote:
>
> > Cutting and pasting your code, I do this
>
> > C:/tmp[3]$/MinGW/bin/g++ -c -ggdb hello.cpp
> > C:/tmp[0]$/MinGW/bin/g++ -o hello.exe hello.o -L/local/lib -lmpatrol
> -lbfd -liberty -limagehlp
> > C:/tmp[0]$./hello
> > C:/tmp[0]$ls -l mpatrol.log
>
> > so something worked.
>
> Bingo, that worked!
>
> But why "-lbfd -liberty -limagehlp"?
'-lbfd' and '-liberty' are in the manual. Just figure that
gcc is originally a *nix compiler, so follow the *nix
instructions; disregard the msw instructions, which seem
to be for the ms compiler only.
I searched the mpatrol mailing list archives carefully and
read every message about the msw platform. I think that's
where I found the '-limagehlp' idea.
'libbfd.a' understands debugging symbols, and uses
'libiberty.a'. The 'imagehlp' library is some msw thing
IIRC; you can read lots about it at Jose Fonseca's site
http://jrfonseca.dyndns.org/projects/gnu-win32/software/drmingw/
under 'The IMAGEHLP.DLL Saga'.
> I searched the mpatrol-manual for this phrases and get
> some hints in the form:
> "if the mpatrol library was built ... then link with...",
> but that really doesn't help me, because - as you know:
> I used the binaries.
That is new and useful information for me. Some coworkers
want to use mpatrol but were apprehensive about building
it from source. Now it sounds like they can just download
the mpatrol binaries from the MinGW site.
[...]
> I omitted both: the "- include mpatrol.h" _and_ all four libraries
> mentioned above. With "your method", the program runs perfectly!
>
> ------------------------------------------------------------------
>
> > I suspect that the gcc C++ ABI has changed since
> > the downloaded library was built. That would
> > explain mysterious behavior if true. Try building
> > the library from source.
>
> Originally I started with compiling mpatrol from the source.
> My try was:
>
> to edit the \built\windows\makefile:
> AR = ar
> LD = $(CC)
>
> CFLAGS = -I$(SOURCE) -I$(TOOLS) # removing -nolog
> OFLAGS = # removing -Ogt
>
> The compiler starts compiling some files, but then it stops when compiling
> "inter.c":
> ../../src/inter.c: In function `void* __mp_alloc(unsigned int, unsigned
> int,
> alloctype, char*, char*, long unsigned int, char*, unsigned int,
> unsigned
> int)':
> ../../src/inter.c:863: `sbrk' undeclared (first use this function)
> ../../src/inter.c:863: (Each undeclared identifier is reported only once
> for
> each function it appears in.)
> mingw32-make.exe: *** [inter.obj] Error 1
> ------------------------------------------------------------
OK, 'sbrk' comes up from time to time when porting *nix source.
Probably there's some mpatrol header that lets you substitute
some standard function; I don't remember, but it's something
like that.
> So I was very happy, when I found the binaries at mingw.org\download.shtml!
> But thanks for your advice anyway.
>
> I think I should start learning more about "-lbfd -liberty -limagehlp".
I think I said something yesterday about 'libbfd' being
available in many incompatible versions--now I think
I really meant 'libiberty'. But if it doesn't work,
the linker should tell you.
> Thanks a lot for your answer. You made me happy.
I think you have made my coworkers very happy.