This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Question regarding your post on gcc mail list


Hi Wenhao,
you're right in that there has not been a definitive conclusion.
In the future, gcc and g++ may leave traces behind in the .o files
to let the linker know which support libraries to link in.
For now, the cleanest solution may be to link with g++ if you
know there are c++ object files involved.
Does that work ok for you?
- Dan

Wenhao Wu wrote:
Hi Dan,

I am writing this email to you regarding your following post on gcc list:

http://gcc.gnu.org/ml/gcc/2004-04/msg01032.html

I just met the exact same problem: My project is a C library that is coded
in C++ internally with a C wrapper. The user API is pure C based. With gcc
2.95.x, I need to use "gcc -lstdc++" for linking. For recent gcc (3.3.3),
I was having this undefined reference to "_Unwind_*" when I use "gcc
-lstdc++"  to link. So I googled around and fortunely found your post at
the gcc mail list. And it fixed my problem :)

So, first of all, very good post. Thanks for the summary / explanation of
the problem and putting it in a central place for people to looking it up.

Second, after reading all the pointers and discussions in the same
thread, I had more questions and hoped that you may be able to provide
more insights:

1. I also have gcc 3.3.1 installed on a machine with same configuration
and it seems to work ok by only linking with "-lstdc++". I tried "gcc -v"
and "g++ -v" on both machines, and found that both gcc 3.3.1 and gcc 3.3.3
were linking with the same libraries:

gcc: -lgcc -lgcc_eh -lc -lgcc -lgcc_eh

g++: -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc

So, is this problem only pertinent to gcc 3.3.3 or higher? Maybe these
symbols were still in -lgcc or -lgcc_eh in gcc 3.3.1 but got removed to
-lgcc_s in gcc 3.3.3? Do you know of any place that documents these?

2. Do you think that linking "-lgcc_s" this way is a good solution? From
you following post here (http://gcc.gnu.org/ml/gcc/2004-04/msg01079.html),
you seemd to still hesitate on that. I work on the embedded space, so
things have been tricky already, as you might already know :)
(http://www.kegel.com/crosstool/).

3. Do you think that I should just use "gcc" for compiler and "g++" for
linker? That might make the things a bit clearer.

I tried to follow on all the articles that you mentioned, but could not
reach any clear conclusions (possibly due to my lack of background in this
area). So I figured that I'd ask you directly. Sorry if I had been lazy
this way :)

I will certainly appreciate more pointers to follow if there is no
confirmative answer on these issues. I also tried to look up on
gcc.gnu.org and didn't find much useful information on this topic. Maybe
we are not supposed to mess around with these symbols, and I would not
want to anyway should the gcc works perfectly :)

Thanks for your time for reading this email. I know it's probably a
bit long considering that it's the first communication between us :)

I look forward to your reply. Thanks again.

Regards,
Wenhao



--
My technical stuff: http://kegel.com
My politics: see http://www.misleader.org for examples of why I'm for regime change

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]