Reputation: 73
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
When i try to complile on cygwin i am getting bellow error:
$ 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
The same thing is working fine on Ubuntu linux, I am not pretty much sure with Cygwin, i guess it is due to the corresponding dll file, but i didnot find it any where, I appreciate your help. Thanks
Upvotes: 0
Views: 340
Reputation: 6022
LIBS=-l/home/C5021090/cppcms/cppcms -l/home/C5021090/cppcms/booster
This is not how the -l flag works. You give -l the name of the library:
LIBS=-lcppcms -lbooster
The linker will look for files called libcppcms.a and libbooster.a
To tell the linker where to find those files, you use the -L option:
LDFLAGS=-L/home/C5021090/cppcms
and a link step like this:
hello: hello.cpp
$(CXX) -O2 -Wall -g ${LDFLAGS} hello.cpp -o hello ${LIBS}
Upvotes: 0
Reputation: 15157
It looks like your two libraries are not built; cppcms
and booster
. Build them in Cygwin and you should be ready to go.
Upvotes: 1