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

Author Topic: Ye olde "undefined reference" errors.  (Read 3398 times)

0 Members and 1 Guest are viewing this topic.

Daimoth

  • Newbie
  • *
  • Posts: 2
    • View Profile
Ye olde "undefined reference" errors.
« on: September 07, 2015, 02:19:15 am »
Trying to get 2.3.1 to work with CodeBlocks 13.12.

Just running through the tutorial here , as well as a few , unable to get the test program from the tutorial to build.

One point in the tutorial confused me, it differentiated between DW2 and SJLJ installations of GCC, but it doesn't seem to specify which is needed. Should I build my own SFML? I have libgcc_s_dw2-1

I'm using dynamic linking, as I read that's preferable so you can freely change the libraries without needing to screw with the executable. I do have include in the compiler tab, lib in the linker tab. Since I'm not using static linking or debug versions, my link libraries look like "sfml-graphics" and such. I believe have heeded the link order - graphics, window, system, audio, main network.

Code: [Select]
||=== Build: Debug in Darkspire (compiler: GNU GCC Compiler) ===|
obj\Debug\src\main.o||In function `main':|
C:\Users\Josh\Google Drive\Darkspire\src\main.cpp|5|undefined reference to `sf::String::String(char const*, std::locale const&)'|
C:\Users\Josh\Google Drive\Darkspire\src\main.cpp|5|undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'|
C:\Users\Josh\Google Drive\Darkspire\src\main.cpp|5|undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'|
C:\Users\Josh\Google Drive\Darkspire\src\main.cpp|6|undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'|
C:\Users\Josh\Google Drive\Darkspire\src\main.cpp|7|undefined reference to `sf::Color::Green'|
C:\Users\Josh\Google Drive\Darkspire\src\main.cpp|7|undefined reference to `sf::Shape::setFillColor(sf::Color const&)'|
C:\Users\Josh\Google Drive\Darkspire\src\main.cpp|15|undefined reference to `sf::Window::close()'|
C:\Users\Josh\Google Drive\Darkspire\src\main.cpp|12|undefined reference to `sf::Window::pollEvent(sf::Event&)'|
C:\Users\Josh\Google Drive\Darkspire\src\main.cpp|18|undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'|
C:\Users\Josh\Google Drive\Darkspire\src\main.cpp|18|undefined reference to `sf::RenderTarget::clear(sf::Color const&)'|
C:\Users\Josh\Google Drive\Darkspire\src\main.cpp|19|undefined reference to `sf::RenderStates::Default'|
C:\Users\Josh\Google Drive\Darkspire\src\main.cpp|19|undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'|
C:\Users\Josh\Google Drive\Darkspire\src\main.cpp|20|undefined reference to `sf::Window::display()'|
C:\Users\Josh\Google Drive\Darkspire\src\main.cpp|9|undefined reference to `sf::Window::isOpen() const'|
C:\Users\Josh\Google Drive\Darkspire\src\main.cpp|23|undefined reference to `sf::RenderWindow::~RenderWindow()'|
C:\Users\Josh\Google Drive\Darkspire\src\main.cpp|5|undefined reference to `sf::RenderWindow::~RenderWindow()'|
C:\Users\Josh\Google Drive\Darkspire\src\main.cpp|23|undefined reference to `sf::RenderWindow::~RenderWindow()'|
obj\Debug\src\main.o||In function `ZN2sf11CircleShapeD1Ev':|
C:\Users\Josh\Google Drive\Darkspire\..\..\Desktop\SFML-2.3.1\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `vtable for sf::CircleShape'|
C:\Users\Josh\Google Drive\Darkspire\..\..\Desktop\SFML-2.3.1\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `vtable for sf::CircleShape'|
C:\Users\Josh\Google Drive\Darkspire\..\..\Desktop\SFML-2.3.1\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `sf::Shape::~Shape()'|
||=== Build failed: 20 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

Apologies if I've left any crucial information out, the sooner I can get past this unpleasant know-nothing phase, the better. Thanks in advance.

Edit: it appears I have done all that careful tinkering in the debug rather than the release tab. Currently finagling, wish me luck.

Now we're looking at:

Code: [Select]
||=== Build: Release in Darkspire (compiler: GNU GCC Compiler) ===|
obj\Release\src\main.o:main.cpp:(.text$_ZN2sf11CircleShapeD1Ev[__ZN2sf11CircleShapeD1Ev]+0x1)||undefined reference to `_imp___ZTVN2sf11CircleShapeE'|
obj\Release\src\main.o:main.cpp:(.text$_ZN2sf11CircleShapeD1Ev[__ZN2sf11CircleShapeD1Ev]+0x11)||undefined reference to `_imp___ZN2sf5ShapeD2Ev'|
obj\Release\src\main.o:main.cpp:(.text.startup+0xc0)||undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'|
obj\Release\src\main.o:main.cpp:(.text.startup+0xf8)||undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'|
obj\Release\src\main.o:main.cpp:(.text.startup+0x132)||undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'|
obj\Release\src\main.o:main.cpp:(.text.startup+0x19c)||undefined reference to `_imp___ZN2sf11CircleShapeC1Efj'|
obj\Release\src\main.o:main.cpp:(.text.startup+0x1a4)||undefined reference to `_imp___ZN2sf5Color5GreenE'|
obj\Release\src\main.o:main.cpp:(.text.startup+0x1bd)||undefined reference to `_imp___ZN2sf5Shape12setFillColorERKNS_5ColorE'|
obj\Release\src\main.o:main.cpp:(.text.startup+0x1d6)||undefined reference to `_imp___ZNK2sf6Window6isOpenEv'|
obj\Release\src\main.o:main.cpp:(.text.startup+0x1ff)||undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE'|
obj\Release\src\main.o:main.cpp:(.text.startup+0x223)||undefined reference to `_imp___ZN2sf6Window5closeEv'|
obj\Release\src\main.o:main.cpp:(.text.startup+0x253)||undefined reference to `_imp___ZN2sf5ColorC1Ehhhh'|
obj\Release\src\main.o:main.cpp:(.text.startup+0x26b)||undefined reference to `_imp___ZN2sf12RenderTarget5clearERKNS_5ColorE'|
obj\Release\src\main.o:main.cpp:(.text.startup+0x271)||undefined reference to `_imp___ZN2sf12RenderStates7DefaultE'|
obj\Release\src\main.o:main.cpp:(.text.startup+0x28a)||undefined reference to `_imp___ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'|
obj\Release\src\main.o:main.cpp:(.text.startup+0x299)||undefined reference to `_imp___ZN2sf6Window7displayEv'|
obj\Release\src\main.o:main.cpp:(.text.startup+0x2c9)||undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'|
obj\Release\src\main.o:main.cpp:(.text.startup+0x3da)||undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'|
||=== Build failed: 18 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

I have ensured that my build and build options are configured to release - no mixing and matching as far as I can tell. Tried putting SFML_DYNAMIC in #defines, but it didn't appear to have an effect.

Current course of action is install the latest version of MinGW and rebuild sfml for it. Should be fun!

Edit 2: I had the compiler selected which comes with Code Blocks rather than the one I installed. After selecting the proper one, I'm down to two errors:

Code: [Select]
||=== Build: Release in Darkspire (compiler: GNU GCC Compiler) ===|
obj\Release\src\main.o:main.cpp:(.text$_ZN2sf11CircleShapeD1Ev[__ZN2sf11CircleShapeD1Ev]+0x1)||undefined reference to `_imp___ZTVN2sf11CircleShapeE'|
obj\Release\src\main.o:main.cpp:(.text$_ZN2sf11CircleShapeD1Ev[__ZN2sf11CircleShapeD1Ev]+0x11)||undefined reference to `_imp___ZN2sf5ShapeD2Ev'|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

Still trying to work out CMake. Grabbed a copy of CMakeLists.txt, put it in the SFML directory, and tried CMake again. It started to work, but is currently complaining "install FILES given no DESTINATION!"

Here's the log it left behind. Currently stumped.
« Last Edit: September 07, 2015, 04:11:49 am by Daimoth »

GraphicsWhale

  • Full Member
  • ***
  • Posts: 131
    • View Profile
Re: Ye olde "undefined reference" errors.
« Reply #1 on: September 08, 2015, 12:01:03 am »
1. What are your linker settings?
2. Which of the SFML binaries did you download?
3. What version of GCC did you install?
4. What OS are you running?

Also, did you bother to read http://www.sfml-dev.org/tutorials/2.0/compile-with-cmake.php? If you're compiling it right, you should not need to download the CMakeLists.txt. It should be included with the source distribution of SFML.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Ye olde "undefined reference" errors.
« Reply #2 on: September 08, 2015, 01:01:40 am »
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Daimoth

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Ye olde "undefined reference" errors.
« Reply #3 on: September 08, 2015, 01:50:34 am »
Windows 8.1, 64 bit. I was working off that tutorial, yes. The .txt file was not included in my distribution, which, looking at it now, was the wrong distribution. So that probably explains that.

In fact, that allowed it to build.

I'm still getting a startup error when I run the project, but I haven't learned how to debug yet, so I'll try my hand at that before asking around.

Thanks for the assistance, gentlemen.

 

anything