[CMake] [resolved] Debug build compiles and links, but Release build fails to link?

Pascal Fleury fleury at users.sourceforge.net
Fri Mar 16 03:43:48 EST 2007


On Thursday 15 March 2007 19:50:36 Jean-Sébastien Guay wrote:
> Hello Alan,
> files. So I investigated the particular methods that were not being
> found on link, and I noticed that they were defined as inline in the
> .cpp file, but not declared inline in the header file.
>
> I don't know enough about the intricacies of C++ to know why having a
> method defined as inline but not declared as inline would be a problem
> only triggered by defining NDEBUG, but that isn't too important. At

My $0.02 here: it maybe due then to other compiler options, especially 
optimizations. In non-optimized code, the compiler may produce actual 
functions (same as for static functions) even if they are marked 'inline' 
(inline is only a *hint* to the compiler, mind that). So that in debug mode, 
it produces some functions for the .cpp you were mentioning, and they are 
optimized out in the release build.  Why the linker would see these  
is unclear to me, because on Linux, it would produce a private symbol in the 
object file, hence not visible to other compilation units. On Windows, maybe 
there is no 'private' symbol, so the linker sees it, but then only in debug 
mode.

Anyway, the declaration and definition of these methods are not consistent, so 
that is the real source of the trouble and should be fixed, if you own the 
code.

--paf
-- 
--paf


More information about the CMake mailing list