Blog‎ > ‎

Good Samaritan

This section includes posts that are supposed to help people.  Things like install software, troubleshoot problems, etc.

The easy way to get subversion revision information into your autotools project

posted Sep 14, 2008, 2:04 PM by Brian Tanner   [ updated Jun 3, 2009, 7:25 AM ]

Introduction

I have been trying to figure how to get the build number automatically included into my autotools project so that when I do ./myprogram --version it will print out the build number. This is very handy because then if there is a problem with code someone is using, you can figure the EXACT version immediately.

I quickly came across this page:
http://www.mhoenicka.de/system-cgi/blog/index.php?itemid=999

This looks interesting, but I couldn't make it work right.  My makefile was giving me errors, and after hours of trying various ways to fix it, I gave up.

Then I thought of a much simpler (IMHO) way that used the same basic idea.   That is listed last on this page (the old/bad way), because since then I've thought of and been told about some even better ideas.

Cross-Platform Easy Way : Using Keywords

There is a much easier way than what I describe below, and I find it more robust.

You need to use svn keywords.  Look them up. They are cool.  Basically, you have a file called: myfile.c, and you do:
svn propedit svn:keywords

Then when you favorite editor comes up you can set some keywords that you want to be replaced.  For example, if you use Revision, then anywhere in myfile.c that you put:
$Revision$, subversion will replace it with something like $Revision: 882 $ AUTOMATICALLY, every time you commit.  Score.  

