C++ for Dummies on Ubuntu

Ok…. So Heekscad is using STL and I wanted to bone up on it a little….

So… After dinner the family goes to our local public library for a browse.  Of course I migrate to 005 in the dewy system..  I was looking to some references to STL.   I wasn’t able to find anything specific to STL but found some stuff in  C++ for Dummies the 6’th (2009) addition.  Actually what was pretty cool is the IDE chosen was code::blocks complete with project files.  How cool is that.

Anyway,  I take the Dummy CD and drag the examples  into CPP_programs into my local directory and rename it CPP_programs for dummies.
So I randomly pick this project :/home/jonas/CPP_Programs_for_dummies/BudgetPrograms/Budget1/Bugdet1.cpp and the project opens up fine… The issue I have is when I attempt to build and run.  I get this message:

————– Build: Debug in Budget1 —————

Compiling: main.cpp
Assembler messages:
Fatal error: can’t create obj/Debug/main.o: Permission denied
Process terminated with status 1 (0 minutes, 1 seconds)
0 errors, 0 warnings

The file browser showing some type of write blocks [carried over from the CD?]. Anyway changing the permissions is a pain in the file browser. Time to go straight to the terminal…

I need to brush up on this a little: https://help.ubuntu.com/community/FilePermissions

so…. lets see what I got:
total 116
-rwxrwxr-x  1 jonas jonas 5230 2009-02-25 16:01 AllPrograms.workspace
dr-xr-xr-x  7 jonas jonas 4096 2009-03-06 04:10 BudgetPrograms
dr-xr-xr-x  3 jonas jonas 4096 2009-03-06 04:10 Chap01
dr-xr-xr-x  4 jonas jonas 4096 2009-03-06 04:10 Chap02
dr-xr-xr-x  4 jonas jonas 4096 2009-03-06 04:10 Chap04
dr-xr-xr-x  9 jonas jonas 4096 2009-03-06 04:10 Chap05
dr-xr-xr-x  4 jonas jonas 4096 2009-03-06 16:10 Chap06
dr-xr-xr-x  7 jonas jonas 4096 2009-03-06 04:10 Chap07
dr-xr-xr-x  5 jonas jonas 4096 2009-03-06 04:10 Chap08
dr-xr-xr-x  6 jonas jonas 4096 2009-03-06 04:10 Chap09
dr-xr-xr-x  4 jonas jonas 4096 2009-03-06 16:10 Chap10
dr-xr-xr-x  3 jonas jonas 4096 2009-03-06 04:10 Chap11
dr-xr-xr-x  5 jonas jonas 4096 2009-03-06 04:10 Chap12
dr-xr-xr-x  9 jonas jonas 4096 2009-03-06 17:32 Chap13
dr-xr-xr-x  6 jonas jonas 4096 2009-03-06 04:09 Chap15
dr-xr-xr-x 10 jonas jonas 4096 2009-03-06 14:58 Chap16
dr-xr-xr-x  6 jonas jonas 4096 2009-03-06 04:09 Chap17
dr-xr-xr-x  4 jonas jonas 4096 2009-03-06 04:09 Chap18
dr-xr-xr-x  3 jonas jonas 4096 2009-03-06 04:09 Chap19
dr-xr-xr-x  3 jonas jonas 4096 2009-03-06 04:09 Chap20
dr-xr-xr-x  3 jonas jonas 4096 2009-03-06 04:09 Chap22
dr-xr-xr-x  5 jonas jonas 4096 2009-03-06 04:09 Chap23
dr-xr-xr-x  5 jonas jonas 4096 2009-03-06 04:09 Chap24
dr-xr-xr-x  5 jonas jonas 4096 2009-03-06 04:09 Chap25
dr-xr-xr-x  4 jonas jonas 4096 2009-03-06 04:09 Chap26
dr-xr-xr-x  4 jonas jonas 4096 2009-03-06 04:09 Chap27
-rwxrwxr-x  1 jonas jonas  837 2008-11-16 09:24 README.txt
-rwxrwxr-x  1 jonas jonas  333 2009-02-22 13:30 Template.cpp
jonas@Ubuntu4:~$

Ok… At this point, you probably think, hey this is a book for dummies…. What does it say to do? Ok than… Page 378… Using the cd, Note for Linux Users: (hey that’s me) “The specifics of mounting and using CDs varies greatly between different versions of Linux. Please see the manual or help information for your system if you experience trouble using this CD.” @#@@

