471,585 Members | 1,169 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,585 software developers and data experts.

Link error in minGW (seems libstdc++.a is not in the search path)

ddh
Hi,

I download mingw in my system(XP SP2), and extract them in
c:\mingw\gcc, so the directories looks like: c:\mingw\gcc\bin,
c:\mingw\gcc\include ..., and I added c:\mingw\gcc\bin in my PATH env.

It is OK for compiling .c code, but when compiling c++ code, some
error will occur.

my cpp file:

--- tmp.cpp ---
#include <iostream>

int main()
{
std::cout << "Hello, world!" << std::endl;
return 0;
}
And the command line is :
gcc -O2 -o tmp tmp.cpp
It output:

C:\DOCUME~1\user\LOCALS~1\Temp/ccYJbaaa.o(.text+0x1b):tmp.cpp:
undefined refe
rence to `std::cout'
C:\DOCUME~1\user\LOCALS~1\Temp/ccYJbaaa.o(.text+0x29):tmp.cpp:
undefined refe
rence to `std::basic_ostream<char, std::char_traits<char> >&
std::operator<< <st
d::char_traits<char> >(std::basic_ostream<char, std::char_traits<char>
&, char const*)'
C:\DOCUME~1\user\LOCALS~1\Temp/ccYJbaaa.o(.text+0x31):tmp.cpp:
undefined refe
rence to `std::basic_ostream<char, std::char_traits<char> >&
std::endl<char, std
::char_traits<char> >(std::basic_ostream<char, std::char_traits<char>&)'

C:\DOCUME~1\user\LOCALS~1\Temp/ccYJbaaa.o(.text+0x7c):tmp.cpp:
undefined refe
rence to `std::ios_base::Init::Init()'
C:\DOCUME~1\user\LOCALS~1\Temp/ccYJbaaa.o(.text+0x98):tmp.cpp:
undefined refe
rence to `std::ios_base::Init::~Init()'
collect2: ld returned 1 exit status

But if the command line is:
gcc -O2 -o tmp tmp.cpp c:\mingw\gcc\lib\libstdc++.a

Then it will be OK.

So I want to know how to set the envionment so that I can use the
former command line to compile c++ code.

Thank you

Jan 13 '06 #1
2 2599
* ddh:
...


1) Use g++, not gcc, for C++ code.
2) In future, please post to appropriate tool-specific group,
since this group is concerned with the C++ _language_.

Thank you,

- Alf

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jan 13 '06 #2
ddh
Thank you very much. It work.

I am sorry for posting it here.
Alf P. Steinbach wrote:
* ddh:
...


1) Use g++, not gcc, for C++ code.
2) In future, please post to appropriate tool-specific group,
since this group is concerned with the C++ _language_.

Thank you,

- Alf

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


Jan 16 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by VoiD | last post: by
1 post views Thread by Doctor Bones | last post: by
3 posts views Thread by Heiko Hund | last post: by
1 post views Thread by Plissken.s | last post: by
1 post views Thread by Brian Hall | last post: by
3 posts views Thread by oberon | last post: by
1 post views Thread by Gary Wessle | last post: by
10 posts views Thread by contactmayankjain | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.