You can also edit your subversion config file (on *nix/Mac it's in ~.subversion/config) so that it always replaces keywords.  Then you can put them in your comments section of each source file.

So now, just put this function in myfile.c and make sure its prototype is known to the code you want to call it from:
char svnVersionString[1024];
char* __get_svn_version(){
int howMuchToCopy=0;
char *theVersion="$Revision: 882 $";
howMuchToCopy=strlen(theVersion+11) - 2;
assert(howMuchToCopy>0);
memcpy(svnVersionString, theVersion+11, howMuchToCopy);
    svnVersionString[howMuchToCopy] = '\0';
return svnVersionString;
}
Now, if you write code like:
printf("The svn revision number is r%s\n",__get_svn_version() );

You will get code that automatically outputs the current global version of the project, without any mess with autotools, local copies of version numbes, etc, etc.

Cross Platform Windows Way -  Use SubWCRev

John Muczynski recently contacted me and suggested I look into SubWCRev.  If you're on Windows, this program comes with Tortoise SVN, and seems to make it even easier to get version information into your program:
http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-subwcrev.html

The First Cross Platform Attempt (the old/bad way)

The basic idea is to either use svnversion to get the current build number if possible, and if not, fall back to  a file that has been saved.  This way, if you build from code checked out of subversion, you have the info, and if you build from a download, you still have it.

The approach used in the link above comes from the subversion people originally, and they want you to use your Makefile to actually create a C source file with a function that gives you the build number.

Instead, you could just define a symbol, say called SVN_VERSION, and then do whatever you want with it in your code.

There just a few steps.

Update configure.ac

This is taken almost directly from the link above.  Basically, we're going to check if svnversion is installed and working, and if so get the build number from it.  IF not, we're going to get the build number from a file we stored one of the other times that we built.  We're then going to define a symbol called SVN_VERSION that has the string as its value.  This is like doing #define SVN_VERSION "383" or similar.

AC_PATH_PROG(svnversioncommand, svnversion)
if test "X$svnversioncommand" = "X" || test `$svnversioncommand -n '.'` = "exported"; then
AC_DEFINE_UNQUOTED(SVN_VERSION, ["`cat saved_svn_version.txt`"], [repository svn version])
else
AC_DEFINE_UNQUOTED(SVN_VERSION, ["`svnversion -n`"], [repository svn version])
`svnversion -n > saved_svn_version.txt`
fi

Update Makefile.am

You'll want to make sure that saved_svn_version.txt will be included when you do "make dist".  So, add it to your EXTRA_DIST, or make an EXTRA_DIST if you don't have one already

EXTRA_DIST = saved_svn_version.txt

Use the value in your source code

printf("SVN VERSION is %s\n",SVN_VERSION);

That's all there is too it.

Caveats/Limitations

The SVN_VERSION will only get updated when you run configure.  If you are like me and "make distclean" before committing your latest revisions, then this is fine, because next time you want to build your code you'll have to ./configure and the values will be updated.  I guess the downside is that if you test some changes, make distclean, then commit, it won't show that the version has changed.  You'll have to ./configure and then make distclean one more time before committing.  I can live with that.  Someone more savvy might point out that there probably a hook you could write somewhere to update saved_svn_version.txt at some point in the process.

So You're Writing A Masters Thesis (At the U of A)

posted Jul 20, 2008, 10:36 AM by Brian Tanner

This is a document I created in 2005 when I was putting my Masters together at the University of Alberta.  It might not be in great shape anymore, but I'll post it, and if its wrong, please let me know and I'll update it.

So, you’re writing a Masters thesis

Introduction

I just spoke with Edith about the ins and outs about scheduling and organizing a Masters thesis defense.  Things are pretty straight-forward, but I wanted to write it all down in the hopes that it might save someone else some time.

Also, the most helpful URL I have for you is from the FGSR website, it has many details about the thesis and defense.
http://gradfile.fgsro.ualberta.ca/gradmanual/eight.htm

Finally, I’ve put this together for your benefit, but at the same time I take no responsibility for it. If I lied in here, or made a mistake, I will not be held responsible for the consequences.

Time Line

3.5-4 weeks

This is how long you need between finishing your thesis and having your defense.  It seems that this cannot be shortened, so if you want to defend at some particular time, make sure your thesis is *done* 4 weeks before that.

If you want to graduate in the fall (and/or start a Ph.D in September), then you can defend your thesis as late as mid-September.  You need to get your final, revised, thesis and all of the paperwork to FGSR NO LATER than October 3rd.  It is better to finish before the end of August.  If you can’t defend in August, your life is not over --> you CAN start your Ph.D courses in September and everything is fine as long as you make the October 3rd deadline.
What to do

  1. There is a form you need to get from Edith Drummond.  You need to fill this out and get it to her around the 4 week mark before your defense.  You’ll also need to supply Edith with an abstract when you submit this form.

  2. You need 3 committee members.  2 can be from within the department (at least 1 of these should be your supervisor), and 1 needs to be external to the department.  Must be from a different academic unit within the university. 

    Note: It is your supervisors responsibility to contact the committee members and schedule the defense.  You should discuss it first, but this is on them.  The reason (I’m led to believe by certain documents I read) is as follows: If someone makes a mistake and there is a problem with protocol, it should not be your fault, it should be your supervisor’s fault.

  3. Get your thesis to your committee 3 weeks before your defense.  This doesn’t have to be professionally bound or anything fancy; just get something that looks good to them 3 weeks before your defense, so they have adequate time to read it.

  4. You need to schedule a seminar.  This is a 1 hour talk, about a week before your defense.  It seems that there are no major constraints here, pick a time that works for you.  Get an electronic copy of your title and abstract to Karen at least a week before so she can announce it to the department.

  5. You need to schedule your defense.  Again, no major constraints.  As long as it works for you and your committee, things are fine.  It’s going to take a couple of hours, so don’t schedule it over lunch. The department will supply someone to chair the examination.

  6. Get an extra copy of your thesis to the chair a couple days before the defense so that the chair can look it over.

  7. Bring extra copies (5-8) of the signing sheet to your defense.  (I don’t know what the signing sheet is, but Edith told me this.)


That’s it.
If you have any questions, ask someone else and then tell me the answer and maybe I’ll keep this document up to date. :)

How to install it++ on Mac OS X 10.4.9

posted Feb 28, 2008, 8:19 PM by Brian Tanner   [ updated Feb 28, 2008, 8:19 PM ]

How to install it++ on Mac OS X 10.4.9