Well… lets see they have anything on there websites….. Nope…..
So….
Looking through the permissions:
jonas@Ubuntu4:~/CPP_Programs_for_dummies/BudgetPrograms$ ls -l
total 20
dr-xr-xr-x 4 jonas jonas 4096 2009-03-06 04:10 Budget1
dr-xr-xr-x 4 jonas jonas 4096 2009-03-06 04:10 Budget2
dr-xr-xr-x 4 jonas jonas 4096 2009-03-06 04:10 Budget3
dr-xr-xr-x 4 jonas jonas 4096 2009-03-06 04:10 Budget4
dr-xr-xr-x 4 jonas jonas 4096 2009-03-06 04:10 Budget5
jonas@Ubuntu4:~/CPP_Programs_for_dummies/BudgetPrograms$ cd Budget1
jonas@Ubuntu4:~/CPP_Programs_for_dummies/BudgetPrograms/Budget1$ ls -l
total 28
dr-xr-xr-x 3 jonas jonas 4096 2009-03-06 04:10 bin
-rwxrwxr-x 1 jonas jonas 729 2009-01-01 13:28 Budget1.cbp
-rwxrwxr-x 1 jonas jonas 32 2009-02-25 15:20 Budget1.depend
-rwxrwxr-x 1 jonas jonas 241 2009-02-25 16:01 Budget1.layout
-rwxrwxr-x 1 jonas jonas 4239 2009-02-25 15:44 main.cpp
dr-xr-xr-x 3 jonas jonas 4096 2009-03-06 04:10 obj
jonas@Ubuntu4:~/CPP_Programs_for_dummies/BudgetPrograms/Budget1$ cd obj
jonas@Ubuntu4:~/CPP_Programs_for_dummies/BudgetPrograms/Budget1/obj$ ls – l
ls: cannot access -: No such file or directory
ls: cannot access l: No such file or directory
jonas@Ubuntu4:~/CPP_Programs_for_dummies/BudgetPrograms/Budget1/obj$ ls -l
total 4
dr-xr-xr-x 2 jonas jonas 4096 2009-03-06 04:10 Debug
jonas@Ubuntu4:~/CPP_Programs_for_dummies/BudgetPrograms/Budget1/obj$ cd Debug ls -l
jonas@Ubuntu4:~/CPP_Programs_for_dummies/BudgetPrograms/Budget1/obj/Debug$

It seems like the issue is that there is no write permissions on the directions for the owner or anyone else… Since, I’m the only one who uses this stuff, I need to open it up for the owner and groups and might as well lock it down for others.

The ubuntu filepermissions lnk suggests reasonable settings   644  for files and 755 for directories.
Since I’m working locally in a directory that I have ownership, I shouldn’t have to use sudo, lest I do something reallly stupid and really screw something up.

Since I need to do some recursive stuff but the permissions are different for files and directories, things get a little gucchi.

Basically this fixed it:
jonas@Ubuntu4:~$ find /home/jonas/CPP_Programs_for_dummies -type f -print0 | xargs -0 chmod 644
jonas@Ubuntu4:~$ find /home/jonas/CPP_Programs_for_dummies -type d -print0 | xargs -0 chmod 755
j

Ok… This seems a bit more reasonable..

jonas@Ubuntu4:~/CPP_Programs_for_dummies/BudgetPrograms$ ls -l
total 20
drwxr-xr-x 4 jonas jonas 4096 2009-03-06 04:10 Budget1
drwxr-xr-x 4 jonas jonas 4096 2009-03-06 04:10 Budget2
drwxr-xr-x 4 jonas jonas 4096 2009-03-06 04:10 Budget3
drwxr-xr-x 4 jonas jonas 4096 2009-03-06 04:10 Budget4
drwxr-xr-x 4 jonas jonas 4096 2009-03-06 04:10 Budget5
jonas@Ubuntu4:~/CPP_Programs_for_dummies/BudgetPrograms$ cd Budget1
jonas@Ubuntu4:~/CPP_Programs_for_dummies/BudgetPrograms/Budget1$ ls -l
total 28
drwxr-xr-x 3 jonas jonas 4096 2009-03-06 04:10 bin
-rw-r–r– 1 jonas jonas 729 2009-01-01 13:28 Budget1.cbp
-rw-r–r– 1 jonas jonas 32 2009-02-25 15:20 Budget1.depend
-rw-r–r– 1 jonas jonas 241 2009-02-25 16:01 Budget1.layout
-rw-r–r– 1 jonas jonas 4239 2009-02-25 15:44 main.cpp
drwxr-xr-x 3 jonas jonas 4096 2009-03-06 04:10 obj
jonas@Ubuntu4:~/CPP_Programs_for_dummies/BudgetPrograms/Budget1$

Now… Back to the gui’s and see if this works…. Yep…… 🙂

This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to C++ for Dummies on Ubuntu

  1. joe says:

    uhhhhhhh
    I have the same thing for windows just trying to build a temp conversion program

    obj\Debug\main.o: Permission denied

    any suggestions?

  2. admin says:

    Switch over to Linux? (sorry…. I couldn’t resist that one)..
    But seriously, you didn’t mention which version of windows you’re using.
    I did some quick googling and I found this: http://www.ehow.com/how_5210173_change-file-permissions-command-line.html
    It’s been a while since I looked at this, but it looking this over I think your dealing with a double whammy. If your dragging the folder over to your hard drive I think there are write restriction on both the folder err directory and the cpp’s. Thinking about this a bit.. I don’t think it should matter on the CPP (unless you’re planning on hacking up the code, but could gum up the works when you compiling.
    I don’t know if this helps…

Leave a Reply

Your email address will not be published. Required fields are marked *