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?

10-20-2007

Salem

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.

10-20-2007

cpjust

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.

10-20-2007

JFonseka

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.

10-20-2007

JFonseka

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

10-20-2007

swoopy

And what error are you getting after you run the chmod command? You haven't said.

10-20-2007

JFonseka

No errors, it seems to execute fine, it just doesn't create an executable

10-20-2007

swoopy

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.

10-20-2007

JFonseka

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.

10-20-2007

robwhit

try ./hw1

10-20-2007

JFonseka

Nope, doesn't work, tried that ages ago

10-20-2007

swoopy

>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.

10-20-2007

JFonseka

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.

10-20-2007

robwhit

are you sure it wasn't a windows binary to begin with?

10-21-2007

swoopy

>For my last assignment, it was in the same way, he released the binary
What was that one called, hw0?