在clang ++中使用include选项的问题

时间:2015-07-06 14:49:14

标签: c++ compilation include-path clang++

我正在尝试使用自己的“API”编译程序。假设我的项目结构是:

main.cc
...
api/
    include/
        *.h
    lib/
        libsdl2ecs.a

我知道编译器(或者至少是gcc和clang)可以选择将目录添加到include和lib路径(-I和-L),所以我用来编译的命令是:

clang++ -std=c++11 -Iapi/include -Lapi/lib -Wall -o main main.cc -lSDL2 -lSDL2_image -lsdl2ecs

它不起作用:输出太可怕了,不能把它放在这里。事情是,这不是我的问题,因为如果我删除-Iapi / include选项并在.cc文件中写入整个路径,它可以完美地工作。

我想知道我是否遗漏了什么。

提前致谢!

编辑:错误消息

clang++ -std=c++11 -Iapi/include/ -Lapi/lib/ -Wall -o main main.cc -lSDL2 -lSDL2_image -lsdl2ecs
In file included from main.cc:1:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/iostream:39:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/ostream:38:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/ios:42:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/bits/ios_base.h:39:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/ext/atomicity.h:35:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/x86_64-redhat-linux/bits/gthr.h:148:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/x86_64-redhat-linux/bits/gthr-default.h:35:
In file included from /usr/include/pthread.h:23:
In file included from /usr/include/sched.h:34:
In file included from api/include/time.h:5:
api/include/system.h:15:9: error: implicit instantiation of undefined template 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >'
        string failureDetail;
               ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/bits/stringfwd.h:71:11: note: template is declared here
    class basic_string;
          ^
In file included from main.cc:1:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/iostream:39:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/ostream:38:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/ios:42:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/bits/ios_base.h:39:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/ext/atomicity.h:35:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/x86_64-redhat-linux/bits/gthr.h:148:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/x86_64-redhat-linux/bits/gthr-default.h:35:
In file included from /usr/include/pthread.h:23:
In file included from /usr/include/sched.h:34:
In file included from api/include/time.h:6:
In file included from api/include/game.h:6:
In file included from api/include/entity.h:4:
api/include/component.h:24:9: error: implicit instantiation of undefined template 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >'
        string failureDetail;
               ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/bits/stringfwd.h:71:11: note: template is declared here
    class basic_string;
          ^
In file included from main.cc:1:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/iostream:39:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/ostream:38:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/ios:42:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/bits/ios_base.h:39:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/ext/atomicity.h:35:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/x86_64-redhat-linux/bits/gthr.h:148:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/x86_64-redhat-linux/bits/gthr-default.h:35:
In file included from /usr/include/pthread.h:23:
In file included from /usr/include/sched.h:34:
In file included from api/include/time.h:6:
In file included from api/include/game.h:6:
In file included from api/include/entity.h:4:
api/include/component.h:70:6: error: member access into incomplete type 'Game'
        game->Instantiate<T>();
            ^
api/include/system.h:4:7: note: forward declaration of 'Game'
class Game;
      ^
In file included from main.cc:1:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/iostream:39:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/ostream:38:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/ios:42:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/bits/ios_base.h:39:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/ext/atomicity.h:35:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/x86_64-redhat-linux/bits/gthr.h:148:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/x86_64-redhat-linux/bits/gthr-default.h:35:
In file included from /usr/include/pthread.h:23:
In file included from /usr/include/sched.h:34:
In file included from api/include/time.h:6:
In file included from api/include/game.h:6:
In file included from api/include/entity.h:4:
api/include/component.h:77:15: error: member access into incomplete type 'Entity'
        return entity->AddComponent<T>();
                     ^
api/include/component.h:13:7: note: forward declaration of 'Entity'
class Entity;
      ^
api/include/component.h:84:15: error: member access into incomplete type 'Entity'
        return entity->GetComponent<Derived>();
                     ^
api/include/component.h:13:7: note: forward declaration of 'Entity'
class Entity;
      ^