Note: Thanks to Alex Alvarado for pointing out a small error with the instructions. Also thanks to Brad Joyce for pointing our numerous other leaps in the directions.

There is some cool software called it++ which lets you write and do Matlab/Octave-like things in C++. So far I've had some trouble getting it installed.

You see, it uses blas, cblas, LAPACK, and fftw (and maybe some other stuff). Generally you'd want to have all these installed yourself before using it++, but on Mac OS X (since 10.2 I think), everything except fftw comes in the vecLib framework (which comes WITH OS X).

So, how do you get this thing running?

1) You need a fortran compiler, and apparently you won't have one by default. In theory, you can install it with Fink. That didn't work for me. I went to http://hpc.sourceforge.net/ and used his binaries . You're looking for g77 3.4. There are instructions there on exactly how to unpack the archive so that everything goes to the right place. Works great. Make sure that you add it to your path in ~/.profile and that you restart terminal (so that the changes take effect). G77 will go in /usr/local/bin, so you should add a line to your ~/.profile like:
export PATH=/usr/local/bin:$PATH

2) You need fftw. I just downloaded, did a ./configure , make, sudo make install and it went off without a hitch.

3) Now you want to install it++. First, go download and unpack it. Then, you should be able to:
./configure

You'll see this (hopefully)
------------------------------------------------------------------------------
itpp-3.10.10 library configuration:
------------------------------------------------------------------------------

Directories:
- prefix ......... : /usr/local
- exec_prefix .... : ${prefix}
- includedir ..... : ${prefix}/include
- libdir ......... : ${exec_prefix}/lib
- docdir ......... : ${datarootdir}/doc/itpp-3.10.10

Switches:
- debug .......... : no
- exceptions ..... : no
- html-doc ....... : no
- shared ......... : yes
- static ......... : no

Documentation tools:
- doxygen ........ : no
- latex .......... : yes
- dvips .......... : yes
- ghostscript .... : yes

Testing tools:
- diff ........... : yes
- sed ............ : yes

External libs:
- BLAS ........... : yes
* MKL .......... : no
* ACML ......... : no
* ATLAS ........ : no
- CBLAS .......... : yes
- LAPACK ......... : yes
- FFT ............ : yes
* MKL .......... : no
* ACML ......... : no
* FFTW ......... : yes

Compiler/linker flags/libs/defs:
- CXX ............ : g++
- F77 ............ : g77
- CXXFLAGS ....... : -DASSERT_LEVEL=1 -O3 -fno-exceptions -pipe
- CXXFLAGS_DEBUG . :
- CPPFLAGS ....... :
- LDFLAGS ........ :
- LIBS ........... : -lfftw3 -llapack -lblas

Note: If y ou didn't install fortran (g77), it WONT FIND LAPACK OR BLAS. That took me a long time to sort out. You've been warned.

Now, if everything went according to plan, you can do:
make
make check

This will run some checks to make sure things are working ok.

sudo make install

That's it, now you're done. Great work. Watch for a follow up post of how to use it++!

Posted by Brian Tanner at 9:19 AM  

Labels: "good samaritan", "os x"

6 comments:

Cosmin said...

Thanks!

May 30, 2007 1:59 PM  
Cosmin said...

Also, Brad and Andrew helped me get it working with xcode, I just added /usr/local/include to the Header Search Paths, /usr/local/lib to the Library Search Paths and disabled the ZeroLink option. So now I can compile and run their matrix inversion example

May 30, 2007 2:46 PM  
Cosmin said...

Almost forgot, I also had to add -litpp -lfftw3 -llapack -lblas to "Other Link Flags"

May 30, 2007 4:15 PM  
Anonymous said...

Just typing "./configure" didn't do the trick for me, I had to explicitely specify to use the vecLib framework: "./configure --with-blas='-framework vecLib'".

June 1, 2007 8:34 AM  
Anonymous said...

I got it to work with fftw3 and g77 from Fink using...

setenv LDFLAGS "-L/sw/lib"
setenv CPPFLAGS "-I/sw/include"
./configure --with-blas='-framework vecLib'
make
make check
sudo make install

