I'm creating my first good sized project, and decided to take the opportunity to learn how to write Makefiles and libraries. I made two out of the helper classes I had written. One works, the other will not link successfully.
**EDIT**
I should mention that if I compile Timer on its own and link to Timer.o it works fine. Putting it into a library breaks it though
Here is the error I get
Timer is in my Util library, which will not link successfully. Here is the makefile that generates that particular libraryCode:make g++ -m64 -O2 -o exec -framework OpenGL -framework GLUT -lThreading -lUtil main.o Undefined symbols: "Timer::~Timer()", referenced from: sync_thread(void*) in main.o "Timer::Timer()", referenced from: sync_thread(void*) in main.o "Timer::start()", referenced from: sync_thread(void*) in main.o "Timer::reset()", referenced from: sync_thread(void*) in main.o "Timer::getMicroSeconds()", referenced from: sync_thread(void*) in main.o ld: symbol(s) not found collect2: ld returned 1 exit status make: *** [exec] Error 1
If anybody can help me out I would greatly appreciate it. Attached is an archive with two folders. include contains the source for both libraries. To compile and create the library run 'make' then 'make install'. This will put two libraries in /usr/lib and a few headers in /usr/include. 'make uninstall' will remove themCode:CC = g++ FLAGS = -m64 -O2 -ansi -W -Wall -c LIBDIR = /usr/lib INCDIR = /usr/include all: Timer.o install: @ar -cvq libUtil.a Timer.o @mv libUtil.a $(LIBDIR)/libUtil.a @cp Timer.h $(INCDIR)/Timer.h uninstall: @rm $(LIBDIR)/libUtil.a @rm $(INCDIR)/Timer.h clean: @rm Timer.o Timer.o: Timer.cpp Timer.h $(CC) $(FLAGS) Timer.cpp
I'm writing this on OS X, which is what the default files will compile on. I also included an archive with what I think the proper code to compile on linux is (it's untested tho).
As I said, I'm also new with Makefiles. If anybody has comments/suggestions or if there's any styles or conventions that I'm violating or omitting, or wants to call me a moron, every bit of advice is welcome
Hmmm..seems that I can't upload archives. Here are rapidshare links to the files
OS X zip
OS X tarball
Linux zip
Linux tarball



LinkBack URL
About LinkBacks





