Skip to content
Advertisement

makefile : How to link object files

I have makefile and I need to link two objects into “main” object

They are -> oglinet.o and libshape.o

their path in system -> home/pi/openvg/

Problem :I need to write full path and objects name(home/pi/openvg/libshapes.o) is possible to “make” them as Makefile variable for example home/pi/openvg/libshape.o into $(OBJ1) in makefile rule ?

Tried to make them as variable for example Obj1= /home/pi/openvg/oglinit.o if I compile that the compilator freeks out.

Working Makefile

JavaScript

Expectations: what libshape.o and oglinit.o objects and thei path in system are “stored” in some kind of variable/variables and if I need I can easily make changes in makefile /

After help of Chriss Dodd (not ideal?) makefile looks like this

JavaScript

Advertisement

Answer

You usually want to make all the object files you’re linking dependencies of the target. Then you can just use $^. You also usually want all the libraries after all the object files on the linker command line. With both of those you end up with something like:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement