Author Topic: How to make programs built with Code::Blocks on one Linux machine run on others?  (Read 7203 times)

Offline Grouch

  • Multiple posting newcomer
  • *
  • Posts: 40
On a computer using Ubuntu Linux, I have written a program called Gwx with Code::Blocks 10.05. On this machine, the owner is George. I put in a USB flash drive and drag the whole directory containing Gwx over to the flash drive. That is, I copy it to the flash drive. I open a terminal window, navigate over to the flash drive and in the /Gwx/bin/Release directory. I do
 ls -l
and find
 -rwxr-xr-x 1 george george 88896 2012-09-13 00:01 Gwx

That looks good and I do
 ./Gwx
and the program executes just fine.
Then I properly close the flash drive and take it over to my wife's computer, where the owner's name is Joan. I put in the flash drive, navigate to the same directory as before, do ls -l and find
 -rw-r--r-- 1 joan joan 88896 2012-09-13 00:01 Gwx

Notice that the x's in the permissions have been all changed to -. All efforts with “chmod u+x Gwx” or “chmod a+x” or “sudo chmod u+x” fail to make any change in the permissions. Needless to say, trying to execute the program with ./Gwx produces only a “Permission denied” message.

How do I get a program built with Code::Blocks on one Ubuntu Linux machine to run on another Ubuntu Linux machine?

Since Code::Blocks 10.05 is installed on both machines, I have also tried to open the project file and rebuild it on the second machine. Code::Blocks seems to find all the files successfully, and seemingly builds successfully, but when execution starts, it terminates immediately with a 255 error message. So a related question is, How can I work on the project on two different computers, both running Ubuntu Linux and Code::Blocks 10.05?

Offline Radek

  • Multiple posting newcomer
  • *
  • Posts: 104
Your problem seems to be related to a non-linux pratition on the flash disk. How is the disk formatted? I've just checked my FAT16-formatted "maiden for everything" and I've seen the same: no 'x' permissions - naturally, FAT16 does not support any 'x' permission. I haven't attempted to run something from the flash disk (I haven't anything Debian-based on it currently) but I suppose that I would see "access denied" as well.

If your flash isn't ext3/ext4 then copy Gwx somewhere on your wife's computer and then run. If you lose the 'x' permission, you would be able to set it now. Another possibility is installing a support for foreign partition types. At least, I've seen a working support for NTFS on Debian. If your flash disk is NTFS then you should be able to run Gwx from it. At any rate, this is not a Code Blocks failure.

Offline Grouch

  • Multiple posting newcomer
  • *
  • Posts: 40
Thank you, Radek, for your helpful reply. I copied Gwx to the hard disk on Joan's machine and was able to use chmod to establish the x permissions, and it then ran fine. I then copied the whole Gwx project to Joan's machine, rebuilt it, and it ran fine. So I copied the executable so created back to the USB Flash drive, but it lost the x permissions already on Joan's machine. I then took the flash drive over to George's machine; and, lo, the Gwx created on Joan's machine had x permissions and ran fine from the flash drive when it was in George's machine! That's right; it would not work on the machine where it was created, but worked on the other machine!

So apparently George's Ubuntu Linux machine will run programs from the flash drive but Joan's Ubuntu Linux machine won't! The only software difference that I can think off between the two machines is that George's has a FAT partition where Windows resides while Joan's does not. Perhaps sharing that FAT partition caused Linux on George's machine to understand the FAT partition on the Flash drive.

Offline Grouch

  • Multiple posting newcomer
  • *
  • Posts: 40
The second problem, the one about moving the Code::Blocks projects from one machine to another, was resolved by using the Ubuntu Software Center to remove "build-essential", wxWidgets, and Code::Blocks and then reinstalling them. Then building the project on Joan's machine worked.