Dear forum, I have a problem with linking of a program I have wrote. Instead of giving you the entire program, which is pretty large, I have prepared a basic example that you can find attached to this message. The example uses CMake to compile.
I have three files: ===== LIB2.CPP ===== #include <iostream> class Lib2 { public: Lib2() { std::cout << "Lib2" << std::endl; } }; Lib2 lib2; ===== LIB1.CPP ===== #include <iostream> class Lib1 { Lib1() { std::cout << "Lib1" << std::endl; } }; ===== MAIN.CPP ==== #include <iostream> int main() { std::cout << "Ciao" << std::endl; return 0; } The file lib2.cpp is compiled into a dynamic library called lib2. The file lib1.cpp is compiled into a dynamic library called lib1 and that links to lib2. Finally, main.cpp is compiled into an executable that links to lib1. The dependencies are thus: lib2 --> lib1 --> testing Now: if I compile the program with g++ 4.5.2, the programs outputs: Lib2 Ciao whereas if I compile with g++ 4.6.1, the program outputs: Ciao For me this is a problem, as my program depends on the behavior of g++ 4.5.2. I would like to ask you if: 1. this is a new feature - in which case, how do fix the problem? 2. this is a known bug - in which case I apologize for asking, but I couldn't find it in the bug list. Thanks a lot in advance for your help. Cheers, Carlo -- View this message in context: http://old.nabble.com/Different-linking-behavior-between-g%2B%2B-4.5.2-and-4.6.1-tp32849125p32849125.html Sent from the gcc - bugs mailing list archive at Nabble.com.