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:

/usr/bin/c++  -fPIC -O3 -DNDEBUG -lXss -shared -Wl,-soname, -o 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 from final rpm for 11.2 haven’t got Xss linked:

 pc028:/pub/zawel # ldd =>  (0xffffe000)             => /usr/lib/ (0xb75da000) => /lib/ (0xb75ba000)      => /lib/ (0xb745a000)              => /lib/ (0xb7431000)              
        /lib/ (0xb7716000)

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

pc028:/pub/zawel # ldd =>  (0xffffe000)                                            => /usr/lib/ (0xb7793000)                            => /usr/lib/ (0xb769f000)                      => /lib/ (0xb7676000)                                    => /lib/ (0xb7656000)                            => /lib/ (0xb74f5000)                                    => /usr/lib/ (0xb73c0000)                            => /usr/lib/ (0xb73ae000)                          
        /lib/ (0xb77df000)                                             => /usr/lib/ (0xb738f000)                            => /lib/ (0xb738a000)                                  => /usr/lib/ (0xb7385000) 

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

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.