使用help of SO community我成功地用C ++运行我的第一个基于MySQL的文件。现在,下一步是在Apache上作为CGI文件运行。在Apache上它提供500内部服务器错误,在服务器日志中我得到以下内容:
Sat Jan 19 12:18:18 2013] [notice] caught SIGTERM, shutting down
[Sat Jan 19 12:18:23 2013] [notice] Digest: generating secret for digest authentication ...
[Sat Jan 19 12:18:23 2013] [notice] Digest: done
[Sat Jan 19 12:18:23 2013] [notice] Apache/2.0.63 (Unix) PHP/5.3.2 DAV/2 configured -- resuming normal operations
[Sat Jan 19 12:18:51 2013] [error] [client 127.0.0.1] Premature end of script headers: addproduct.cgi
我执行了以下步骤
1-我进入了netbeans生成的DEBUG文件夹,并将addproduct.o文件重命名为addproduct.cgi
2-在htdocs / myappfolder /
中复制它我的文件正在使用MySQL和Boost的库,我想我因为同样的原因而收到错误。我愿意知道如何将包含和 libs 与CGI联系起来?
下面给出了C ++代码,它附带了MySQL Connector / C ++
更新:摆弄路径后,我现在收到以下错误:
inventory dyld:未加载库:libmysqlcppconn.6.dylib
参考自: /Applications/MAMP/htdocs/inventory/Inventory/dist/Debug/GNU-MacOSX/./inventory 原因:未找到图像Trace / BPT陷阱http://pastie.org/5723836
otool 提供以下信息:
otool -LMV库存
inventory:
libmysqlcppconn.6.dylib (compatibility version 6.0.0, current version 6.1.1)
time stamp 2 Thu Jan 1 05:00:02 1970
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
time stamp 2 Thu Jan 1 05:00:02 1970
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)
答案 0 :(得分:1)
看起来你使用的是错误的文件。 .o文件是一个目标文件,它是编译的结果,但尚未链接。我希望netbeans还生成了一个名为addproduct的文件而没有任何扩展名。这是你的可执行文件,可以被apache调用。
PS如果您认真对待C ++和CGI,可能需要查看fastcgi。