I'm trying to link three files using g++. The files are simulation.o
, lattice.o
and thermodynamics.o
.
They're a bit long, but the gist of it is. I have a makefile:
main: simulation.o thermodynamics.o lattice.o
g++ simulation.o thermodynamics.o lattice.o
simulation.o: simulation.cpp lattice.o lattice.h thermodynamics.o thermodynamics.h
g++ -std=c++11 simulation.cpp -o simulation.o -c
thermodynamics.o: thermodynamics.cpp
g++ -std=c++11 thermodynamics.cpp -o thermodynamics.o -lgsl -c
lattice.o: lattice.cpp
g++ -std=c++11 lattice.cpp -o lattice.o -c
It passes the compile stage, but never links them. For each method I need from a different file, it simply says that it's undefined, and and refuses to find them.
The classes and methods are all defined in the .h
files. But for some reason I can define an external function but not an external class.