Thanks!

June 19, 2007 8:41 PM  
lisa said...

I installed fftw3 and it++ pacakges and followed all the instructions described, but I'm unable to compile Fortran programs invoking lapack/blas routines. The error message is as follows:
/usr/bin/ld: can't locate file for: -llapack
collect2: ld returned 1 exit status

Samsung ML-1610 Printer on Mac OS X (Intel Mac)

posted Feb 28, 2008, 8:19 PM by Brian Tanner   [ updated Feb 28, 2008, 8:19 PM ]

NOTE: Some of the steps in these instructions don't work anymore because the files don't exist.  I've updated the instructions to work on Leopard, which you can check out here:  Samsung ML-1610 Printer on Mac OS X 10.5 Leopard (Intel Mac) .

This is a transplant of a blog entry from my old site here:

http://briantannerresearch.blogspot.com/2007/05/samsung-ml-1610-printer-on-mac-os-x.html  


Samsung ML-1610 Printer on Mac OS X (Intel Mac)

Hi. I have tried so many times to figure out how to get my Samsung ML-1610 printer working on my Intel Mac.

There are many quick explanations on the web of how to do this, but they don't seem to have all of the details... and as a non Unix guru, I've always had trouble making them work.

--

Ack. I just spent hours trying to actually get this working. I don't know why I try to be so clever. The instructions are posted below. The things is, all of the directions use OLD files, made for powerPC. I'm using a new Intel Mac, so I thought instead of following the direct links from instructions (to old files), I should find the up to date versions. NO LUCK with that.

Moral of the story: don't try to be clever. Here are the directions.
1) Go here: http://www.linux-foundation.org/en/OpenPrinting/MacOSX/hpijs

2) Download and install espgs-7.07.1.ppc.dmg (5.4 MB)

"But Brian" (you say), "that's powerPC! I have an Intel Mac." That's true.

You might also find it interesting to know that ESPGS (ESP Ghost Script) has been replaced by Gutenprint some time ago. It doesn't matter, don't go for Gutenprint. I tried that route, and had no end to my problems. I tried to build it from source and had errors, then installed it from a disk image only for it to 'work' but instead of printing my documents it would just fire up my printer and then not do anything.

Just install the old one from the page.

This worked on OS X 10.4.9 on an brand new Intel Imac on May 5 2007.

If you are more clever than me and got it working with newer software please tell me.

3) Download and install hpijs-foomatic-2.0.2.ppc.dmg (1.6 MB)

Same story, I know, I know, it looks old. It works. Suck it up. :P

4) Go to System Preference --> Print & Fax

5) Click the + button to add a printer

6) Samsung should be in the list now! Thank heavens. But, ML-1610 isn't there! Oh no! Just use ML-1210 Soomatic + GDI. Seems to work fine.

There, all done.

Again, if you have a more up to date method than this, please share it with me. I'm just glad to finally have this working.

Posted by Brian Tanner at 1:55 PM  

Labels: "good samaritan", "os x"

8 comments:

Perez said...

G'day Brian,
I tried this on an Intel MacBook purchased on 16 May with OS X 10.4.8. Everything looked groovy but...
even ML-1210 +GDI didn't appear in the list.

I tried selecting other random ML printers in the list with no luck. Do you have any clues?
Should I be running 10.4.9?

In earnest,

Perez

May 16, 2007 6:35 PM  
Perez said...

Hold it!
I updated to OS X 10.4.9

When I rebooted list of printers was much shorter but it did include ML-1710, which works!

You're a genius.

Perez

May 16, 2007 7:57 PM  
Brian Tanner said...

Hey Perez. Glad it worked out! Weird that there were different options. I hope the direction are actually correct and that I didn't get it working by some weird fluke.

May 16, 2007 9:36 PM  
Anonymous said...

Thanks man!

June 18, 2007 7:42 AM  
matt said...

Samsung Australia still list the official OS X driver, maybe give that a try? I use it with my ML-1210

July 15, 2007 8:57 AM  
Anonymous said...

