cygwin上的cppcms,在尝试编译时生成错误

时间:2013-03-11 19:28:33

标签: gcc cygwin cppcms

CPP:

#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文件,但我没有找到它在哪里,我感谢你的帮助。 感谢

2 个答案:

答案 0 :(得分:1)

看起来你的两个图书馆没有建成; cppcmsbooster。在Cygwin中构建它们 ,你应该准备好了。

答案 1 :(得分:0)

  

LIBS = -l / home / C5021090 / cppcms / cppcms -l / home / C5021090 / cppcms / booster

这不是-l标志的工作原理。你给了-l库的名称

LIBS=-lcppcms -lbooster

链接器将查找名为libcppcms.a和libbooster.a

的文件

要告诉链接器在哪里找到这些文件,请使用-L选项:

LDFLAGS=-L/home/C5021090/cppcms

和这样的链接步骤:

hello: hello.cpp
        $(CXX) -O2 -Wall -g ${LDFLAGS} hello.cpp -o hello ${LIBS}
相关问题