How to Use make to compile c file on codespace - c

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.

Related

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 the directory /usr/src/kernel/system in MINIX 3?

I am working in MINIX 3.1.6, and currently I am changing a little thing in do_fork.C class which is located int /usr/src/kernel/system.
Usually to compile the files in Kernel folder, is use make install in the kernel directory, and then make hdboot.
I used this form, but it didn't compile me the ../kernel/system folder! Then I went first in the directory with cd: "cd /usr/src/kernel/system" and then I used there make clean and make install. In the end I used the command make hdboot in the directory /usr/src/tools
But even that one didn't work... the compiler doesn't show any error or anything, it just doesn't take my changes.
Does anyone know how to compile the whole directory: /usr/src/kernel/system in Minix ?
Thanks in Advance
EDITED
It's interesting, I did a mistake in do_fork class, and when I tried make install it showed me an Error. This means that do_fork.c is being taken by the make install. Can the problem be in the make hdboot that it isn't taking the changes of do_fork.c?
I changed the main.c file in /usr/src/kernel folder by adding an additional printf statement in announce method and the following commands worked for me in MINIX 3.2 version.
Run command "make install" inside /usr/src/kernel folder.
Go to the directory /usr/src/tools and run command "make hdboot".
Restart OS.
Select first option in boot screen and my changes was available.

Running an executable file through Cygwin

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

Xcode, how to run one file at a time?

Xcode Question, how to run one file at a time?
I keep getting this error: "Linker command failed with exit code 1" and I've noticed that it occurs when i use the "int main" method in multiple files. Furthermore, when I try to run a simple return 0 file, my "hello world" file still gives results to the console. So my assumption is that xcode is running all of the files in the project at the same time causing me to have a duplication error when I repeat method names (such as "int main"). How do I only run one file at a time? These are C files by the way, I'm using xcode as a tool to practice my c programming before next semester. Thanks for your help!
It sounds like you're trying to build multiple programs. The problem is you have a single "target" which is what Xcode uses to define what goes into an application.
You will need to create a separate target for each of your programs and assign target membership for your source files. Go to File->New->Target to create a new target. From the sounds of it, you are creating a command-line C program, so you will want to create a Command-Line Tool found under OS X-> Application.
Alternatively, you could also create separate projects for each program. See File->New->Program
As yet another alternative, assuming you are creating command-linen tools, if you wish you can use Xcode merely as an editor and build the program from the commandline (which you may have to do for your classes anyway). You can do this by creating your .c files and opening them in Xcode. Save the files to the same folder. To compile from the commandline, run something like the following in Terminal:
gcc -Wall file1.c file2.c -o myprogram
You would then run your program by giving:
./myprogram
If that doesn't work, make sure the command line tools are installed.
You can only have one int main per target.
You're getting linker errors because you're defining more than one.
If you need to run a function other than main at the start of execution, call it from main.
I ran into this issue myself following Learning C by Dan Gookin with exercise files. I learned that in order to be able to run the .c files, a project must be created then the files must be added specifying no target membership, otherwise Xcode will compile the entire files three as one executable and the errors encounter would prevent the program to run.

i want to run a program without using terminal -- is it possible ? how?

I'm having a program that will do a file copy, but does not need terminal to print.
Now i want to run the file by double clicking ./filemove but it does not do anything. Through the terminal it works fine.
I think it's because I need to include the headers and I do not know how to include the headers to that file.
Can anybody help me? I want to know how to include header files to the executable file or if that is not the reason than what else is the reason?
Thank you.
I use Ubuntu Linux OS. I didn't take any environmental variables and still i cant find it!
I'm going to take a stab at this and guess your problem has to do with file paths. On Linux you can absolutely run programs without the terminal. The terminal is just an interface to the application. The same is true of whatever Desktop Environment you are using.
I'm assuming that your filemove program is using relative paths. What I'm guessing is happening is that when you double click your application, the DE is running it from a different directory than the one it is in. This is pretty counter-intuitive but is possible. So if your program is in /home/user/myproject/ and you double click on it, it's possible that the DE is running it from /home/user/ instead.
I would recommend adding output to your program, and have it print out it's working directory. Since you are not running it on the CLI, have it print to a file.
EDIT: you could also try changing any relative file paths to absolute file paths and seeing if it works. That will at least tell you if the working directory is the problem or not.
If you want to further try to debug this, create a shell script that contains something like:
#!/bin/sh
exec strace /path/to/yourprogram "$#" >/tmp/strace.out 2>&1
Make the script executable, and run that instead of your program, look for clues in /tmp/strace.out
Make sure you've installed the strace program (apt-get install strace)
A wild guess: Are you giving arguments to your program when you run it in the terminal? As in the command ./filemove oldname newname?
In that case, you need to give those arguments to the program in some other way. In at least some window systems- you can drag and drop files on the program icon to give it the paths of those files as arguments.

Resources