cgccpathcygwin

gcc compiler in cygwin does not execute properly (gives up?)


The gcc compiler in cygwin does not execute properly (gives up?) from any folder but /bin. For instance, attempting to compile my code from /bin works, but from /bin/myprogram using the verbose option I get the following message from the compiler:

gcc version 4.5.3 (GCC)
COLLECT_GCC_OPTIONS='-O' '-ansi' '-v' '-c' '-mtune=generic' '-march=i686'
 /usr/lib/gcc/i686-pc-cygwin/4.5.3/cc1.exe -quiet -v -D__CYGWIN32__ -D__CYGWIN__ -D__unix__ -D__unix -idirafter /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../include/w32api -idirafter /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/lib/../../include/w32api sb.c -quiet -dumpbase sb.c -mtune=generic -march=i686 -ansi -auxbase sb -O -ansi -version -o /tmp/ccyhmnJp.s
Makefile:101: recipe for target `sb.o' failed
make: *** [sb.o] Error 1

Other people have reported similar problems:

http://cygwin.com/ml/cygwin/2010-01/msg00939.html

The solution appears to be to modify the path, although "remove X from the path" sounds like a temporary (and strange) workaround, not a permanent solution, and I don't know what to remove. Regardless I ran cygcheck from /bin and from /bin/myprogram (in which I want to compile). The output follows.

From /bin:

$ cygcheck /usr/lib/gcc/i686-pc-cygwin/4.5.3/cc1.exe
C:\cygwin\lib\gcc\i686-pc-cygwin\4.5.3\cc1.exe
  C:\cygwin\bin\cygcloog-0.dll
    C:\cygwin\bin\cygwin1.dll
      C:\WINDOWS\system32\KERNEL32.dll
        C:\WINDOWS\system32\ntdll.dll
    C:\cygwin\bin\cyggmp-10.dll
    C:\cygwin\bin\cygppl_c-4.dll
      C:\cygwin\bin\cygppl-9.dll
        C:\cygwin\bin\cyggcc_s-1.dll
        C:\cygwin\bin\cygstdc++-6.dll
        C:\cygwin\bin\cyggmpxx-4.dll
      C:\cygwin\bin\cygpwl-5.dll
  C:\cygwin\bin\cyggmp-3.dll
  C:\cygwin\bin\cygiconv-2.dll
  C:\cygwin\bin\cygintl-8.dll
  C:\cygwin\bin\cygmpc-1.dll
    C:\cygwin\bin\cygmpfr-1.dll
  C:\cygwin\bin\cygmpfr-4.dll
  C:\cygwin\bin\cygppl_c-2.dll
    C:\cygwin\bin\cygppl-7.dll
  C:\cygwin\bin\cygz.dll

From /bin/myprogram:

$ cygcheck /usr/lib/gcc/i686-pc-cygwin/4.5.3/cc1.exe
C:\cygwin\lib\gcc\i686-pc-cygwin\4.5.3\cc1.exe
  C:\cygwin\bin\cygcloog-0.dll
    C:\cygwin\usr\local\bin\cygwin1.dll
      C:\WINDOWS\system32\ADVAPI32.DLL
        C:\WINDOWS\system32\KERNEL32.dll
          C:\WINDOWS\system32\ntdll.dll
        C:\WINDOWS\system32\RPCRT4.dll
          C:\WINDOWS\system32\Secur32.dll
    C:\cygwin\bin\cyggmp-10.dll
    C:\cygwin\bin\cygppl_c-4.dll
      C:\cygwin\bin\cygppl-9.dll
        C:\cygwin\bin\cyggcc_s-1.dll
        C:\cygwin\bin\cygstdc++-6.dll
        C:\cygwin\bin\cyggmpxx-4.dll
      C:\cygwin\bin\cygpwl-5.dll
  C:\cygwin\bin\cyggmp-3.dll
  C:\cygwin\bin\cygiconv-2.dll
  C:\cygwin\bin\cygintl-8.dll
  C:\cygwin\bin\cygmpc-1.dll
    C:\cygwin\bin\cygmpfr-1.dll
  C:\cygwin\bin\cygmpfr-4.dll
  C:\cygwin\bin\cygppl_c-2.dll
    C:\cygwin\bin\cygppl-7.dll
  C:\cygwin\usr\local\bin\cygz.dll

There are some clear differences but I am not sure what these mean.

Path on my system returns:

$ $PATH
-bash: /usr/local/bin:/usr/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:                                                         /cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/ProgramFiles/ImageMagick-6.8.6-Q16                                                         :/cygdrive/c/Ruby193/bin:/cygdrive/c/Program: No such file or directory

Question is, what do I do now? If the answer is change the path variable, what should be removed? Is the path variable stored in one of the bash resource files or do changes have to be made from the command line? Many thanks!


Solution

  • You have various options. The problem is the wrong /usr/local/bin/cygz.dll

    Either delete your rogue /usr/local/bin/cygz.dll (preferred), or fix you PATH

    $ export PATH=/usr/bin:/usr/local/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS
    

    Explanation:

    On windows the library search path has . before $PATH. So when you are in /bin the right cygz.dll will be found. Otherwise the broken one from your path will be found first.