I read this blog recently and thought, "yes, that’s true". I’ve seen a lot of code that has resource leaks because programmers don’t properly close database connections. This is one of the most compelling reasons to use something like Spring’s database classes – they remove the boilerplate code for you and make using JDBC just that little bit easier. If you don’t want to use Spring, then its not too difficult to write a couple of library methods that will close all database connections correctly.
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~
Comments
Post a Comment