This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


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

Compiling GCC 3.1 for Cygwin


There seems to be a problem with the search paths compiled into the compiler/linker tools. This may be an issue with binutils. I am submitting this by way of information to help those who may need to fix it in the configuration or compilation of their tools. If this isn't a gcc problem, would someone please tell me so that I can submit it to the proper list. Thanks.

Here's the scoop:
I have successfully compiled binutils for cygwin and installed it to /usr/local/devel-3.1
It was configured as follows:
../../binutils-2.12/configure --with-included-gettext \
--target=i686-pc-cygwin --host=i686-pc-cygwin \
--build=i686-pc-cygwin --prefix=/usr/local/devel-3.1 \
-v --norecursion

It configured and installed fine. Then I configured, built, and installed gcc using:
/tmp/src/gnu/gcc-3.1/configure \
--with-gcc-version-trigger=/tmp/src/gnu/gcc-3.1/gcc/version.c \
--host=i686-pc-cygwin --enable-languages=c,c++ \
--enable-threads --enable-shared \
--with-included-gettext --prefix=/usr/local/devel-3.1 \
-v --norecursion

This completed without errors as well.

The problem comes when trying to use the the toolchain to compile a C++ file. Here is my simple source file:

#include <iostream>
using namespace std;
int main()
{
cout << "Hello, World!\n";
std::cout << "Hello, World!\n";
return 0;
}

Here are the results of a compile attempt:
cygwin$ echo $PATH
/usr/local/devel-3.1/bin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:.:/cygdrive/c/WINNT/system32:/cygdrive/c/WINNT

cygwin$ g++ -g -O0 -v -o hellocpp hello.cpp
Reading specs from /usr/local/devel-3.1/lib/gcc-lib/i686-pc-cygwin/3.1/specs
Configured with: /tmp/src/gnu/gcc-3.1/configure --enable-languages=c,c++ --enable-threads --enable-shared --with-included-gettext --prefix=/usr/local/devel-3.1 -v
Thread model: win32
gcc version 3.1
 /usr/local/devel-3.1/lib/gcc-lib/i686-pc-cygwin/3.1/cc1plus.exe -v -D__GNUC__=3 -D__GNUC_MINOR__=1 -D__GNUC_PATCHLEVEL__=0 -D_X86_=1 -D_X86_=1 -Asystem=winnt -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Acpu
=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ -D__stdcall=__attribute__((__stdcall__)) -D__cdecl=__attribute__((__cdecl__)) -D_stdcall=__attribute__((__stdcall__)) -D_cdecl=__attribute__((__cdecl__)) -D__declspec(x)=__attribute__((x)) -D__i386__ -D__i386 -D__CYGWIN32__ -D__CYGWIN__ -Dunix -D__unix__ -D__unix -isystem /usr/local/include -idirafter /usr/local/devel-3.1/i686-pc-cygwin/include -idirafter /usr/include -idirafter /usr/local/devel-3.1/i686-pc-cygwin/include/w32api -idirafter /usr/include/w32api hello.cpp -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -quiet -dumpbase hello.cpp -g -O0 -version -o /cygdrive/c/TEMP/cctBIRjh.s

ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/local/devel-3.1/i686-pc-cygwin/include/w32api"
GNU CPP version 3.1 (cpplib) (80386, BSD syntax)
GNU C++ version 3.1 (i686-pc-cygwin)
        compiled by GNU C version 2.95.3-5 (cygwin special).
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/devel-3.1/include/g++-v3
 /usr/local/devel-3.1/include/g++-v3/i686-pc-cygwin
 /usr/local/devel-3.1/include/g++-v3/backward
 /usr/local/devel-3.1/include
 /usr/local/devel-3.1/lib/gcc-lib/i686-pc-cygwin/3.1/include
 /usr/local/devel-3.1/i686-pc-cygwin/include
 /usr/include
 /usr/include/w32api
End of search list.
 /usr/local/devel-3.1/lib/gcc-lib/i686-pc-cygwin/3.1/../../../../i686-pc-cygwin/bin/as.exe --traditional-format -o /cygdrive/c/TEMP/cc82efKk.o /cygdrive/c/TEMP/cctBIRjh.s
 /usr/local/devel-3.1/lib/gcc-lib/i686-pc-cygwin/3.1/collect2.exe -L/usr/local/devel-3.1/i686-pc-cygwin/lib/w32api/ -L/usr/lib/w32api/ -Bdynamic --dll-search-prefix=cyg -o hellocpp.exe /usr/lib/crt0.o
 -L/usr/local/devel-3.1/lib/gcc-lib/i686-pc-cygwin/3.1 -L/usr/local/devel-3.1/lib/gcc-lib/i686-pc-cygwin/3.1/../../../../i686-pc-cygwin/lib -L/usr/lib/mingw /cygdrive/c/TEMP/cc82efKk.o -lstdc++ -lgcc -lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32 -lgcc
/cygdrive/c/TEMP/cc82efKk.o: In function `main':
/home/Administrator/projects/sandbox/hello/hello.cpp:5: undefined reference to `std::cout'
/home/Administrator/projects/sandbox/hello/hello.cpp:5: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, st
d::char_traits<char> >&, char const*)'
/home/Administrator/projects/sandbox/hello/hello.cpp:6: undefined reference to `std::cout'
/home/Administrator/projects/sandbox/hello/hello.cpp:6: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, st
d::char_traits<char> >&, char const*)'
/cygdrive/c/TEMP/cc82efKk.o: In function `_Z41__static_initialization_and_destruction_0ii':
/usr/local/devel-3.1/include/g++-v3/iostream:62: undefined reference to `std::ios_base::Init::Init[in-charge]()'
/usr/local/devel-3.1/include/g++-v3/iostream:62: undefined reference to `std::ios_base::Init::~Init[in-charge]()'
collect2: ld returned 1 exit status

So the problem seems to be with the search path that collect2 is using. The directory where libstdc++ is installed is /usr/local/devel-3.1/lib (not searched by the linker). I have verified that adding this directory to the collect2 line creates a successful executable. I performed the compile and link in two steps, like so:
cygwin$ g++ -g -O0 -v -c hello.cpp
cygwin$ $ /usr/local/devel-3.1/lib/gcc-lib/i686-pc-cygwin/3.1/collect2.exe \
-L$prefix/$target/lib/w32api \
-L/usr/lib/w32api/ \
--dll-search-prefix=cyg \
-o hellocpp.exe /usr/lib/crt0.o \
-L$prefix/lib/gcc-lib/$target/3.1 \
-L$prefix/$target/lib \
-L/usr/lib/mingw \
./hello.o \
-lstdc++ -lgcc -lcygwin -luser32 -lkernel32 \
-ladvapi32 -lshell32 -lgcc \
-L$prefix/lib

Which successfully creates hellocpp.exe.

Does anyone know where the configure/make/make install process is failing to match the correct path?

Is there a switch that I can pass to gcc to fix this?

Thanks,
Brett



_____________________________________________________
Supercharge your e-mail with a 25MB Inbox, POP3 Access, No Ads
and NoTaglines --> LYCOS MAIL PLUS.
http://www.mail.lycos.com/brandPage.shtml?pageId=plus 


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