0

我刚刚安装了 Eclipse CDT 并尝试在其中安装 sfml 2。我似乎在链接库时遇到问题,因为它既不能通过静态链接也不能通过动态链接编译。它只是给了我这些错误:

22:08:57 **** Incremental Build of configuration Debug for project sdl ****
Info: Internal Builder is used for build
g++ "-LC:\\Users\\Romeo\\Desktop\\SFML-2.0-rc\\lib" -o sdl.exe "src\\sdl.o" -lsfml-graphics-s-d -lsfml-window-s-d -lsfml-system-s-d 
src\sdl.o: In function `main':
D:\_workspace\_eclipsec++\sdl\Debug/../src/sdl.cpp:5: undefined reference to     `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
D:\_workspace\_eclipsec++\sdl\Debug/../src/sdl.cpp:5: undefined reference to     `sf::RenderWindow::RenderWindow(sf::VideoMode, std::string const&, unsigned int,     sf::ContextSettings const&)'
D:\_workspace\_eclipsec++\sdl\Debug/../src/sdl.cpp:6: undefined reference to     `sf::CircleShape::CircleShape(float, unsigned int)'
D:\_workspace\_eclipsec++\sdl\Debug/../src/sdl.cpp:7: undefined reference to     `sf::Color::Green'
D:\_workspace\_eclipsec++\sdl\Debug/../src/sdl.cpp:7: undefined reference to     `sf::Shape::setFillColor(sf::Color const&)'
D:\_workspace\_eclipsec++\sdl\Debug/../src/sdl.cpp:15: undefined reference to `sf::Window::close()'
D:\_workspace\_eclipsec++\sdl\Debug/../src/sdl.cpp:12: undefined reference to `sf::Window::pollEvent(sf::Event&)'
D:\_workspace\_eclipsec++\sdl\Debug/../src/sdl.cpp:18: undefined reference to     `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
D:\_workspace\_eclipsec++\sdl\Debug/../src/sdl.cpp:18: undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
D:\_workspace\_eclipsec++\sdl\Debug/../src/sdl.cpp:19: undefined reference to `sf::RenderStates::Default'
D:\_workspace\_eclipsec++\sdl\Debug/../src/sdl.cpp:19: undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'
D:\_workspace\_eclipsec++\sdl\Debug/../src/sdl.cpp:20: undefined reference to `sf::Window::display()'
D:\_workspace\_eclipsec++\sdl\Debug/../src/sdl.cpp:9: undefined reference to `sf::Window::isOpen() const'
D:\_workspace\_eclipsec++\sdl\Debug/../src/sdl.cpp:5: undefined reference to `sf::RenderWindow::~RenderWindow()'
D:\_workspace\_eclipsec++\sdl\Debug/../src/sdl.cpp:5: undefined reference to `sf::RenderWindow::~RenderWindow()'
D:\_workspace\_eclipsec++\sdl\Debug/../src/sdl.cpp:5: undefined reference to `sf::RenderWindow::~RenderWindow()'
src\sdl.o: In function `~CircleShape':
C:/Users/Romeo/Desktop/SFML-2.0-rc/include/SFML/Graphics/CircleShape.hpp:41: undefined     reference to `vtable for sf::CircleShape'
C:/Users/Romeo/Desktop/SFML-2.0-rc/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `vtable for sf::CircleShape'
C:/Users/Romeo/Desktop/SFML-2.0-rc/include/SFML/Graphics/CircleShape.hpp:41: undefined     reference to `sf::Shape::~Shape()'
collect2: ld returned 1 exit status

22:08:59 Build Finished (took 1s.419ms)

我想我做错了什么,但我不知道是什么。一点帮助?

4

1 回答 1

0

因为你的 g++ 不同于编译器来构建 sfml。以下任何组合都会导致您的问题:

  • g++ <-> cl(vc++的编译器)
  • g++32 <-> g++64
  • g++ <-> gcc
于 2013-01-29T10:05:16.620 回答