Running an executable file through Cygwin - c

I've recently opened up Head First C and I was having an issue with one of the programs. (I'm using Windows)
I saved a cards.c file in my Documents folder under a folder named Practice and navigated to that folder within Cygwin
I compiled using gcc cards.c -o cards and it compiled with no errors, so I tried to type cards to run the exe file but I got -bash: cards: command not found.
I read through several stackoverflow answers and tried multiple suggestions such as ./a exe, /a exe, cards.exe, a cards, etc/bin/cards and more, but I could only run the file with /cygdrive/c/Me/Documents/Practice/cards.exe
I'm somewhat new with Cygwin so I'm wondering if there is something I missed or a better way to go about this? I'm really looking to learn. On a side note I'm wondering if copying cygwin1.dll from the cygwin bin file to the folder containing the exe file will help, but I don't know how to access the bin file to copy it.

the output file will be named cards, not cards.exe
there are a few different ways to execute that file, here are some of those ways.
a) . cards <-- notice the leading '. '
b) at the cygwin command line in the directory where 'cards' is located:
chmod cards 777
cards
c) from the directory where cards is located:
./cards
Suggest the b) method since it is a permanent fix

Related

How to Use make to compile c file on codespace

make CLI keyword is failing to compile my c programming file.
There seems to be 2 different issues there:
1- make seems to not be present in your workspace. Please try running rebuild50 to rebuild it. You'll not lose your files.
2- You're issueing the command from outside the correct folder.
Please note that in hello folder there are two distinct files (hello and hello.c), but the output from your ls command shows only one result (which is the folder, not the files).
Please run cd hello first to get into the folder containing the file to make.

How to use C file in Ubuntu

I'm trying to get this https://github.com/TheCacophonyProject/voice_scrubbing working on my ubuntu. I've managed to 'make' the thing using
make
Go me!
But I don't know how to insert any files into it.
I'm pretty sure the app takes a .wav file and edits that file inplace.
So could I get some help with doing this?
All the best
Edit:
Here's my directory contents. I want to find a way of using that mute_low(.exe) file:
notebook#heyfinn:~/Cacophony/voice_scrubbing$ ls
Makefile mute_low.c README.md wavefile.h
mute_low mute_low.o wavefile.c wavefile.o
And here's the file contents on Jupyter notebooks to explain why I think there is an .exe file there:
On Linux you do not have .exe files. But instead files are marked with execute permission.
If you look at your Makefile, you can see it defines the TARGET=mute_low.
This is your executable.
You can run it as
./mute_low # in the same directory where you did make
If for some reason it doesn't execute and you get errors like
./mute_low - Not an executable
you can make it an executable as
chmod +x mute_low
Finally it would need the file name of the .wav file and you can provide that as
./mute_low filename.wav

How to compile a Firmware project by using command prompt

I am looking for a bunch of code lines to compile a firmware project by using command prompt. I found for compiling just a .c file it's enough to write gcc -o filename.c.
However my project is a folder with a number of .c files .h files and 3 other formats and I have no idea how to run and compile the whole folder by cmd.
Here is content of project:
Would you give me some advice on what are related commands for this?
Thanks

Compile C source file using Command Prompt

I am having trouble while using the codeblocks-16.01mingw-setup.exe - installed in a file whose path does not contain spaces - when trying to compile at a comand prompt. A beginner's guide recommended using the following line in command prompt:
gcc cards.c -o cards
for the source file named cards.c (on my desktop). This gives the error
'gcc' is not recognised as an internal or external command, operable program or batch file.
When trying to figure this out, I have found out that you can drag and drop files in your command prompt and it specifies their path. Doing this with the gcc.exe taken from F:\Programare\Codeblocks\MinGW\bin\gcc.exe and adding the c source file as C:\Users\dream\Desktop\cards.c gives the error
as.exe - System error: The program can't start because libintl-8.dll is missing from your computer. Try reinstalling the program to fix this problem.
I've reinstated my Codeblocks to no avail. I've also tried matching the paths of the compiler with the source file, bringing the source code where the compiler was, again to no avail.
Please help me understand the issue. I must say that the file named libintl-8.dll is right there where gcc.exe is, trying to add it in the command prompt gives some syntax error.
gcc is trying to find that dll file in the working directory, so you need to cd into that directory cd /d F:\Programare\Codeblocks\MinGW\bin.
Dynamic-Link Library Search Order (Windows)
The directory specified by lpFileName.
The system directory. Use the GetSystemDirectory function to get the path of this directory.
The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched.
The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
The current directory.
The directories that are listed in the PATH environment variable. Note that this does not include the per-application path specified by the App Paths registry key. The App Paths key is not used when computing the DLL search path.
You have to add F:\Programare\Codeblocks\MinGW\bin\ to your users or systems PATH environment variable.
Once you have done this you can simply type
gcc cards.c -o cards

Help with C Program Executable - Linux

I just recently made the move to Linux, and now looking to program on it as well.
However, for some reason I cannot get an executable to work.
Here's what I've done:
Downloaded Code::Blocks
Made a new Console Project in Workspace 1 with C source.
Added a getchar() before return(0);
Ran and Compiled - Which works perfectly INSIDE Code::Blocks
Went to the bin/release folder in which the file is saved, tried double clicking, right clicking and selecting: open, open with, tried using terminal to run the name of my program. I copied the folder URL, and then name of the file.. I just can't seem to get the created file to execute!
In windows it made a .exe, I know there is no ending (?) in linux. (Could be wrong).
I'm currently running Ubuntu 11.04.
Most Linux distributions don't include the current directory in the PATH variable that determines where to search for executables. Try opening a terminal, changing to the bin/release directory and explicitly qualifying your executable for the current directory:
./myprogram
This is in contrast to Windows, where you can simply type "myprogram.exe".
You might need to grant your program permission to run as an executable:
sudo chmod +x yourProgram
In the terminal emulator, go to (cd) the folder where the executable is created.
Type ./programname
Where programname is the name of the executable file
(./ tells the shell to look in the current directory for the program to run)

Resources