In file included from main.cc:1:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/iostream:39:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/ostream:38:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/ios:42:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/bits/ios_base.h:39:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/ext/atomicity.h:35:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/x86_64-redhat-linux/bits/gthr.h:148:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/x86_64-redhat-linux/bits/gthr-default.h:35:
In file included from /usr/include/pthread.h:23:
In file included from /usr/include/sched.h:34:
In file included from api/include/time.h:6:
In file included from api/include/game.h:6:
In file included from api/include/entity.h:6:
In file included from api/include/texture.h:8:
In file included from api/include/renderer.h:6:
api/include/display.h:14:9: error: implicit instantiation of undefined template 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >'
        string title;
               ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/bits/stringfwd.h:71:11: note: template is declared here
    class basic_string;
          ^
In file included from main.cc:1:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/iostream:39:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/ostream:38:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/ios:42:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/bits/ios_base.h:39:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/ext/atomicity.h:35:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/x86_64-redhat-linux/bits/gthr.h:148:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/x86_64-redhat-linux/bits/gthr-default.h:35:
In file included from /usr/include/pthread.h:23:
In file included from /usr/include/sched.h:34:
In file included from api/include/time.h:6:
In file included from api/include/game.h:6:
In file included from api/include/entity.h:6:
api/include/texture.h:18:9: error: implicit instantiation of undefined template 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >'
        string path;
               ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/bits/stringfwd.h:71:11: note: template is declared here
    class basic_string;
          ^
In file included from main.cc:4:
In file included from ./prefabs.hh:2:
./ccomponents.hh:20:36: error: cannot initialize object parameter of type 'Component' with an expression of type 'WASDController'
            Transform &transform = GetTransform();
                                   ^~~~~~~~~~~~
./ccomponents.hh:22:17: error: cannot initialize object parameter of type 'Component' with an expression of type 'WASDController'
            if (GetKeyPressed(SDLK_d))
                ^~~~~~~~~~~~~
./ccomponents.hh:25:17: error: cannot initialize object parameter of type 'Component' with an expression of type 'WASDController'
            if (GetKeyPressed(SDLK_w))
                ^~~~~~~~~~~~~
./ccomponents.hh:28:17: error: cannot initialize object parameter of type 'Component' with an expression of type 'WASDController'
            if (GetKeyPressed(SDLK_a))
                ^~~~~~~~~~~~~
./ccomponents.hh:31:17: error: cannot initialize object parameter of type 'Component' with an expression of type 'WASDController'
            if (GetKeyPressed(SDLK_s))
                ^~~~~~~~~~~~~
./ccomponents.hh:34:17: error: cannot initialize object parameter of type 'Component' with an expression of type 'WASDController'
            if (GetKeyDown(SDLK_v))
                ^~~~~~~~~~
./ccomponents.hh:44:36: error: cannot initialize object parameter of type 'Component' with an expression of type 'Zoomer'
            Transform &transform = GetTransform();
                                   ^~~~~~~~~~~~
./ccomponents.hh:46:17: error: cannot initialize object parameter of type 'Component' with an expression of type 'Zoomer'
            if (GetKeyPressed(SDLK_x)) {
                ^~~~~~~~~~~~~
./ccomponents.hh:51:17: error: cannot initialize object parameter of type 'Component' with an expression of type 'Zoomer'
            if (GetKeyPressed(SDLK_z)) {
                ^~~~~~~~~~~~~
./ccomponents.hh:63:36: error: cannot initialize object parameter of type 'Component' with an expression of type 'Rotator'
            Transform &transform = GetTransform();
                                   ^~~~~~~~~~~~
./ccomponents.hh:65:17: error: cannot initialize object parameter of type 'Component' with an expression of type 'Rotator'
            if (GetKeyPressed(SDLK_e))
                ^~~~~~~~~~~~~
./ccomponents.hh:68:17: error: cannot initialize object parameter of type 'Component' with an expression of type 'Rotator'
            if (GetKeyPressed(SDLK_q))
                ^~~~~~~~~~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
Makefile:11: recipe for target 'main' failed
make: *** [main] Error 1

0 个答案:

没有答案