HI guys , Try to 1650

August 15, 2007 5:23 PM  
Anonymous said...

I tied this, and the ML-1210 showed up (my printer), but when i tried to print nothing happened. Sometimes the printer would indicate it was getting info, but nothing ever printed!

September 5, 2007 9:53 PM  
Junaid said...

Hi guys, I'm trying to click on the hpijs-foomatic-2.0.2.ppc.dmg (1.6 MB) link but it doesnt seem to appear, is there anywhere else from where i can download it?

Samsung ML-1610 Printer on Mac OS X 10.5 Leopard (Intel Mac)

posted Feb 28, 2008, 8:17 PM by Brian Tanner   [ updated Aug 15, 2009, 6:44 AM ]

Samsung ML-1610 Printer on Mac OS X 10.5 Leopard (Intel Mac) Edit PDF Print E-mail

I have a section of this site that explains how to explain the ML 1610 Printer on Mac OS X (10.4 -- Tiger) on an Intel iMac .  I recently upgraded to Leopard, and my printer disappeared.  So again, I'll journey into the Hell that can be getting certain peripherals working on Mac and try to get my printer installed.


 

The New/Best Way -- Guigo's Driver (March 4, 2008)

Guigo sent me an e-mail about a new way to get the ML1610 working.  His method works on Tiger and Leopard, and is much easier than the way I originally found.  I recommend you use his method, especially since the links in my original post seem to not work anymore.

Guigo's Driver

I ported the free Splix driver (which supports the ML1610 among a lot of other printers) to mac os x. I haven’t tested it on Tiger, but it should work too. You can download it at http://www.guigo.us/mac/splix
Feedback is welcome! thanks 
April 5, 2007 Arto tells me that the Splix driver actaully works on Leopard, and even allowed him to hook the printer up through his wireless network.

On Jan 17 I received the following.  If anyone tries this and verifies, please let me know.

Samsung Australia ML-1710 Driver (Dario's Method)

Dario Sait sent me this some time before Guigo contacted me with his driver.


Here is a much easier way than the original method (but not as good as Guigo's) to get that printer work (works at least for Tiger and for Leopard).  On the Australian website is a driver for the ML-1710 that works for the ML-1610 too.

little howto:

Just visit the Samsung.com-Website and then change your Region to Australia. A search for the ML-1710 leads you to the following page (first result):

http://www.samsung.com/au/support/download/supportDown.do?model_nm=ML-1710&mType=DR&vType=L

There you can download that driver for Mac OS 10.5 and it works perfectly for me.

Maybe you can add this information to your website [1] because it is one of the first search results in google (Congratulations :) ) and it may help some people.

Best Regards
Dario Sait
I've chronicled my troubleshooting process, but there are some wrong turns in there.  So, if you want the whole story, look at the next section "The Journey", if you only want the results, scroll down to "The Directions".


The Original Method  

The following sections describe my original journey and methods for getting the printer working.  They are not recommended anymore.  In fact, I think these links are even dead.  I recommend you use Guigo's driver at the top of the page.

The Journey 

I'm going to trace through my old blog post directions, see if that works, and diverge when it doesn't.  So, here we go:

1) Download and install espgs-7.07.1.ppc.dmg (5.4 MB)

Ok, that installed successfully.

 2) Download and install http://www.openprinting.org/download/printdriver/macosx/hpijs-foomatic-2.0.2.ppc.dmg (1.6 MB)

Oh darn.   That file is gone.  Crap. Quick web search, found that Daniele Sluijters  has a post on his blog about  this printer with Leopard. Unfortunately it's not helpful.

 Hmm, looking back at the http://www.openprinting.org/download/printdriver/macosx/ , I see there is a file that looks interesting hpijs-2.7.10-UB.dmg  

So, I downloaded that.  There is a file in the disk image with a list of support printers, and while ML 1610 isn't there, I'll try to install this anyway.  Like a real man, I won't read the readme.

 Hehe, funny story.  The installer quit half-way through and told me to read the readme file.

