Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Link error in minGW (seems libstdc++.a is not in the search path)

Reply
Thread Tools

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

 
 
ddh
Guest
Posts: n/a
 
      01-13-2006
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:perator<< <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+0x9: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

 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      01-13-2006
* 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?
 
Reply With Quote
 
 
 
 
ddh
Guest
Posts: n/a
 
      01-16-2006
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?


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows GCC Support (Mingw & Mingw-w64) xeno fears Python 1 10-04-2009 06:40 PM
Is it possible to link LIB files using a GNU g++ compiler/linker(e.g. mingw)? Gerwin C++ 1 12-09-2007 03:32 PM
sqlext.h - ODBC link time error - dev-c++ IDE with mingw compiler mike C++ 3 08-30-2005 02:16 AM
Re: Link Link Link DANGER WILL ROBINSON!!! Kevin Spencer ASP .Net 0 05-17-2005 10:41 AM
[g++ mingw eclipse] How do I setup Eclipse to use MinGw's g++ compiler? Sam Smith C++ 0 10-18-2004 11:36 AM



Advertisments