gcc and iostream

y2bismil@engmail.uwaterloo.ca y2bismil@engmail.uwaterloo.ca
Thu Oct 30 22:35:00 GMT 2003


Hi all,

I'm having a linking problem with GCC and iostream.  I'm not sure if it has
anything to do with cygwin, so I'll check here.

I am using 
#include <iostream>
using namespace std;

Its a pretty large project.  First, all the sources and compiled into object
files using gcc.  Then to link, I've tried both gcc and g++.  Both times using
-lstdc++ as a paramter.  Yet, I always seem to get iostream errors like:

: undefined reference to `ostream::operator<<(char const*)
: undefined reference to `_cin'
: undefined reference to `_cout'
:undefined reference to `istream& operator>><int>(istream&, smanip<int> const&)'

Below is the output of gcc/g++ -print-search-dirs
**************************************************
install: /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/
programs:
=/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/:/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/:/usr/lib/gc
c-lib/i686-pc-cygwin/:/usr/lib/gcc/i686-pc-cygwin/3.3.1/:/usr/lib/gcc/i686-pc-cygwin/:/usr/lib/gcc-l
ib/i686-pc-cygwin/3.3.1/../../../../i686-pc-cygwin/bin/i686-pc-cygwin/3.3.1/:/usr/lib/gcc-lib/i686-p
c-cygwin/3.3.1/../../../../i686-pc-cygwin/bin/
libraries:
=/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/:/usr/lib/gcc/i686-pc-cygwin/3.3.1/:/usr/lib/gcc-l
ib/i686-pc-cygwin/3.3.1/../../../../i686-pc-cygwin/lib/i686-pc-cygwin/3.3.1/:/usr/lib/gcc-lib/i686-p
c-cygwin/3.3.1/../../../../i686-pc-cygwin/lib/:/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/../../../i686-p
c-cygwin/3.3.1/:/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/../../../:/lib/i686-pc-cygwin/3.3.1/:/lib/:/us
r/lib/i686-pc-cygwin/3.3.1/:/usr/lib/
************************************************
My compile line is:
gcc/g++
   -mno-cygwin  -g -o$(_Target)
   -LC:\cygwin\lib\mingw
   -Wl,--start-group
   -lwsock32
   -lstdc++   
   <files needed to be linked>
   -Wl,--end-group    

I doubt this is a code problem, though its always possible.  I think its some
setup option or something like that.

any ideas?  
Thanks,


Yamin

----------------------------------------
This mail sent through www.mywaterloo.ca

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list