public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* Re: Different linking behavior between g++ 4.5.2 and 4.6.1
@ 2011-11-15 18:36 Jonathan Wakely
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2011-11-15 18:36 UTC (permalink / raw)
  To: Carlo Pinciroli; +Cc: gcc-bugs

This is the gcc-bugs list, for automated mails from our Bugzilla
database.  Your email should probably have been sent to the gcc-help
list.

http://gcc.gnu.org/lists.html


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Different linking behavior between g++ 4.5.2 and 4.6.1
  2011-11-15 18:39 ` Andrew Pinski
@ 2011-11-15 19:25   ` Carlo Pinciroli
  0 siblings, 0 replies; 4+ messages in thread
From: Carlo Pinciroli @ 2011-11-15 19:25 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: gcc-bugs

Thank you very much Andrew, your suggestion indeed solved the problem.
And thanks also for your fast answer! :-)

Cheers,
Carlo

On Tue, Nov 15, 2011 at 6:49 PM, Andrew Pinski <pinskia@gmail.com> wrote:
> On Tue, Nov 15, 2011 at 9:34 AM, Carlo Pinciroli <ilpincy@gmail.com> wrote:
>>
>> 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:
>
> Sounds like --as-needed is the default with the linker you are using.
> That is GCC is not the issue but rather the defaults with the distros
> you are using are different.
>
> Thanks,
> Andrew Pinski
>



-- 
Guarda l'apina che vola gaudente
A questo e quel ramo lei passa radente
Poi vede qualcosa, si posa su un fiore
Io prendo il giornale, la schiaccio e lei muore.

Invia il necrologio a ilpincy@gmail.com.

Look at the bee that happily flits
>From tree to tree no branches she hits
Then something she sees, to the flower she flies
I take the newspaper, swat her and she dies.

Send the necrology to ilpincy@gmail.com.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Different linking behavior between g++ 4.5.2 and 4.6.1
  2011-11-15 17:50 Carlo Pinciroli
@ 2011-11-15 18:39 ` Andrew Pinski
  2011-11-15 19:25   ` Carlo Pinciroli
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Pinski @ 2011-11-15 18:39 UTC (permalink / raw)
  To: Carlo Pinciroli; +Cc: gcc-bugs

On Tue, Nov 15, 2011 at 9:34 AM, Carlo Pinciroli <ilpincy@gmail.com> wrote:
>
> 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:

Sounds like --as-needed is the default with the linker you are using.
That is GCC is not the issue but rather the defaults with the distros
you are using are different.

Thanks,
Andrew Pinski


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Different linking behavior between g++ 4.5.2 and 4.6.1
@ 2011-11-15 17:50 Carlo Pinciroli
  2011-11-15 18:39 ` Andrew Pinski
  0 siblings, 1 reply; 4+ messages in thread
From: Carlo Pinciroli @ 2011-11-15 17:50 UTC (permalink / raw)
  To: gcc-bugs


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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-11-15 18:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-15 18:36 Different linking behavior between g++ 4.5.2 and 4.6.1 Jonathan Wakely
  -- strict thread matches above, loose matches on Subject: below --
2011-11-15 17:50 Carlo Pinciroli
2011-11-15 18:39 ` Andrew Pinski
2011-11-15 19:25   ` Carlo Pinciroli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).