Laura
Laura

Reputation: 83

make reports "command not found" for an executable on my $PATH

I'm working on a project that requires me to convert a c++ program (prog1.cpp) to a unix text file. I'm using the command

dos2unix prog1.cpp

However, the files that my makefile makes aren't working as they should. make all is supposed to make an executable file hantow which is does, but upon executing hantow the shell reads:

-bash: hantow: command not found

My code is okay, no errors there. I can see there is a file called hantow in the directory and I've already ran

chmod 755 hantow

I wanted to ask if that's the only step you're supposed to take ie.dos2unix or are there any followup commands as well?

Upvotes: 0

Views: 143

Answers (2)

umläute
umläute

Reputation: 31254

well, text-files are pretty universal with one big (or minor) issue: line-endings.

traditionally, text files use different line-endings on differents systems:

  • CRLF on W32
  • LF on Un*x
  • CR on MacOS

Luckily Apple switched to the proper Un*x line-endings when they moved to OSX (a while ago). So these days you will only find two different line-endings.

In the meantime, virtually any decent text-editor will handle text-files of any line-ending convention (I think the big exception is notepad.exe which still can only handle CRLF). Also any C/C++ compiler will not care at all about the actual line-ending.

So there is no real need to convert a "c++ program to unix text file".

OTOH, I still prefer working with native line-endings whenever possible, and dos2unix is a perfect tool for that. (though modern VCSs will automatically handle line-ending conversion for you, so there is less demand for dos2unix these days).

Finally: your problems with hantow are not related to this.

Upvotes: 1

joranvar
joranvar

Reputation: 490

To answer your specific question: dos2unix should usually be enough to convert the line endings of a file from CRLF to LF. There may be other reasons that the code does not execute, for example if the code uses some other OS-specific functions that are not available in your environment. Also make sure that your Makefile and other input files have the correct line endings. You can call file on the file, to see whether it outputs something like ..., with CRLF line terminators, in which case you might want to run dos2unix on them, too.

Upvotes: 0

Related Questions