For anyone who has trouble with getopt_long and IRIX..
I know we have a Wiki on this that says "google around for the example code to implement this" .. which was not very helpful for me.
Granted, once I figured it out, it now seems easy but it took some time for me to get to that point. I want this thread to help anyone else with this problem.
Attached is a tarball with ya_getopt .. Yet-Another getopt implementation.. compiles on IRIX and I tested it already (however not very extensively! so hopefully nothing breaks from this).
tar tpf ../getopt_long-in-irix.tar
Code: Select all
the .c and .h are from ya_getopt. libya_getopt.so is a compiled shared library on IRIX 6.5/mips4 with GCC (we all love GCC right?
The README has some rough notes for anyone who may find themselves in a getopt_long() missing situation and may be clueless as to what to do:
Here is the README (its rough notes.. )
Code: Select all
# These are notes for getopt_lang() in IRIX (GCC)
# Yet Another GetOpt implementation (drop-in)
# COMPILE shared library (GCC)
gcc -c -Wall -Werror -fpic ya_getopt.c
gcc -shared -o libya_getopt.so ya_getopt.o
# LINK with your code (examples)
gcc -Wall -o test main.c -lya_getopt
# LINK with your code specifying .so library directory location
gcc -L/whereis/ya_getopt/ -Wall -o test main.c -lya_getopt
# Copy ya_getopt.h to your source and edit relevant files:
# Replace getopt_long() calls in your code to ya_getopt_long()
# Example Makefile changes (and/or Environment variable adjustments)
LDFLAGS = -L/usr/nekoware/lib -L/usr/lib32 -L/whereis/ya_getopt/
LIBS = -lya_getopt
Ensure libya_getopt.so is stored somewhere where the binary can access
Such as /usr/local/lib/
It does compile with MIPSpro as well:
cc -c ya_getopt.c
cc -shared -o libya_getopt.so ya_getopt.o
Thanks again to Kubo @ https://github.com/kubo/ya_getopt
for his ya_getopt code.