Skip to main content

Posts

Showing posts from February, 2012

Compiling C/C++ With the Math Library

Quite often I see, or get asked why certain math functions don’t compile properly when all the necessary includes are correctly applied. For example: #include <stdio.h> #include <math.h> int main() { double value = 9.0; double ans = sqrt(value); char szBuffer[256]; sprintf(szBuffer,"%f",ans); printf("%s",szBuffer); return 0; } Compiling the above code with the command gcc main.c gives an error indicating that sqrt is undefined. $ gcc main.c /tmp/ccHazXRB.o: In function `main': main.c:(.text+0x48): undefined reference to `sqrt' collect2: ld returned 1 exit status The simple problem here is that the code isn’t linked against the math library so the math functions cannot be resolved. The correct way to compile is using the -lm option which instructs the linker to use the math library. $ gcc main.c -lm One thing to remember is the location of the -lm option. This usually has to be placed after the filename that is being c...

Updated Enigmail

Last week I posted about not being able to use Enigmail in Thunderbird to read encrypted messages. My solution was to manually download the latest version of Enigmail and install locally. Good news today to make the task easier. The new version (enigmail 2:1.3.5-0ubuntu0.11.10.1) of Enigmail has been pushed out to the Ubuntu Software Centre and can be installed by updating with apt-get .

10 Useful git Commands

git status Show the working tree status, i.e. what have I changed and what have I added. git commit -a -m “my message” Commit all my changes and store with the message “my message”. git push origin Push all my commits back to the remote server. git tag List the tags in the current branch. git tag -a myTag -m “tag message” Create a tag called myTag and store with the message “tag message”. git show myTag  Show information about the tag myTag. git branch myBranch Create a branch called myBranch. git branch Display a list of all branches. git merge myBranch Merge the changes made on the current branch into myBranch. git checkout myBranch Switch code base to the branch myBranch.

Cannot Read Decrypted Messages in Thunderbird 10 Using Enigmail

I’ve just upgraded to Thunderbird 10 today on Ubuntu 11.10. Upon running Thunderbird I got the following error message stating that Enigmail had failed to start. Enigmail: Enigmime Service not available To permanently avoid this alert, either fix the problem or uninstall Enigmail. Click on the Help button for more details. The version of Enigmail that is downloaded and installed via the Ubuntu Software Centre is 1.3.4. It seems this version doesn’t work properly with Thunderbird 10. To fix the problem, remove the 1.3.4 plugin (choose “Tools | Addons”) and then install the new 1.3.5 version available from the Enigmail download site. Update: A new version of Enigmail has been pushed out to the Software Centre. See here for more details.

Review of JBoss AS 7 Configuration, Deployment and Administration

JBoss 7 is the latest Java EE application server to be released by Red Hat. Version 7 is certified against the Java EE 6 Web Profile and has been developed with productivity and speed in mind – the current version offering significant speed enhancements over previous versions. Not only is AS7 available as a download for developers, it is also an important aspect of Red Hat's OpenShift Platform-as-a-Service (PaaS) offering. JBoss AS 7 Configuration, Deployment and Administration explains how to use all the components that make up the application server covering (as you would expect from the title) configuration, management, deployment and administration. Many of these features are different in AS 7 from previous versions of JBoss AS so this book is in invaluable resource. The book is aimed at administrators, developers and testers, so whatever your role, chances are you will find something useful in the book. The book starts by showing how to download and install AS7. ...

PrimeFaces 3.1 Released

Prime Technology  have announced the release of PrimeFaces 3.1 - " The Ultimate JSF Component Suite ". PrimeFaces contains over 100 JSF components and over 30 ui themes; a mobile optimized rendering engine and high performance push features which alltogether make Prime Faces one of the leading JSF 2 component suites. For a demonstration of the different components check out the Prime Faces  Showcase . Both the PrimeFaces libraries and source code can be downloaded from  here  - this also contains details of how to configure Prime Faces within a Maven build.

Free JBoss AS 7 Book

I just wanted to remind everyone of the free competition that is going on over at developinjava.com to win a free copy of JBoss AS 7 Configuration, Deployment and Administration by Francesco Marchioni. To enter, all you have to do is visit the competition and comment on the book. What are you waiting for?  Go and enter now and you could be the proud winner of a copy of the book.

A Simple Makefile for a GTK/GTKMM Project

When compiling small applications, its fairly easy just to compile using g++ from the command line. If you’re compiling anything more complex than a single file, its probably easier to use a Makefile. This example Makefile demonstrates how to compile an application that uses the GTKMM library. NAME=my-app CFLAGS=-g -Wall -o $(NAME) GTKFLAGS=`pkg-config --cflags --libs gtkmm-3.0` SRCS=main.cc myapp.cc CC=g++ # Do all all: main # Compile main: $(SRCS) $(CC) $(CFLAGS) $(SRCS) $(GTKFLAGS) # Clean clean: rm -f $(NAME) rm -f *.h~ rm -f *.cc~ rm -f Makefile~ rm -f *.glade~