While compiling a simple or complicated c++ program in Cygwin/g++ if you get below error
/usr/lib/gcc-lib/i686-pc-cygwin/2.95.2-6/../../../../i686-pc-cygwin/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status
Go though following steps.
First try to find where you /usr/lib is mapped. Use Cygpath -w /usr/lib
Above command would tell you the windows directory path where /usr/local/lib is mapped. Go to that directory. In my case it was c:\utils\cygwin\lib. cd into this directory. And search for file libstdc*. You would get a file named libstdc++.a.2.10.0. Create a link named libstdc++.a for the same file in this directory. Here is sequence of commands.
C:\> Cygpath -w /usr/lib
c:\utils\cygwin\lib
C:\>cd c:\utils\cygwin\lib
C:\utils\Cygwin\lib>ls libstdc++*
libstdc++.a.2.10.0
C:\utils\Cygwin\lib>ln -s libstdc++.a.2.10.0 libstdc++.a
And thats it. And even if above trick does not work, try creating link to libstdc++ in directory given by cygpath -w /usr/local/lib.
The problem is g++ can not find out libstdc++ on its own, it needs to be told about this. Here are more threads on this.
http://ubuntuforums.org/archive/index.php/t-15120.html
http://gcc.gnu.org/ml/libstdc++/2002-05/msg00353.html
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment