Makefile not working with cygwin - makefile

I just installed cygwin with C++ compiler and Perl on my windows machine. Whenever
trying to compile the C++ files with the makefile I get the following error:
>make
Cant find C:\Program on PATH
Not sure what path is exactly missing and where I can change it...

You should install cygwin in C:\, not in C:\Program Files\ - the latter often causes problems because of the space, as is the case here.

You've got a space in your PATH environment variable. Wherever you set the path, you might use an 8.3 filename instead of an extended filename, or you might encapsulate the section with spaces in quotes. For example: PATH=c:\windows;"c:\program files\foo"

Related

showip: command not found

I am trying to run one of the example from Beej's Guide to Network Programming (https://beej.us/guide/bgnet/), specifically showip.c (The link to the program is here: https://beej.us/guide/bgnet/examples/showip.c). Using gcc, I've typed in
gcc -o showip showip.c
Then ran the program
showip www.example.net
and I get an error showip: command not found on the same directory where the code and the program is compiled at. I'm not sure why this is the case. I've even cloned the code from his GitHub and used makefile to compile the program and yet I'm getting the same error. What exactly am I doing it wrong here?
This is actually problem with how you're running the program.
On Linux systems (unlike Windows systems) an executable in the current directory is not by default searched by the shell for programs to run. If the given program does not contain a path element (i.e. there are no / characters in the name) then only the directories listed in the PATH environment variable are searched.
Since the current directory is not part of your PATH, prefix the command with the directory:
./showip www.example.net
Is the working directory on your path? Likely not.
Try ./showip
Since the program showip is not in your $PATH you have to tell
your shell that it's in the current directory:
./showip
Or add the current directory to your $PATH but it's a less secure
option:
PATH=:$PATH
or
PATH=.:$PATH
and run it as you're trying now:
showip

Mac OSx 7zcat command not found

I am trying to execute a Makefile script and my Mac complains about 7zcat, although I already have 7z installed.
/bin/sh: 7zcat: command not found
Any thoughts on what's missing on my system? Thank you!
I have never used 7zcat before.
However, it looks like it needs to be installed on your system.
https://github.com/essentialkaos/7zcat
Also, after you download install 7zcat you have to give it execute permission with chmod. Finally, you have to execute it by calling its full path for example if you installed it to the directory you are in you would run ./7zcat file.7z or you would add the path to the file to your environment's $PATH variable.
I hope this helps. You might have to do some more research though.
When you open a Terminal window and type 7zcat and hit enter, what happens? Same message? Well, if you cannot use it, why should make be able to use it? Where and how have you installed 7z? Is the folder with the 7z binaries in your PATH? Since if it isn't, of course the command won't be found.
When the system shall run a command, it will search for this command in the directories stored in the PATH variable. Execute echo $PATH in terminal and you will get a colon separated list of directories; only these directories are searched for binaries. So either you must move your binaries to one of these (or put a symlink to one of these) or add the directory with these binaries to the PATH.
Yet there is no official 7z command line installer for MacOS, which brings me back to the original questions "Where and how have you installed 7z?" And are you sure that whatever you installed even includes a 7zcat?

How to add directories to Cygwin gcc default search path

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.
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?

Compiling PDCurses into ".a", error with mingw command

I'm following this tutorial: https://www.youtube.com/watch?v=mYnfix8ruAo
for compiling PDCurses and linking it to a CodeBlocks project, but I keep getting an error ('mingw32-make' is not recognized as an internal or external command, operable program or batch file.)
The thing is, I definitely have mingw installed properly, and have a path pointing to it in the system environment variables.
http://puu.sh/id6nC/3ab670cbdc.png
In the terminal, I tried the command twice without specifying a target file to make sure it's recognized, and it is. It's not until after I get to the point that I want to build the library that it stops recognizing it as a command for some reason. I'd really appreciate any help.
This isn't a PDCurses issue, it's a PATH issue. The PATH is an environment variable that the command-line shell uses to locate the executables you type as commands, if they aren't in the current directory, or shell built-ins. It's a list of directories, separated by semi-colons. Each directory is checked in turn, until a match is found.
Specifcally, your problem is this line:
path=c:\CodeBlocks\mingw\bin
Apparently, mingw32-make is not in that location. But, since it was found without that line, you clearly don't need the line -- at least not for that. So, just take it out.
Now, if it later turns out that you do need to add \CodeBlocks\mingw\bin to your PATH for some other reason, then the way to do it is like this:
path=%PATH%;c:\CodeBlocks\mingw\bin
This appends your new path to the existing PATH, instead of wiping out the existing PATH and replacing it with that directory alone.

