cp:
#include <cppcms/application.h>
#include <cppcms/applications_pool.h>
#include <cppcms/service.h>
#include <cppcms/http_response.h>
#include <iostream>
class my_hello_world : public cppcms::application {
public:
my_hello_world(cppcms::service &srv) :
cppcms::application(srv)
{
}
virtual void main(std::string url);
};
void my_hello_world::main(std::string /*url*/)
{
response().out()<<
"<html>\n"
"<body>\n"
" <h1>Hello World</h1>\n"
"</body>\n"
"</html>\n";
}
int main(int argc,char ** argv)
{
try {
cppcms::service srv(argc,argv);
srv.applications_pool().mount(cppcms::applications_factory<my_hello_world>());
srv.run();
}
catch(std::exception const &e) {
std::cerr<<e.what()<<std::endl;
}
}
/* End of code */
生成文件:
LIBS=-l/home/C5021090/cppcms/cppcms -l/home/C5021090/cppcms/booster
all: hello
hello: hello.cpp
$(CXX) -O2 -Wall -g hello.cpp -o hello ${LIBS}
clean:
rm -fr hello hello.exe cppcms_rundir
当我尝试在 cygwin 上编译时,出现以下错误:
$ make
g++ -O2 -Wall -g hello.cpp -o hello -l/home/C5021090/cppcms/cppcms -l/home/C5021090/cppcms/booster
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld: cannot find -l/home/C5021090/cppcms/cppcms
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld: cannot find -l/home/C5021090/cppcms/booster
collect2: ld returned 1 exit status
Makefile:7: recipe for target `hello' failed
make: *** [hello] Error 1
同样的事情在 Ubuntu linux 上运行良好,我不太确定 Cygwin,我猜这是由于相应的 dll 文件,但我没有在任何地方找到它,感谢您的帮助。谢谢