title: How do I convert a normal Makefile to create a static executable that can be used on another computer
body: <p>I got the <code>temp_conversion</code> example program from mosquitto C++, from <a href="https://github.com/eclipse/mosquitto" rel="nofollow noreferrer">here</a>. I have looked at <a href="https://stackoverflow.com/questions/31421616/c-creating-static-library-and-linking-using-makefile">this thread</a> but I don't quite get it, I have minimal experience with makefiles. I'm not sure if static libraries even work this way, but I have 2 questions:</p>
  
  <ol>
  <li><p>Is it possible to be able to move the executable to another pc and have it still run? (without installing mosquitto libraries there, maybe copying a static library created by the makefile with it)</p></li>
  <li><p>How do I convert this makefile to make a static "moveable" executable?</p></li>
  </ol>
  
  <p>The makefile:</p>
  
  <pre><code>CFLAGS=-Wall -ggdb -I../../lib -I../../lib/cpp
  LDFLAGS=-L../../lib ../../lib/cpp/libmosquittopp.so.1 ../../lib/libmosquitto.so.1
  
  .PHONY: all clean
  
  all : mqtt_temperature_conversion
  
  mqtt_temperature_conversion : main.o temperature_conversion.o
  ${CXX} $^ -o $@ ${LDFLAGS}
  
  main.o : main.cpp
      ${CXX} -c $^ -o $@ ${CFLAGS}
  
  temperature_conversion.o : temperature_conversion.cpp
      ${CXX} -c $^ -o $@ ${CFLAGS}
  
  clean : 
      -rm -f *.o mqtt_temperature_conversion
  </code></pre>