For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > March 2007 > problems in combining release and debug libraries to get and executable









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author problems in combining release and debug libraries to get and executable
wolverine

2007-03-27, 8:15 am

Hi,
Assume i have a library "libabc.a" which is build in debug ( -g
flag) mode and another library "libxyz.a" which is build in release (-
O2 flag) mode. Then if i link these 2 libraries like

1) g++ -g test.cpp -labc -lxyz (debug build)

2) g++ -O2 test.cpp -labc -lxyz (release build)

Will any of the above 2 builds result in a incorrect executable ?


Thanks in Advance
Kiran.

Bin Chen

2007-03-27, 10:08 pm

On Mar 27, 8:59 pm, "wolverine" <kiran.ha...@gmail.com> wrote:
> Hi,
> Assume i have a library "libabc.a" which is build in debug ( -g
> flag) mode and another library "libxyz.a" which is build in release (-
> O2 flag) mode. Then if i link these 2 libraries like
>
> 1) g++ -g test.cpp -labc -lxyz (debug build)
>
> 2) g++ -O2 test.cpp -labc -lxyz (release build)
>
> Will any of the above 2 builds result in a incorrect executable ?

No, if is, it is the bug of g++.

Ulrich Eckhardt

2007-03-27, 10:08 pm

wolverine wrote:
> Assume i have a library "libabc.a" which is build in debug ( -g
> flag) mode and another library "libxyz.a" which is build in release (-
> O2 flag) mode.


Often, the difference is not just the -O2/-g but also a -DNDEBUG in release
mode. If this changes anything in the interface(!) of the library, this
will lead to problems.

> Then if i link these 2 libraries like
>
> 1) g++ -g test.cpp -labc -lxyz (debug build)
>
> 2) g++ -O2 test.cpp -labc -lxyz (release build)
>
> Will any of the above 2 builds result in a incorrect executable ?


From what you said, not necessarily.

Uli

--
http://www.erlenstar.demon.co.uk/unix/
wolverine

2007-03-28, 4:18 am

On Mar 27, 10:00 pm, Ulrich Eckhardt <dooms...@knuut.de> wrote:
> wolverine wrote:
>
> Often, the difference is not just the -O2/-g but also a -DNDEBUG in release
> mode. If this changes anything in the interface(!) of the library, this
> will lead to problems.
>
>
>
>
>
> From what you said, not necessarily.


Why did you say "From what you said" ?. Is there any case in which
linking debug and release build libraries can cause problems ?


>
> Uli
>
> --http://www.erlenstar.demon.co.uk/unix/



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com