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?
Printable View
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.
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?
Actually his example was for hw1 the first assignment, i never used the binary of the 1st assignment.
I used the binary for the second assignment hw2, but since the command doesn't change because the file name is different, I used that, and I remember it didn't work properly, but I did mess around with the extensions and I entered some command and it produced an executable.
I am currently trying to replicate that for the third assignment, hw3
You know I'm now wondering if you had Cygwin installed, if the hw1 would run under that.
Your teacher is nuts.
Ask for you money back.
Indeed. There is no such thing as "execute" bits on a Windows system. There is in Linux/Unix, but not in Windows. Instead, the Windows command line shell determines how to "execute" something based on the extension of the file. Write a text-file called "Blah.txt" in noetpad. Now rename it to Blah.com, type blah in command line [in the appropriate directory] and see if crash! [This doesn't work for .exe files, since .exe files have a bit more complex structure, and thus the OS will realize that it's not an exectuable file and fail to load it in the first place].
--
Mats
Err no, I did this myself when messing around with commands when he released hw2
I got the executable for hw2 and it's with me
I don't care if you get Linus Torvalds to come and explain it's not possible, because I got the executable I made by entering some random command I found online earlier or finding it in the 'man'.
I got the evidence, it's hw2.exe and it came from the binary he released.
Well, under Windows, "chmod +x blah" will do absolutely nothing, so how that "makes it work" is probably more to do with some other random coincident. And I suspect Linus will not be able to explain that. If you have a file called ".exe", it by 99% certainly didn't come from a Linux machine. chmod definitely will not produce a .exe file from a Linux executable, because that is nearly impossible to achieve [it would be technically possible to generate the code if you have a compatibility shared library loader and convert the input ELF file into a COFF format - but it's certainly not something "chmod" would do].
--
Mats