View Full Version : Linking (ld) problems (g++)

Jun 25, 2007, 02:04 AM
Trying to compile a small software package (http://csi.usc.edu/chugg/tools/cycles.shtml) I've downloaded from the web. It uses CBLAS (linear algebra library), which, as I understand, is pre-installed on OSX. Btw, I'm running 10.3.9.

The package contains .cpp and .h files, but no Makefile. Within my experience with compiling, I've tried to set up a Makefile (see below), but I get problems during linking:
$ make
g++ -c main.cpp
g++ -c Short_Cycle_Counter.cpp
g++ -c Short_Cycle_Matrix.cpp
g++ -o ccount main.o Short_Cycle_Counter.o Short_Cycle_Matrix.o
ld: Undefined symbols:
make: *** [ccount] Error 1
locate cblas.h gives me /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/Headers/cblas.h
I've tried changing the include to cblas.h in many possible ways, but (as long as the path to the file cblas.h is valid), I always get the same error.

Hope someone can help (and that the error is not too obvious) :)
Here's the Makefile I've made:
CXX = g++

ccount: main.o Short_Cycle_Counter.o Short_Cycle_Matrix.o
$(CXX) -o ccount main.o Short_Cycle_Counter.o Short_Cycle_Matrix.o

main.o: Short_Cycle_Counter.h Short_Cycle_Matrix.h main.cpp
$(CXX) -c main.cpp

Short_Cycle_Counter.o: Short_Cycle_Counter.h Short_Cycle_Counter.cpp
$(CXX) -c Short_Cycle_Counter.cpp

Short_Cycle_Matrix.o: Short_Cycle_Matrix.h Short_Cycle_Matrix.cpp
$(CXX) -c Short_Cycle_Matrix.cpp

rm *.o ccount