Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Code::Blocks linking issues  (Read 3211 times)

0 Members and 1 Guest are viewing this topic.

justAuser

  • Newbie
  • *
  • Posts: 5
    • View Profile
Code::Blocks linking issues
« on: December 08, 2021, 12:02:08 pm »
After following the linking tutorial for SFML in Code::Blocks, I am still having trouble to run the code. Here are the errors that I get:
||=== Build file: "no target" in "no project" (compiler: unknown) ===|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `sf::String::String(char const*, std::locale const&)'|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `sf::View::View(sf::Rect<float> const&)'
|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `sf::RenderTarget::setView(sf::View const&)'|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `GhostManager::GhostManager()'
|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `Pacman::Pacman()'|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `convert_sketch(std::array<std::string, 21ull> const&, std::array<Position, 4ull>&, Pacman&)'
|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `GhostManager::reset(unsigned char, std::array<Position, 4ull> const&)'|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `sf::Window::close()'
|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `sf::Window::pollEvent(sf::Event&)'|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `Pacman::get_dead()'
|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `Pacman::update(unsigned char, std::array<std::array<Cell, 21ull>, 21ull>&)'|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `GhostManager::update(unsigned char, std::array<std::array<Cell, 21ull>, 21ull>&, Pacman&)'
|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `Pacman::set_animation_timer(unsigned short)'|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `sf::Keyboard::isKeyPressed(sf::Keyboard::Key)'
|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `Pacman::get_dead()'|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `convert_sketch(std::array<std::string, 21ull> const&, std::array<Position, 4ull>&, Pacman&)'
|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `GhostManager::reset(unsigned char, std::array<Position, 4ull> const&)'|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `Pacman::reset()'
|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `Pacman::get_dead()'|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `draw_map(std::array<std::array<Cell, 21ull>, 21ull> const&, sf::RenderWindow&)'
|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `Pacman::get_energizer_timer()'|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `GhostManager::draw(bool, sf::RenderWindow&)'
|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `draw_text(bool, unsigned short, unsigned short, std::string const&, sf::RenderWindow&)'|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `Pacman::draw(bool, sf::RenderWindow&)'
|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `Pacman::get_animation_over()'|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `draw_text(bool, unsigned short, unsigned short, std::string const&, sf::RenderWindow&)'
|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `draw_text(bool, unsigned short, unsigned short, std::string const&, sf::RenderWindow&)'|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `sf::Window::display()'
|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `sf::Window::isOpen() const'|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `sf::RenderWindow::~RenderWindow()'
|
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp|| undefined reference to `sf::RenderWindow::~RenderWindow()'|
||error: ld returned 1 exit status|
||=== Build failed: 36 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10226
    • View Profile
    • development blog
    • Email
Re: Code::Blocks linking issues
« Reply #1 on: December 08, 2021, 12:58:19 pm »
Some or of your own code, which sounds to me like you forgot to add them to your code::blocks project
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

justAuser

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Code::Blocks linking issues
« Reply #2 on: December 08, 2021, 01:26:05 pm »
The other files are included using #include "file.hpp" . Do I have to do something else? Also, most of the issues are from the sf namespace, which I think is from the SFML libraries, right?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10226
    • View Profile
    • development blog
    • Email
Re: Code::Blocks linking issues
« Reply #3 on: December 08, 2021, 01:28:37 pm »
Did you add the to your project? I think if you right click a file, there's an option for that.
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

justAuser

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Code::Blocks linking issues
« Reply #4 on: December 08, 2021, 01:36:40 pm »
I only have these:

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10226
    • View Profile
    • development blog
    • Email
Re: Code::Blocks linking issues
« Reply #5 on: December 08, 2021, 03:56:20 pm »
Maybe a stupid question, but do you even have multiple files or is everything in Main.cpp?

Can you provide the verbose build output as described here: https://www.sfml-dev.org/faq.php#tr-grl-verbose-ide
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

justAuser

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Code::Blocks linking issues
« Reply #6 on: December 10, 2021, 03:27:54 pm »
I do have multiple files but I am not sure if they have been linked to the main file. I simply installed this project from the Internet and went ahead and opened the main.cpp file on Code::Blocks.

Here is the verbose build output:
g++.exe -std=c++11 -DSFML_STATIC -I"C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\SFML-2.5.1\include" -c "C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.cpp" -o "C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o"
g++.exe -L"C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\SFML-2.5.1\lib" -o "C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.exe" "C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o"   "C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\SFML-2.5.1\lib\libsfml-graphics-s.a" "C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\SFML-2.5.1\lib\libsfml-window-s.a" "C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\SFML-2.5.1\lib\libsfml-system-s.a" "C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\SFML-2.5.1\lib\libopenal32.a" "C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\SFML-2.5.1\lib\libfreetype.a"
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0x70e): undefined reference to `sf::String::String(char const*, std::locale const&)'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0x72e): undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0x777): undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0x7d4): undefined reference to `sf::View::View(sf::Rect<float> const&)'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0x7ee): undefined reference to `sf::RenderTarget::setView(sf::View const&)'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0x7fd): undefined reference to `GhostManager::GhostManager()'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0x80c): undefined reference to `Pacman::Pacman()'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0x844): undefined reference to `convert_sketch(std::array<std::string, 21ull> const&, std::array<Position, 4ull>&, Pacman&)'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0x88f): undefined reference to `GhostManager::reset(unsigned char, std::array<Position, 4ull> const&)'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0x972): undefined reference to `sf::Window::close()'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0x988): undefined reference to `sf::Window::pollEvent(sf::Event&)'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0x9a9): undefined reference to `Pacman::get_dead()'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0x9eb): undefined reference to `Pacman::update(unsigned char, std::array<std::array<Cell, 21ull>, 21ull>&)'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0xa15): undefined reference to `GhostManager::update(unsigned char, std::array<std::array<Cell, 21ull>, 21ull>&, Pacman&)'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0xb24): undefined reference to `Pacman::set_animation_timer(unsigned short)'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0xb33): undefined reference to `sf::Keyboard::isKeyPressed(sf::Keyboard::Key)'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0xb51): undefined reference to `Pacman::get_dead()'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0xb95): undefined reference to `convert_sketch(std::array<std::string, 21ull> const&, std::array<Position, 4ull>&, Pacman&)'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0xbe0): undefined reference to `GhostManager::reset(unsigned char, std::array<Position, 4ull> const&)'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0xbef): undefined reference to `Pacman::reset()'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0xc27): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0xc41): undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0xc5e): undefined reference to `Pacman::get_dead()'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0xc8f): undefined reference to `draw_map(std::array<std::array<Cell, 21ull>, 21ull> const&, sf::RenderWindow&)'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0xc9e): undefined reference to `Pacman::get_energizer_timer()'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0xcc1): undefined reference to `GhostManager::draw(bool, sf::RenderWindow&)'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0xd25): undefined reference to `draw_text(bool, unsigned short, unsigned short, std::string const&, sf::RenderWindow&)'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0xd63): undefined reference to `Pacman::draw(bool, sf::RenderWindow&)'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0xd72): undefined reference to `Pacman::get_animation_over()'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0xddd): undefined reference to `draw_text(bool, unsigned short, unsigned short, std::string const&, sf::RenderWindow&)'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0xe57): undefined reference to `draw_text(bool, unsigned short, unsigned short, std::string const&, sf::RenderWindow&)'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0xe84): undefined reference to `sf::Window::display()'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0xea3): undefined reference to `sf::Window::isOpen() const'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0xeba): undefined reference to `sf::RenderWindow::~RenderWindow()'
C:\Users\...\Dropbox\PC\Documents\Project Task 2\Pacman-Main\Source\Main.o:Main.cpp:(.text+0x12ec): undefined reference to `sf::RenderWindow::~RenderWindow()'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 6 second(s))
36 error(s), 0 warning(s) (0 minute(s), 6 second(s))

 

anything