"Additional software: All Mac OS X users MUST install Foomatic-RIP and Ghostscript. This driver will not function without it!"

 So, that link takes you here:

http://www.linux-foundation.org/en/OpenPrinting/MacOSX/foomatic

 And now I'm downloading a PPC disk image again : foomatic-rip-3.43.2.15.ppc.dmg (88KB).  I feel like I've played this game before.  Ok, downloaded, and installed.

 Now let's try the hpijs installer again.  Success!

Let's try and continue where my old instructions left off:

4) Go to System Preference --> Print & Fax

5) Click the + button to add a printer

6) My printer is listed.  So I click it.  Now the computer is search for drivers.... and the list of available drivers is empty.  That's heartbreaking.  Oh wait, choose "Select a driver to use..." then a bunch of options pops up.  Oh, Leopard is cute, there is a little spotlight box to help us find what we want.  Let's type "ML".  Looks like there are quite a few ML drivers, good.  I'll choose ML1650, because it's the closest to my model, ML 1610.  If you prefer "The price is right" rules, you could have taken ML 1450.   I click "add" and now have a printer listed as installed on my computer.  Double click it, go up to the "printer" menu, and choose "print test page".  I wait about 30 seconds, and then...nothing.  How sad.  Ok well, in my previous instructions, I had success with ML-1210, so I'll remove the printer and try that.... YES!  It works!

Ok, so now I wonder if any of these steps were superfluous.  I'm not sure, so I'll just sum up what I did.

The Directions

1) Download and install espgs-7.07.1.ppc.dmg (5.4 MB)

2) Download and install foomatic-rip-3.43.2.15.ppc.dmg  (88 KB)

3) Downlad and install hpijs-2.7.10-UB.dmg  (4 MB)

4) Go to System Preference --> Print & Fax

5) Click the + button to add a printer

6) Pick your printer and then for driver choose: "Select a driver to use..."

7) Pick Samsung ML-1210 Foomatic + GDI

You're done!  

On this new website there isn't yet an easy way to add comments, so feel free to e-mail me: brian@tannerpages.comThis e-mail address is being protected from spam bots, you need JavaScript enabled to view it with your experience and I'll tack it on here. 

 

Update from Rosyna

7) Pick Samsung ML-1210 Foomatic + GDI

This driver does not come with any of the foomatic or hpjis downloads you previously instruct to install. It may have come with an older version of the software you had installed. To get the driver, go to http://openprinting.org/show_printer.cgi?recnum=Samsung-ML-1210 and download http://openprinting.org/ppd-o-matic.cgi?driver=gdi&printer=Samsung-ML-1210&show=0 then after it is downloaded, place it in /Library/Printers/PPDs/Resources/ (the finder may ask you to authenticate). *Then* you can choose "Samsung ML-1210 foomatic/gdi".

If the PPD is not installed beforehand, it will not appear in the list.

(I recently had to get an ML-1210 printer working on 10.5 and your instructions worked nicely except for the PPD step).
 

How to install sCons on Intel Mac OS 10.4.9

posted Feb 28, 2008, 8:15 PM by Brian Tanner   [ updated Feb 28, 2008, 8:15 PM ]

How to install sCons on Intel Mac OS 10.4.9

sCons (http://www.scons.org/) is an awesome, cross platform, python based build tool. I am using it for my bt-glue project.

Anyways: installation is quite straightforward. But you need to know 1 key thing! Get the latest build, and NOT the stable build. The stable build is several years old and missing features you want. I promise.

1) Download the latest tarball, unpack it
2) Execute: sudo python setup.py install
3) Edit your .profile and update your path to include:
/System/Library/Frameworks/Python.framework/Versions/Current/bin

If you don't know what that means, that's ok.
i) Create a file in your home directory called ".profile".
ii) Add a line like this:
export PATH=$PATH:/System/Library/Frameworks/Python.framework/Versions/current/bin

iii) Save the file

Now, when you open a new terminal session, you should be able to type: scons -version and have good things happen.

Happy sCons'ing.

1-6 of 6