Strange linking problem with 11.2

I’m building IM client called kadu (home:zawel1:kadu) in OSC. This project compiles some plugins (shared libraries loaded on demand by main program). One of them relies on libXss which is linked with (apparent) success:
line

/usr/bin/c++  -fPIC -O3 -DNDEBUG -lXss -shared -Wl,-soname,libidle.so -o libidle.so CMakeFiles/idle.dir/idle.cpp.o CMakeFiles/idle.dir/idle_x11.cpp.o CMakeFiles/idle.dir/moc_idle.cxx.o -Ldocking -Lqt4_docking

goes without a problem. But resulting libidle.so from final rpm for 11.2 haven’t got Xss linked:

 pc028:/pub/zawel # ldd libidle.so 
        linux-gate.so.1 =>  (0xffffe000)             
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb75da000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb75ba000)      
        libc.so.6 => /lib/libc.so.6 (0xb745a000)              
        libm.so.6 => /lib/libm.so.6 (0xb7431000)              
        /lib/ld-linux.so.2 (0xb7716000)

What is more strange, when I compile this rpm on my own machine the Xss IS linked:

pc028:/pub/zawel # ldd libidle.so 
        linux-gate.so.1 =>  (0xffffe000)                                            
        libXss.so.1 => /usr/lib/libXss.so.1 (0xb7793000)                            
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb769f000)                      
        libm.so.6 => /lib/libm.so.6 (0xb7676000)                                    
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7656000)                            
        libc.so.6 => /lib/libc.so.6 (0xb74f5000)                                    
        libX11.so.6 => /usr/lib/libX11.so.6 (0xb73c0000)                            
        libXext.so.6 => /usr/lib/libXext.so.6 (0xb73ae000)                          
        /lib/ld-linux.so.2 (0xb77df000)                                             
        libxcb.so.1 => /usr/lib/libxcb.so.1 (0xb738f000)                            
        libdl.so.2 => /lib/libdl.so.2 (0xb738a000)                                  
        libXau.so.6 => /usr/lib/libXau.so.6 (0xb7385000) 

Any ideas what can be wrong with OSC compilation? Rpms for other suse versions (11.0, 11.1) are properly compiled.
ZAWEL

man ld and search for --as-needed, it is used by default since openSUSE 11.2.

You can also search in the man page for “-l namespec”. In the third paragraph you can see that your link command is wrong even if it happens to work.

When -lXss is read the linker sees that it doesn’t provides any symbol needed by any previous object, so ignores it. If it is really needed put it AFTER the .o’s.

Thank you for pointing me --as-needed, this way I found the bug in compilation scrips. This command come from Makefile which in turn was generated by cmake. The real error was that -lXss was added to properties LINK_FLAGS and not via target_link_libraries(). I’ve corrected that and everything looks ok now. I will send info to original authors of the software. Thanks again for quick reply.