I am attempting to write a cgi program (using cgicc) which incorporates the boost regex library. The program works perfectly with std regex, but I am trying to change to boost regex to test the performance difference.
The program also works perfectly if I create an offline version that does not use cgicc or run through a browser. When I compile this program I use the following command lines:
c++ -std=c++11 resourcelocator.cpp -I /path/include -I /path/boost_1_57_0 -L /path/src -L/path/lib -lcgicc -lgmp -lcurl -lcurlcpp -lboost_regex -o resourcelocator.cgi
The executable which results always looks in the wrong place for the boost regex library so I have to do the following as well:
install_name_tool -change libboost_regex.dylib /path/libboost_regex.dylib resourcelocator.cgi
After that, the offline version works perfectly. However, if I attempt to write an almost identical program as a cgi script and run it from a browser, I get a 500 error every time. I tried reducing the script to doing nothing but printing out the header and it still returned a 500 error. If I do not link -lboost_regex when I compile the program will work again (as long as I take out the boost regexes, of course).
I get a few error messages when it runs - in essence: "dyld: Library not loaded:" then "Reason: no suitable image" then \\t/path/libboost_regex.dylib: stat() failed with errno=13, referer: http://localhost/test.html
Why would linking the library cause the cgi to fail? Is there any way for me to use this library in a cgi program?