Find the answer to your Linux question:
Results 1 to 10 of 10
Why I cannot run the compiled executable file (the 'diamond' file) in other pc but just can run in the pc which compiles it? Any solution for it? Thanks in ...
  1. #1
    Just Joined!
    Join Date
    Nov 2008
    Posts
    25

    [SOLVED]Why I cannot run the compiled executable in other pc?

    Why I cannot run the compiled executable file (the 'diamond' file) in other pc but just can run in the pc which compiles it?

    Any solution for it?

    Thanks in advanced. Nice day.

  2. #2
    Trusted Penguin elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    2,298
    Quote Originally Posted by christyyim View Post
    Why I cannot run the compiled executable file (the 'diamond' file) in other pc but just can run in the pc which compiles it?

    Any solution for it?

    Thanks in advanced. Nice day.
    Compiled on Windows - Running on Linux
    Compiled on Linux - Running on Windows
    Compiled on 64 bit - Running on 32 bit

    Hundreds of other possibilities, please provide more details to help us narrow it down a bit
    If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)


    My new blog. It's probably not as good as I think it is.

  3. #3
    Just Joined!
    Join Date
    Nov 2008
    Posts
    25
    this is an executable file my friend sent to me. I didn't have the source code to recompile it. By the way, he was using Ubuntu 7.10 to compile it and i was using Ubuntu 7.10 to run the executable as well.

    The error message i get was
    christyyim@christyyim-desktop:~/Desktop$ ./abc
    bash: ./abc: Permission denied


    Is it because different pc, the C compiler compile the source code in different path and cause me cannot run the executable file?

    ps: I didn't know about what 32bits or 64bits. Can you explain some?

  4. #4
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Posts
    935
    Type "man chmod" and pay close attention to the letter "x".
    Debian GNU/Linux -- You know you want it.

  5. #5
    Trusted Penguin elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    2,298
    It sounds like you need execute permissions

    In the terminal type

    Code:
    chmod +x abc
    ./abc
    chmod +x will make the program executable and then you can run it

    64 bit operating systems are for 64 bit processors. A 64 bit processor can run 32 bit software but a 32 bit processor can't run 64 bit software.

    [edit]Beaten to it [/edit]
    If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)


    My new blog. It's probably not as good as I think it is.

  6. #6
    Just Joined!
    Join Date
    Nov 2008
    Posts
    25
    Yeah~~~ it works!!!!!!

    Thanks guys!!!

    By the way, what problem cause this error?

  7. #7
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    it needed to be made executable in order to run it

  8. #8
    Trusted Penguin elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    2,298
    Quote Originally Posted by christyyim View Post
    Yeah~~~ it works!!!!!!

    Thanks guys!!!

    By the way, what problem cause this error?
    On a properly configured Linux system even executable files are not executable by default. You need to give a user execute permission to the file, otherwise you will get the permission denied error as you saw.

    This is yet another layer of Malware protection built in to Linux.
    If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)


    My new blog. It's probably not as good as I think it is.

  9. #9
    Just Joined!
    Join Date
    Nov 2008
    Posts
    25
    Thanks a lot, I get it.

  10. #10
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    elija is basically correct, but I want to clarify one point.

    Linux has no concept of "executable" files. All files are simply a collection of bytes in a certain order.

    However, every file has three permissions associated with it: read, write, and execute. The execute permission says that user has permission to actually attempt to follow whatever instructions are in this file.

    In the case of a compiled binary, the format of the file is probably ELF. If you ever compile your own kernel, you will see that you have the choice to compile support for different binary formats, one of which is ELF.

    In the case of a script, the first line of the script is called the shebang line. This is a special sequence that the OS understands that it will use to attempt to execute the script.

    So in order to execute a program, you need to have executable permissions on it. The chmod program modifies user permissions on a file, so this is how you can grant yourself execute permissions.

    I hope that makes sense, and glad you got it working.
    DISTRO=Arch
    Registered Linux User #388732

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...