I am trying to build/cross compile some C code using Qualcomm Hexagon toolchain for Hexagon target. I use argtable3 . library for commandline parsing needed in my application.
The build gives multiple definition linker errors for certain functions which are present in both the argtable3 library and also the Hexagon toolchain libc.a. Errors given below.
How can I work around this problem, as I cannot remove argtable, and neither remove linking of libc.a as thats my target architecture, and removing it might throw-up other errors.
Error: multiple definition of symbol `getopt' in file ../../lib/libargtable.a(argtable3.c.o) and /home/HEXAGON_Tools/7.2.12/Tools/bin/../target/hexagon/lib/v60/libc.a(getopt.o)
Error: multiple definition of symbol `opterr' in file ../../lib/libargtable.a(argtable3.c.o) and /home/HEXAGON_Tools/7.2.12/Tools/bin/../target/hexagon/lib/v60/libc.a(getopt.o)
Error: multiple definition of symbol `optind' in file ../../lib/libargtable.a(argtable3.c.o) and /home/HEXAGON_Tools/7.2.12/Tools/bin/../target/hexagon/lib/v60/libc.a(getopt.o)
Error: multiple definition of symbol `optopt' in file ../../lib/libargtable.a(argtable3.c.o) and /home/HEXAGON_Tools/7.2.12/Tools/bin/../target/hexagon/lib/v60/libc.a(getopt.o)
Just in case you are still stuck in this problem, mind checking what is your compiler command? i think the best way is to modify these areas in your argtable3.c code like:
#ifdef REPLACE_GETOPT
/*
* getopt --
* Parse argc/argv argument vector.
*
* [eventually this will replace the BSD getopt]
*/
int
getopt(int nargc, char * const *nargv, const char *options)
{
Similar occurences in: https://github.com/argtable/argtable3/blob/master/argtable3.c