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

Author Topic: Undefined Reference Issues  (Read 1622 times)

0 Members and 1 Guest are viewing this topic.

redavni

  • Newbie
  • *
  • Posts: 4
    • View Profile
Undefined Reference Issues
« on: December 20, 2011, 02:58:13 pm »
Hi, new here and running into some annoying issue when running a very basic test on SFML.

OK, first off here's my code:

Code: [Select]
#include <iostream>
#include <SFML/System.hpp>

using namespace std;

int main()
{
    sf::Clock clck;
    cout << "built?!" << endl;
    return 0;
}


And the error I get is
Code: [Select]
obj\Debug\main.o||In function `main':
C:\Users\Jake\Desktop\test\main.cpp|8|undefined reference to `_imp___ZN2sf5ClockC1Ev'
=== Build finished: 1 errors, 0 warnings ===


And now a breakdown of my setup to help clarify. I am using SFML 1.6 on windows with code::blocks 10.05. I installed the latest mingw earlier today. Tested simple c++ programs to make sure everything was good, no problem.

I am linking dynamically, using a Debug build target.
So in Settings->Compiler and Debugger->Search Directories->Compiler I have 'D:\libraries\SFML-1.6\include
Linker: D:\libraries\SFML-1.6\lib

Moving on to project build options. Compiler settings -> defines: I have SFML_DYNAMIC.
Linker Settings-> Other linker options: -lsfml-system-d
And finally I have copied sfml-system-d.dll to the Debug folder of my project.

Hope that's clear enough to avoid any of the basic questions about following the tutorial. Any help would be appreciated.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Undefined Reference Issues
« Reply #1 on: December 20, 2011, 03:01:20 pm »
Quote
Compiler settings -> defines: I have SFML_DYNAMIC.
Linker Settings-> Other linker options: -lsfml-system-d

That should be enough to avoid the error that you get. Can you upload your .cbp file so that we can have a look at it?
Laurent Gomila - SFML developer

redavni

  • Newbie
  • *
  • Posts: 4
    • View Profile
Undefined Reference Issues
« Reply #2 on: December 20, 2011, 03:06:18 pm »
Here you go

Code: [Select]
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="test" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin\Debug\test" prefix_auto="1" extension_auto="1" />
<Option object_output="obj\Debug\" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin\Release\test" prefix_auto="1" extension_auto="1" />
<Option object_output="obj\Release\" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Unit filename="main.cpp" />
<Extensions>
<code_completion />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Undefined Reference Issues
« Reply #3 on: December 20, 2011, 03:28:56 pm »
It's an empty project, there's no SFML_DYNAMIC and no -lsfml-system-d.
Laurent Gomila - SFML developer

redavni

  • Newbie
  • *
  • Posts: 4
    • View Profile
Undefined Reference Issues
« Reply #4 on: December 20, 2011, 03:41:13 pm »
My mistake, I hadn't saved the file. Here's the updated version.

Code: [Select]
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="test" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin\Debug\test" prefix_auto="1" extension_auto="1" />
<Option object_output="obj\Debug\" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
<Add option="-DSFML_DYNAMIC" />
</Compiler>
<Linker>
<Add option="-lsfml-system-d" />
</Linker>
</Target>
<Target title="Release">
<Option output="bin\Release\test" prefix_auto="1" extension_auto="1" />
<Option object_output="obj\Release\" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Unit filename="main.cpp" />
<Extensions>
<code_completion />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Undefined Reference Issues
« Reply #5 on: December 20, 2011, 03:49:17 pm »
You should try with the version of MinGW which is linked in the tutorial for Code::Blocks.
Laurent Gomila - SFML developer

redavni

  • Newbie
  • *
  • Posts: 4
    • View Profile
Undefined Reference Issues
« Reply #6 on: December 20, 2011, 04:14:22 pm »
Gave it a shot with the same project (updating gcc to the one you mentioned) and a fresh one, exact same error.

 

anything