I am trying to create an executable, according to my lecturer to turn his sample solution into an executable to run on windows I need to type:
chmod a+x hw3
I did that, but it still doesn't make it executable
Suggestions?
I am trying to create an executable, according to my lecturer to turn his sample solution into an executable to run on windows I need to type:
chmod a+x hw3
I did that, but it still doesn't make it executable
Suggestions?
Huh?
You compile the code on the machine you want to run it on, using the compiler which is native to that machine.
You can't just take a random executable from one type of machine and expect it to run on another.
Post your code and state your OS/Compiler.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
chmod is a UNIX command (similar to the attrib command on DOS/Windows).
To run a program on Windows you need to compile it on Windows. The binary format of UNIX programs and Windows programs are completely different.
The compiler is GCC.
And yes you can, I've done it before by mistake, I just forgot how to do it because I never really knew it in the first place, just did it by accident.
We have to do an assignment, so the lecturer has given the "sample solution" which is a binary, and to make it into an executable we have to type chmod a+x <filename>
That doesn't work completely, I remember this happened to me once before, and I typed in some extra command and then it did become executable, but I just don't remember what I did.
This is what the lecturer says:
2) How do we run the compiled version, and how can we test our program?
First, copy hw1 to your own directory. You will then need to make it "executable" by typing:
$ chmod a+x hw1
And what error are you getting after you run the chmod command? You haven't said.
No errors, it seems to execute fine, it just doesn't create an executable
hw1 is the executable. To run the executable, simply type hw1. Look up chmod on your *nix machine, it changes file permissions. Post any error you get after typing hw1.
Command not found.
Lol, forget it, I'm just going to run it from my Uni computer now. It works on that, but not on my laptop.
try ./hw1
Nope, doesn't work, tried that ages ago
>I'm just going to run it from my Uni computer now
That's the only way to run it. If you want to run it on your laptop, you'll have to ask your lecturer for the source code.
That can't be.
For my last assignment, it was in the same way, he released the binary, and I did run it on my laptop, same OS, Windows Vista, that chmod didn't work, I was messing around with some commands, and I turned it into an executable, I don't know how, but I did.
are you sure it wasn't a windows binary to begin with?
>For my last assignment, it was in the same way, he released the binary
What was that one called, hw0?