## Saturday, April 28, 2012

### c++11 - mingw 4.7 install and msys setup notes

The new c++11 standard adds lots of new syntactic sugar to play with.

http://gcc.gnu.org/gcc-4.7/cxx0x_status.html

Unfortunately you'll need to get the 4.7 release directly... the automatic installer still wont download then for you.

Once down loaded unzip in to your desired location (mine is c:\tools\...)

Then you will need to help the system locate the compiler, linker and libs (runtime dlls) for usage as well so you should run the following on a prompt before running your compliation and built .exes.

export PATH="/c/tools/tmp2/mingw/i686-w64-mingw32/lib:$PATH" export PATH="/c/tools/tmp2/mingw/bin:$PATH"


### boost 1.49 in windows 7 using mingw

Before you start. This is for(although its has worked on other systems)

mingw gcc version 4.6.2
boost verison: 1.49
OS: Windows 7 home.

This is basically the same as before in my prior post /2011/02/boost-in-vista-using-mingw-and-cmdexe.html

Dont bother downloading one of the ones with a build version of bjam it wont work. You will need to build it.

Setup gcc as in one of my prior posts.

Make certain that gcc is available on cmd.exe by running a fresh cmd.exe and executing:
gcc -v


You must double that this is not just a temp change to the %PATH% env variable by some script. It has to be set from windows GUI control directly to work reliably.
If gcc failed you can add it to the PATH with the following command sequence.
• windows key+e
• select "my computer"
• right click it and select "properties"
• 3rd tab -> click buttom "variables" button
• add (or edit the existing) PATH entry and set its value [installed_dir]/mingw/bin;[installed_dir]/mingw/lib (where instal_dir is the pathto your mingw install
Next Build bjam: For help refer to: building bjam for 1.49. Note that I use the directory c:\tools as my install area for all programs that need to avoid the windows UAE etc idiocy.. Unziped the files into the desired location Then build the bjam.exe in cmd.exe by executing :
cd C:\tools\boost_1_49_0\tools\build\v2\engine
build.bat mingw

Once built copy C:\tools\boost_1_49_0\tools\build\v2\engine\bin.ntx86\b*.exe into C:\tools\MinGW\bin (This isnt needed but makes it easy later, since you likely have it in your %PATH% already.) Next build the boost libs also in cmd.exe by excuting:
cd C:\tools\boost_1_49_0
bjam toolset=gcc --build-type=complete stage

Refer: http://www.boost.org/doc/libs/1_49_0/more/getting_started/unix-variants.html Wait for the build system to grind it out. This time around there are very few build problems. I guess alot of things have been fixed since the 1.47 version. You should then build a few boost test programs(in cmd or msys) with:
g++ -I"c:\tools\boost_1_49_0" -L"c:\tools\boost_1_49_0\stage\lib" -static boost_lamba_test.cpp -o a.exe
g++ -I"c:\tools\boost_1_49_0" -L"c:\tools\boost_1_49_0\stage\lib" -static boost_regex_test.cpp -lboost_regex-mgw46-1_49 -o b.exe


The test programs are from here:

Lamba test: http://www.boost.org/doc/libs/1_45_0/more/getting_started/windows.html#build-a-simple-program-using-boost

Keep in mind the order of the source and libs files is important in mingw http://www.mingw.org/wiki/Specify_the_libraries_for_the_linker_to_use

### mingw msys install with the new installer

Got my self a new windows 7 machine as my work machine. Got set it up now.

So Msys and mingw have to be installed, and they have a new installer. SO first lets get the installer.. I have the 0.5 beta from here:
http://sourceforge.net/projects/mingw/files/Installer/mingw-get/

Dont really know what they where thinking with this. Its an apt-get command line imitation. The old plain and simple nullsoft installer with its simple stepped choices of install location the most common packages could get the job done no sweet.

Now you must have a net connection or take the trouble to pre-download all the crud on a different machine with a connection a head of time and transport all that to the offline machine.. its much more messy.

To top it off the default run of the program is just plain ridiculous. Open up the cmd.exe and run:
mingw-get.exe


You get a "cant do a gui install prompt, OK?" in a >>GUI<< prompt... despite the fact that i just ran it from the cmd line...and then it closes without doing anything else.. WTF! Correct this too this command:
mingw-get.exe --help


Then you get the basic idea. When you install it, it appears to installed to ../ dir from the current on so be careful where you ran it:
mingw-get.exe update
mingw-get.exe install mingw
mingw-get.exe install g++
mingw-get.exe install msys


gcc.exe -v
g++.exe -v


This resulted in version 4.6.2 of gcc and g++ and version 1.0 of msys.

My install directory is "c:\tools\mingw" And the msys boot script installs to [install_dir]/msys/1.0 so for me the full path of it is:
c:\tools\mingw\msys\1.0\msys.bat


Once I booted up msys I noted a problem with the /mingw directory.. simply put it was missing so to get all the tools i did a final ln -s as such:
cd /
ln -s /c/tools/mingw mingw


And then everything in msys seemed to be alive and in the default path.

## Sunday, April 15, 2012

### Ubuntu 11.10 -- samba setup

Ok now that we have all the disk setup we need to setup samba shares that so they drives are available on the network

sudo apt-get install samba
sudo apt-get install libpam-smbpass


Then edit and update the settings
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.20120415
sudo vi /etc/samba/smb.conf


workgroup = WORKGROUP
security = user


[share200GB]
comment = 200GB Share
path = /media/biggy
browsable = yes
guest ok = no


Keep in mind that if you give "guest ok = yes" then anyone can get in to the disk and read write etc...

Then reboot the samba server
sudo restart smbd
sudo restart nmbd


In the end I also had add an new user and force that user to be enabled as well with:
sudo useradd --home /home/remote --shell /bin/false remote
sudo passwd remote
sudo smbpasswd -e remote


https://help.ubuntu.com/11.04/serverguide/C/samba-fileserver.html

### ubuntu 11.10 -- wake on lan

After you setup the BIOS to allow wake up get the ethtool to setup the wake on lan;
sudo apt-get install ethtool


sudo ethtool eth0


Look for the Wake On settings then select one. The most common is "g"

sudo ethtool -s eth1 wol g


shutdown the machine and check that it can be woken from a wake up tool like "wakeonlan"

### ubuntu 11.10 -- fixing missing mounted disks.

I have no clue why but if you put the desktop version of ubuntu in it insists on dynamically mounting and unmounting the disks as the user needs them. I want them shared in samba so I need to fix them disk mounting.

First discover all the disks that your system has with:
sudo fdisk -l
sudo blkid


It is best to use the blkid of the device this creates a more robust setup and allows for the disk to move around depending of scsi and apti booting.

One of these will be your system disk... DO NOT mess with this disk it its a sure fire way to brick the machine. The basic install partitions look like this:
Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        2048    76068863    38033408   83  Linux
/dev/sdb2        76070910    78163967     1046529    5  Extended
/dev/sdb5        76070912    78163967     1046528   82  Linux swap / Solaris


Next rather that mess around with fstab and guess the whole thing fro scratch im going to use a GUI tool to mount the disks most of the way and clean up manually.

So to be safe we are backing up fstab first. if you brick it then boot from your install disk and copy the backup back over the top
sudo cp /etc/fstab /etc/fstab.20120412


Open the "Dash Home" (upper left) and search for "Storage Device Manager"..
Note that If you get nothing click the "More Apps" and then try the search again (the good the bad and then unity...) click it youll end up in the software center install it(the button is one the mid right). Then repeat the above step.

Now Storage Device Manager isn't bug free, the newer hard disks tend to confuse it. click each disk and confirm that the /dev/.. in the lower left corner matches to the tree layout if it does and it prompts you that your device is not mounted then go ahead and auto mount it.. it the text and display mismatch dont mess with it you can brick the machine. Also confirm that your not messing the the main system disk.

For example on my machine it confused sda1 with /dev/sbb5 ..

So once you run the tool or manually add the basic disk step you will want to mount each disk and confirm the they work. Then reboot and confirm that boot still works. Once your machine boots by that we can think about fixing permissions etc.

This page has an excellent listing of the basic options types to use to make the disk work well. https://help.ubuntu.com/community/AutomaticallyMountPartitions#Systemwide_Mounts

### Ubuntu 11.10 -- fixing grub

Gezz can they screw the system up even worst.. now we have a graphical grub that is not 100% compatible with all monitors. To disable this mess.

 GRUB_TERMINAL=console
GRUB_CMDLINE_LINUX_DEFAULT="text"


Then run:
 update-grub


And reboot. Now we should have text and problems on boot will clearly visible.... amazing!

### Ubuntu 11.10 -- renaming the machine

God knows why but the install appends a mess of crud to the end of the machine name to fix this in a GUI) edit the hostname and replay it with something saner

sudo vi /etc/hostname


### Ubuntu 11.10 -- VNC screen not updating fixes

This time around im combining all my various servers into one. And i had the brilliant idea to update to Ubuntu 11.10 in the progress. This was a massive mistake. Unity is buggy as hell

First step setup VNC. This is simple (or should be)

1. First create a user that autologs in,
2. in that user hit the "Dash home" in the upper left of the unity menu.
3. Enter "desk" in the search box and find the "Desktop sharing" app and open it
4. check the "Allow other users to view", "Allow other users to control"
5. uncheck the "You must confirm..."
6. check the "Require the user to enter this password" and punch in a password
7. save it

Now that dead simple... but it doesn't work! The key issue is the stupid eye candy. So log out(from the upper right cog menu) and get to user login menu.

On select automatic login users account and click the cog select "unity 2D" to disable the pointless eye candy and then login. Now VNC will connect and the the screen will update.

On a side not you might what to disable more the crud like backgrounds etc. so that the connection is faster and lighter.