0

http://cppcms.com/wikipp/en/page/cppcms_1x_tut_hello_templatesから

私はチュートリアルに従っています。以下は私が行ったことです。

content.h

#include <cppcms/view.h>
#include <string>

namespace content  {
    struct message : public cppcms::base_content {
        std::string text;
    };
}

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 %>

インクルードを追加hello.cpp:

#include <content.h>

コントローラを追加hello.cpp:

virtual void main(std::string /*url*/)
{
    content::message c;
    c.text=">>>Hello<<<";
    render("message",c);
}

runで静的にリンクmy_skin.cppすると、以下のエラーが発生します。hello.cppg++ hello.cpp my_skin.cpp -o hello -lcppcms -lbooster

hello.cpp:1:21: fatal error: content.h: No such file or directory

hello.cppcontent.hが同じディレクトリにあるため、なぜエラーが発生するのかわかりません

4

1 に答える 1

1

次に「content.h」を使用して含める必要があります

GCC include <>タグは、次のパスでファイルを検索します

/usr/local/include
libdir/gcc/target/version/include
/usr/target/include
/usr/include

参照http://gcc.gnu.org/onlinedocs/cpp/Search-Path.html

ファイルが同じディレクトリにある場合は、を使用してそれらを追加できます

「fileName.h」を含める

この場合、コンパイラは現在のディレクトリを検索します

ただし、-Lフラグを使用して、検索パスに任意のパスを追加することもできます。例

gcc -L / path / to / library filename.cpp

于 2013-03-21T15:40:56.597 に答える