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

Author Topic: SFML 1.6 Tutorial: undefined reference to `_imp___ZN2sf5ClockC1Ev'  (Read 4040 times)

0 Members and 1 Guest are viewing this topic.

meddlingwithfire

  • Newbie
  • *
  • Posts: 4
    • View Profile
I am having trouble completing the tutorial to set up SFML 1.6 with CodeBlocks+MinGW (http://www.sfml-dev.org/tutorials/1.6/start-cb.php).  Specifically, when I build the project I get the following build log:

Quote
-------------- Build: Debug in sfmlTest ---------------

Compiling: main.cpp
Linking console executable: bin\Debug\sfmlTest.exe
obj\Debug\main.o: In function `main':
C:/Dev/codeBlocksTest/sfmlTest/main.cpp:6: undefined reference to `_imp___ZN2sf5ClockC1Ev'
C:/Dev/codeBlocksTest/sfmlTest/main.cpp:9: undefined reference to `_imp___ZNK2sf5Clock14GetElapsedTimeEv'
C:/Dev/codeBlocksTest/sfmlTest/main.cpp:10: undefined reference to `_imp___ZN2sf5SleepEf'
C:/Dev/codeBlocksTest/sfmlTest/main.cpp:7: undefined reference to `_imp___ZNK2sf5Clock14GetElapsedTimeEv'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
4 errors, 0 warnings

It looks like a problem with my linker configuration, but I've combed through the tutorial a dozen times now and I can't see what I am doing wrong or missing.  As far as I can tell, I am following the instructions to the letter.  I've set up the Global Compiler Settings >> Search Directory >> Compiler and Linker to point to the appropriate SFML include and lib directories.  I've updated my project build options (for both Debug & Release) to include the -lsfml-system library.  I've added the compiler SFML_DYNAMIC define as well (again, in both Debug & Release targets).  I have verified that all of the directory path settings are valid; I copy & pasted all of them into Windows Explorer to verify.  I also copy & pasted the code straight from the tutorial:

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

int main()
{
    sf::Clock Clock;
    while (Clock.GetElapsedTime() < 5.f)
    {
        std::cout << Clock.GetElapsedTime() << std::endl;
        sf::Sleep(0.5f);
    }

    return 0;
}

I searched around, and did see a couple people with similar issues:
http://en.sfml-dev.org/forums/index.php?topic=6900.msg45530#msg45530
http://www.cplusplus.com/forum/beginner/49533/

But their solutions have not resolved my errors.  I try a full Clean + Rebuild after each change I make as well.

I've verified that I am using the GCC 4.4 compiler:

Quote
C:\Program Files (x86)\CodeBlocks\MinGW\bin>gcc --version
gcc (TDM-2 mingw32) 4.4.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

For reference, here is my Code::Block .cbp project file:
Code: [Select]
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="sfmlTest" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin\Debug\sfmlTest" 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\sfmlTest" prefix_auto="1" extension_auto="1" />
<Option object_output="obj\Release\" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
<Add option="-DSFML_DYNAMIC" />
</Compiler>
<Linker>
<Add option="-s" />
<Add option="-lsfml-system" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Unit filename="main.cpp" />
<Extensions>
<code_completion />
<envvars />
<debugger />
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>

Thanks to everyone who takes a look.  If any further information would be helpful, just let me know, and I'll put together whatever I can.

meddlingwithfire

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: SFML 1.6 Tutorial: undefined reference to `_imp___ZN2sf5ClockC1Ev'
« Reply #1 on: November 11, 2012, 06:59:36 pm »
Figured it out!  I thought it would be something stupid, and it was. 

I was linking against the the wrong library build.  I had originally downloaded the Visual Studio C++ build of SFML, as I was going to get things up and running in that environment.  But when I switched over to Code::Blocks+MinGW, I didn't re-download the proper development files, I had just re-used the Visual Studio build files.  As soon as I grabbed the MinGW files and set them up in Code::Blocks, the linker was happy.

 

anything