title: How to link libraries on Raspberry Pi cross compiler?
body: <p>I followed <a href="https://solarianprogrammer.com/2018/05/06/building-gcc-cross-compiler-raspberry-pi/" rel="nofollow noreferrer">this guide</a> to build a cross compiler for Raspberry Pi ARMv7. It works fine (compiles ok hello world) but the problem is I can't use Raspberry Pi libraries such as wiringpi, sqlite etc.</p>
  
  <p>This is my Makefile.</p>
  
  <pre><code>CC = /opt/cross-pi-gcc/bin/arm-linux-gnueabihf-g++
  QUOTE := "
  CFLAGS = -g -lwiringPi -pthread -lpthread
  PROGRAM = lora
  OBJDIR = obj
  
  CPP_SRCS += \
  src/main.cpp \
  src/radio/sx1276/sx1276.cpp \
  src/radio/radio.cpp \
  
  OBJ_FILES += \
  $(OBJDIR)/main.o \
  $(OBJDIR)/sx1276.o \
  $(OBJDIR)/radio.o \
  
  
  all: make_dir $(OBJ_FILES)
      $(CC) $(OBJ_FILES) $(CFLAGS) -o $(PROGRAM)  
  
  make_dir:
      mkdir -p $(OBJDIR)
  
  $(OBJDIR)/main.o: src/main.cpp
      $(CC) $(CFLAGS) -c -o $@ $&lt;
  
  $(OBJDIR)/service.o: src/service/service.cpp
      $(CC) $(CFLAGS) -c -o $@ $&lt;
  
  $(OBJDIR)/sx1276.o: src/radio/sx1276/sx1276.cpp
      $(CC) $(CFLAGS) -c -o $@ $&lt;
  
  $(OBJDIR)/radio.o: src/radio/radio.cpp 
      $(CC) $(CFLAGS) -c -o $@ $&lt;
  
  clean:
      rm $(PROGRAM)
      rm -rf $(OBJDIR)
  </code></pre>
  
  <p>The error I'm getting:</p>
  
  <pre><code>/opt/cross-pi-gcc/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lwiringPi
  </code></pre>
  
  <p>I copied some libraries from my Pi into a folder on my home dir with this command.</p>
  
  <pre><code>rsync -vR --progress -rl --delete-after --safe-links pi@192.168.1.PI:/{lib,usr,opt/vc/lib} $HOME/raspberrypi/rootfs
  </code></pre>
  
  <p>Which I found it <a href="https://stackoverflow.com/questions/19162072/how-to-install-the-raspberry-pi-cross-compiler-on-my-linux-host-machine/58559140#58559140">here</a>.</p>
  
  <p>But I'm not sure how to link them. Did I overlook something?</p>
  
  <p>Note: The piece of code I'm trying to compile was compiling fine on Windows's cross-compiler.
  I'm trying to setup a tool-chain on my Linux desktop. I'm using Manjaro.</p>