Friday, August 10, 2012

Monday, April 16, 2012

Adding to the PATH variable on Mac

Found explanation here: Copying it in case I lose the link :-)

  • Open the Terminal application. It can be found in the Utilities directory inside the Applications directory.
  • Type the following: echo 'export PATH=YOURPATHHERE:$PATH' >> ~/.profile, replacing "YOURPATHHERE" with the name of the directory you want to add. Make certain that you use ">>" instead of one ">".
  • Hit Enter.
  • Close the Terminal and reopen. Your new Terminal session should now use the new PATH.

Monday, March 19, 2012

Installing SVN on Shared Hosting with PHP exec()

Using PHP's wonderful exec() I have been able to compile, link and install svn on my shared hosting (not VPS). I won't say which hosting provider I use in case they find out and disable svn on me. exec() allowed me to get around the fact that I didn't have ssh access. So how do you do it?

Created a method to wrap exec so I could see the output in a nicely formatted way (useful for debugging):

function run($cmd) {

echo "running ". $cmd . "</br>";
exec($cmd.' 2>&1', &$output);
echo "<pre><code>";
print_r( $output );
echo "</code></pre";

Then I called this method with commands I wanted to execute as if I was logged into my hosting via ssh. e.g. calling run('ls') will run "ls" on the server and echo the output as a HTML response.

I following the steps from a helpful post (see credit below) to do the actual install. Firstly, you need to download the subversion source and dependencies:

Using the server to download the tar files is usually much faster than uploading the files yourself. Then you need to extract the files:
run('tar -xzvf subversion-1.4.6.tar.gz');
run('tar -xzvf subversion-deps-1.4.6.tar.gz');

Next you'll need to run the configure script which came with the subversion source (see following code snippet). I replaced $HOME with a directory I had access to. The prefix is effectively the install location for svn. If you leave the $HOME variable in the command you will be installing it to the directory the $HOME variable contains. If it is empty you'll be trying to install to the root of the system which won't work because you won't have permissions.
run('./subversion-1.4.6/configure --prefix=$HOME --without-berkeley-db \ --with-ssl --with-editor=/usr/bin/vim \ --without-apxs --without-apache');

Finally run make and make install:
run('make install')

The make commands will compile, link and install svn to the prefix directory. The svn binary is stored under the prefix/bin. So to run a svn command you can do:
run('./$HOST/bin/svn <args>')


Wednesday, September 7, 2011

Handling - Runtime Error R6034 Application attempted to load the C runtime lib incorrectly

Handling - Runtime Error R6034, An application has made an attempt to load the C runtime lib incorrectly

  1. This could mean that you have linked against both the debug and release versions of the C runtime library (msvcrt.lib)
  2. This blog post is very useful:

Another possible cause is linking a debug version of a static library when building a release version of your executable. The executable will run on a development machine because the development machine has both the debug and release versions of the DLL installed (

Adding MSVCPRTD.LIB to the list of ignore libraries prevented that library being automatically linked to the project. This caused the linker to show which static library was trying to import the debug dll.

NOTE: Need to create a test project.... an exe which imports a static lib. That static lib should be built in debug config and should use a debug function....... when the exe is built in release mode it will not run on a customer machine (one that doesn't have VS installed) and will bomb out.... show error message there.... But how can you figure out what DLL it is trying to load (maybe it's in the error message).... a good way is to use depends.exe..... check out the profiling tool in it..... show clearly that both the debug and release versions of depends are being searched for... Depends also shows what function that exe is trying to call in the debug version of the DLL..... But how can you figure out which static library that you're linking against is causing this?

So now you know the DLL and the function in the dll you can continue debugging.... the next step is to add the MSVCPRTD.LIB to the ignore specific libraries since you know you don't want to include this..... explain what the MSVCPRTD.LIB is.... also discuss other potential libraries which could cause this error.... finally try building the exe with this setting.... if the correct library is ignored then the static library will not link correctly and the link will fail.... the linker error message will display the function as a missing external symbol and also show which static library the function is being called from.... in my case the static lib I was linking against was built in debug mode but accidentally copied into the Release folder.... I simply dropped in my release version of the static lib, rebuilt and everything worked....

MSVCPRTD.LIB; msvcrtd.lib

Wednesday, August 10, 2011

Calling Const Functions

I learned today that if you have a const object then the compiler will only allow you to call const methods on that object (i.e. methods which are guaranteed not to changed the state of that object). So how do you tell the compiler that a method won't change the object? Put const at the end of the method declaration:
void MyClass::myConstFunction() const

I hit this issue when I was writing a copy constructor with the following signature:
man(const man& m)

I tried calling m.getName() to retrieve the man's name but because I didn't declare getName() as a const method I got the following error (I was using Visual Studio 2008):

error C2662: 'man::getName' : cannot convert 'this' pointer from 'const man' to 'man &'

I realised during my debugging that I didn't need to call a getter because the copy constructor could access the private members of the other man object. Here's the great article that helped me.

Friday, June 10, 2011

Setting Network Device Priorities on Windows 7

I have a laptop at work and dock it when I'm at my desk. So I want to use my wired connection at my desk and wireless otherwise. However when I docked my machine it still used the wireless even though the wired connection was faster. I found these simple few steps to fix this here:

  1. Go to the "Network And Sharing Center" window click "Change Adapter Settings"
  2. On the "Network Connections" window, press the ALT key on your keyboard to being up the menu bar
  3. Click the "Advanced" menu and then "Advanced Settings"
  4. In the "Advanced Settings" window you will see the "Adapters and Bindings" tab and under "Connections" you will see the order they are in, you can use the arrows to the side to move the connection priority up and down.

Friday, February 4, 2011

InstallShield Automation Interface on 64-bit System

If you use a script to automate your build process using the InstallShield 2011 Automation Interface on a 64-bit OS you must call the script using a 32-bit process. Otherwise you may get this error: "Automation server can't create object" (error code: 800A01AD). Launching the script from a 64-bit process like C:\Windows\System32\cmd.exe you'll get the following error:

To get around this use the 32-bit version of command prompt which is here: C:\Windows\SysWOW64\cmd.exe. For more detail see InstallShield's webpage about this issue.