mingw make can't handle spaces in path?

I am trying to compile code, the makefile created using qmake.
When I run mingw32-make I get the following error:
cd bzip2-1.0.5\ && c:\QtSDK\Desktop\Qt\4.7.3\mingw\bin\qmake.exe c:\Documents an
d Settings\user\My Documents\Visual Studio 2010\Projects\meshlab\meshlab\meshla
b\src\external\bzip2-1.0.5\bzip2-1.0.5.pro -o Makefile
Cannot find file: c:\Documents.
Cannot find file: and.
Cannot find file: Settings\user\My.
Cannot find file: Documents\Visual.
Cannot find file: Studio.
Cannot find file: 2010\Projects\meshlab\meshlab\meshlab\src\external\bzip2-1.0.5
\bzip2-1.0.5.pro.
mingw32-make: *** [bzip2-1.0.5\Makefile] Error 2
By the error it appears that mingw32-make doesn't understand paths that have spaces in them. Is that true? Is there a way around it?
The common way to do it in Linux/UNIX is to escape each space with a backslash, like: /c/Documents\ and\ Settings/User However, this doesn't always work in MinGW.
So, use the short (8.3) name. You get the short name with the Windows (not MinGW) command for %I in (<PATH>) do #echo %~sI where <PATH> can be . (show current directory, like pwd), * (list files in current directory), a particular file path, etc.
Btw, to copy from the awful cmd.exe window, click the icon in the upper-left corner of the title bar, go to Properties, Options, and enable QuickEdit Mode. Then you can select text with your mouse. The Enter key (or menu>Edit>Copy) copies the text to the clipboard. The insert key (or menu>Edit>Paste) pastes it.
From the MinGW "Getting Started" guide:
MinGW may have problems with paths containing spaces, and if not, usually other programs used with MinGW will experience problems with such paths. Thus, we strongly recommend that you do not install MinGW in any location with spaces in the path name reference; i.e. you should avoid installing into any subdirectory of "Program Files" or "My Documents", or the like.
I suspect the same problems found in running executable files will also manifest itself with other files as well. You could try wrapping the whole thing (file specification) inside double quotes and this may work but Windows is sometimes not as logical as UNIX-based shells in this area.
Spaces in file names are evil anyway :-)
Not sure if this helpful or not (in fear of being downvoted), but I created a semantic link in order to avoid paths with spaces. Not sure if it will solve the problem since in my scenario it displayed a different error after I used the semantic link relating to pthreads which I still haven't been able to fix.
Creating semantic link using the command prompt:
mklink /j "C:\newshortcut" "C:\Program Files\Directory with spaces"
Then on the command you want to run, you use C:\newshortcut
Sorry for necroing this, but I had a similar problem and I was able to fix it using cygpath.
For my case I was trying to make an environment variable to visual studio:
export DEVENV="/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/devenv.com
echo $DEVENV
$DEVENV $1 /build "Release|win64"
Which would result in:
/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/devenv.com
-bash: /c/Program: No such file or directory
The solution was to use cygpath -w to convert the path with spaces into an 8.3 filename:
export DEVENV=$(cygpath -w -s "/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/devenv.com")
echo $DEVENV
$DEVENV $1 /build "Release|win64"
Which results in:
C:\PROGRA~2\MICROS~1\2019\COMMUN~1\Common7\IDE\devenv.com
and no error. Hopefully this helps future travellers.

Resources