How to add directories to Cygwin gcc default search path

1.4k views Asked by At

I'm a bit of a noob at working with compilers. I want to add an arbitrary directory on my win 8 C:\ drive to the Cygwin gcc default search path.

Here is what I have tried so far. Using gcc --help I found the commands -print-search-dirs and -B <directory> ("add directory to the compiler's search path").

Using the former command output this: install: /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/ programs: =/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/:/usr/lib/gcc/x86_64-pc-cygwin/4. 9.2/:/usr/lib/gcc/x86_64-pc-cygwin/:/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/:/usr/li b/gcc/x86_64-pc-cygwin/:/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-p c-cygwin/bin/x86_64-pc-cygwin/4.9.2/:/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../. ./../x86_64-pc-cygwin/bin/ libraries: =/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/:/usr/lib/gcc/x86_64-pc-cygwin/4 .9.2/../../../../x86_64-pc-cygwin/lib/x86_64-pc-cygwin/4.9.2/:/usr/lib/gcc/x86_6 4-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/lib/../lib/:/usr/lib/gcc/x86_64-p c-cygwin/4.9.2/../../../x86_64-pc-cygwin/4.9.2/:/usr/lib/gcc/x86_64-pc-cygwin/4. 9.2/../../../../lib/:/lib/x86_64-pc-cygwin/4.9.2/:/lib/../lib/:/usr/lib/x86_64-p c-cygwin/4.9.2/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../.. /x86_64-pc-cygwin/lib/:/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../:/lib/:/usr/ lib/

The full path to /usr is C:\cygwin64\usr. The directory I want to add is c:\directory So I tried gcc -B /../directory and other variations, but I get error

gcc: fatal error: no input files compilation terminated

Seems like it thinks I'm trying to compile something. I want to permanently add a directory to the list of default search paths.

1

There are 1 answers

1
Patrick Kelly On BEST ANSWER

There are two issues at play here.

The first problem has to do with the fact that Cygwin views the top of its directory tree / to be within the Windows directory C:\cygwin64. As a result, you are unable to move above that point in the filesystem. The solution is to go through Cygwin's directory /cygdrive, which is the access point where all Windows disk drives are mounted. You can access the top-level Windows directory C:\ from Cygwin as /cygdrive/c. So for the problem above, instead of using gcc -B /../directory, try using gcc -B /cygdrive/c/directory.

The second issue is that of adding directories to the search path, versus telling it to compile a specific source file. Given the date of this question, I assume you've solved that part of the problem at this point?