Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: corrected source code

...

If you face problem with building boost-container, connected with flag -m64, which does not exist on gcc at RPI, you need to create wrapper to remove the flag. I've created the wrapper in c++ (file g++wrapper.cc):



#include

...

<cstdio>

...


#include

...

<cstdlib>

...


#include

...

<cstring>

...


#include

...

<string>

...


using

...

namespace

...

std;

...



string

...

args2Text(int

...

argc,

...

 char**

...

argv,

...

 const char*

...

forbiddenFlag="-m64",

...

 const char*

...

compilerCommand="/usr/bin/g++");

...


int

...

returnValidNumberFromSubcommand(int

...

systemCallReturnValue);

...


string escapeQuotes(const string& text);



int main(int

...

argc,

...

char*

...

argv[])

...


{
   const auto command = args2Text(argc,

...

argv);

...


   const auto status = system(command.c_str());

...


   return returnValidNumberFromSubcommand(status);

...


}


string args2Text(int

...

argc,

...

 char**

...

argv,

...

 const char*

...

forbiddenFlag,

...

 const char*

...

compilerCommand)

...


{
   string command = compilerCommand;
   for (int i = 1;

...

i < argc;

...

++i)

...


   {
      if (strcmp(argv[i],

...

forbiddenFlag))

...


         command +=

...

"

...

"s

...

+

...

escapeQuotes(argv[i]);

...


   }
   return command;
}


string escapeQuotes(const string& text)
{
   constexpr const char* escapedQuote = R"_(\")_";
   string returnString;
   returnString.reserve(text.size()

...

+

...

2);

...


   for (auto

...

c

...

:

...

text)

...


   {
      if ('"'

...

==

...

c)

...


         returnString += escapedQuote;
      else
         returnString += c;
   }
   return returnString;
}


int returnValidNumberFromSubcommand(int systemCallReturnValue)
{
   if (systemCallReturnValue < 0)
   {
      return -1;
   }
   else
   {
      if (WIFEXITED(systemCallReturnValue))
      {
         return WEXITSTATUS(systemCallReturnValue);
      }
      else
      {
         return 1;
      }
   }
}

just compile that: g++ g++wrapper.cc -o g++wrapper We just need to replace system's /usr/bin/c++ with our wrapper, we can do that with commands:

...