Post a new topicPost a reply Page 1 of 1   [ 2 posts ]
Author Message
 Post subject: g++
PostPosted: Sat Apr 22, 2017 11:36 am 

Joined: Thu Dec 01, 2016 11:13 am
Posts: 4
how to compaile this ,,,,,,g++ -lrt -lpthread MY_PROGRAM.cpp arduPi.o -o MY_PROGRAM


Top
 Profile  
 
 Post subject: Re: g++
PostPosted: Tue Apr 25, 2017 7:48 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11338
Hello rahul_123,
take a view to the script provided to "cook" your programs.
LoRaWAN ./cook.sh dump content:
Code:
#!/bin/bash

PWD="$(pwd)"
cd ..
cd ..
BASE_DIR="$(pwd)"
ARDUPI_DIR="$BASE_DIR/arduPi"
ARDUPIAPI_DIR="$BASE_DIR/arduPi-api"
EXAMPLES_DIR="$BASE_DIR/examples/LoRaWAN"
LIBRARY_DIR="$BASE_DIR/libraries/arduPiLoRaWAN"

#compile arduPi
cd "$ARDUPI_DIR"
file="./arduPi.o"
if [ -e $file ]; then
  if [ "$1" == "-clean" ]; then
    echo "arduPi.o -> purged"
    rm ./arduPi.o
  else
    echo "arduPi already compiled"
  fi
else
  if [ "$1" != "-clean" ]; then
    echo "Compiling arduPi..."
    g++ -c arduPi.cpp -o arduPi.o
  fi
fi

#compile arduPi-api
cd "$ARDUPIAPI_DIR"
file="./arduPiUART.o"
if [ -e $file ]; then
  if [ "$1" == "-clean" ]; then
    echo "arduPiUART.o -> purged"
    rm ./arduPiUART.o
  else
   echo "arduPiUART already compiled"
  fi
else
  if [ "$1" != "-clean" ]; then
   echo "Compiling arduPiUART..."
    g++ -c arduPiUART.cpp -o arduPiUART.o
  fi
fi

file="./arduPiUtils.o"
if [ -e $file ]; then
  if [ "$1" == "-clean" ]; then
    echo "arduPiUtils.o -> purged"
    rm ./arduPiUtils.o
  else
   echo "arduPiUtils already compiled"
  fi
else
  if [ "$1" != "-clean" ]; then
   echo "Compiling arduPiUtils..."
    g++ -c arduPiUtils.cpp -o arduPiUtils.o
  fi
fi

file="./arduPiMultiprotocol.o"
if [ -e $file ]; then
  if [ "$1" == "-clean" ]; then
    echo "arduPiMultiprotocol.o -> purged"
    rm ./arduPiMultiprotocol.o
  else
   echo "arduPiMultiprotocol already compiled"
  fi
else
  if [ "$1" != "-clean" ]; then
   echo "Compiling arduPiMultiprotocol..."
    g++ -c arduPiMultiprotocol.cpp -o arduPiMultiprotocol.o
  fi
fi

#compile library
cd "$LIBRARY_DIR"
file="./arduPiLoRaWAN.o"
if [ -e $file ]; then
  if [ "$1" == "-clean" ]; then
    echo "arduPiLoRaWAN.o -> purged"
    rm ./arduPiLoRaWAN.o
  else
   echo "arduPiLoRa already compiled"
  fi
else
  if [ "$1" != "-clean" ]; then
   echo "Compiling arduPiLoRaWAN..."
    g++ -c arduPiLoRaWAN.cpp \
      -I"$ARDUPIAPI_DIR" \
      -I"$ARDUPI_DIR" \
      -o arduPiLoRaWAN.o
  fi
fi

sleep 1


#compile example
cd "$EXAMPLES_DIR"
file="./$1"

if [ "$1" != "-clean" ]; then
  if [ -e $file ]; then
    if [ "$1" != "" ]; then
    echo "Compiling Example..."
       
    g++ -lrt -lpthread -lstdc++ "$1" \
      "$LIBRARY_DIR/arduPiLoRaWAN.o" \
      "$ARDUPIAPI_DIR/arduPiUART.o" \
      "$ARDUPIAPI_DIR/arduPiUtils.o" \
      "$ARDUPIAPI_DIR/arduPiMultiprotocol.o" \
      "$ARDUPI_DIR/arduPi.o" \
      -I"$ARDUPI_DIR" \
      -I"$ARDUPIAPI_DIR" \
      -I"$LIBRARY_DIR" \
      -o "$1_exe"
    else
      echo "---------------HELP------------------"
      echo "Compiling: ./mak.sh filetocompile.cpp"
      echo "Cleaning:  ./mak.sh -clean"
      echo "-------------------------------------"
    fi
  else
    echo "ERROR No such file or directory: $file"
  fi
else
  echo "¡¡Spotless Kitchen!!"
fi
 
sleep 1

exit 0


You can modify the library structure directories for your own or directly compile with:
Code:
    g++ -lrt -lpthread -lstdc++ your_file_cpp arduPi.o -o your_file_executable


Regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 2 posts ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of http://www.gamexe.net


© Libelium Comunicaciones Distribuidas S.L. | Terms of use.