> U __ZN5Timer5startEv (in main)
> T __ZN5Timer5startEv (in lib)
Well that's exactly what I expected to see, but I'm stumped as to why it doesn't work.
So I grabbed the zip, and tried it on cygwin.
With a couple of edits to the makefile, it works.
First I got this
ar: libUtil.a: No such file or directory
So I fixed the invocation of ar
Then I got this
main.cpp:2:19: Timer.h: No such file or directory
So I fixed the FLAGS
Then all was well...
Code:
$ make
g++ -ansi -W -Wall -I. -c Timer.cpp
g++ -ansi -W -Wall -I. -c main.cpp
main.cpp:8: warning: unused parameter 'argc'
main.cpp:8: warning: unused parameter 'argv'
g++ -ansi -W -Wall -I. -o main -L. main.o -lUtil
$ ./main
123
Time elapsed: 2653000 usecs.
Time elapsed: 0 usecs.
Time elapsed: 0 usecs.
Time elapsed: 0 usecs.
The makefile now looks like this
Code:
$ cat Makefile
CC = g++
FLAGS = -ansi -W -Wall -I.
all: libUtil.a main.o
$(CC) $(FLAGS) -o main -L. main.o -lUtil
libUtil.a: Timer.o
@ar crs libUtil.a Timer.o
Timer.o: Timer.cpp Timer.h
$(CC) $(FLAGS) -c Timer.cpp
main.o: main.cpp
$(CC) $(FLAGS) -c main.cpp
Just for good measure, I did this as well
Code:
$ g++ main.o Timer.o
$ ./a.exe
234
Time elapsed: 1582000 usecs.
Time elapsed: 0 usecs.
Time elapsed: 0 usecs.
Time elapsed: 0 usecs.
If you just link both objects, does it work?
It might tell us whether it's a linker problem or a library problem.