From http://cppcms.com/wikipp/en/page/cppcms_1x_tut_hello_templates
I'm following the tutorial and below is what I've done.
In content.h
:
#include <cppcms/view.h>
#include <string>
namespace content {
struct message : public cppcms::base_content {
std::string text;
};
}
In my_skin.tmpl
:
<% c++ #include "content.h" %>
<% skin my_skin %>
<% view message uses content::message %>
<% template render() %>
<html>
<body>
<h1><%= text %> World!</h1>
</body>
<html>
<% end template %>
<% end view %>
<% end skin %>
Add include in hello.cpp
:
#include <content.h>
Add controller in hello.cpp
:
virtual void main(std::string /*url*/)
{
content::message c;
c.text=">>>Hello<<<";
render("message",c);
}
When I link statically my_skin.cpp
to hello.cpp
by run g++ hello.cpp my_skin.cpp -o hello -lcppcms -lbooster
, it give error below:
hello.cpp:1:21: fatal error: content.h: No such file or directory
I dont know why error since hello.cpp
and content.h
is in the same directory
you have to include then using "content.h"
GCC include <> tag searches the file in the following path
/usr/local/include libdir/gcc/target/version/include /usr/target/include /usr/include
reference http://gcc.gnu.org/onlinedocs/cpp/Search-Path.html
If the file is in the same directory then you can add them using
include "fileName.h"
in which case the compiler will search in the current directory
However you can also add any path to the search path by using -L flag. example
gcc -L/path/to/library filename.cpp