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

Author Topic: Can't figure out 'undefined reference'  (Read 3178 times)

0 Members and 1 Guest are viewing this topic.

hayer

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Can't figure out 'undefined reference'
« on: October 05, 2011, 06:59:34 pm »
Hi

Here is my code
Code: [Select]

sf::Image treeImage;
if(!treeImage.LoadFromFile("D:\\sfml\\textures\\tree_large.png"))
{
    std::cout << "[Image] Could not load 'tree_large.png'" << std::endl;
}


The problem is that CodeBlocks just spits out;

Code: [Select]

obj\Debug\main.o||In function `main':|
D:\sfml\YetAnotherTest\main.cpp|60|undefined reference to `_imp___ZN2sf5ImageD1Ev'|
D:\sfml\YetAnotherTest\main.cpp|60|undefined reference to `_imp___ZN2sf5ImageD1Ev'|
||=== Build finished: 2 errors, 0 warnings ===|


And for the life of me I can't figure out why it ain't linking  :(  :oops:

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Can't figure out 'undefined reference'
« Reply #1 on: October 05, 2011, 07:12:31 pm »
Have you told the linker which SFML libraries you use? "It" doesn't link automatically, it's you who has to specify the libraries ;)

How this exactly works is explained in the tutorials.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

hayer

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Can't figure out 'undefined reference'
« Reply #2 on: October 05, 2011, 07:15:44 pm »
I have told it where the libs are and where the header files are.. I'm already using sf::Shape and sf::Vector and some other SFML classes without any problem

?_?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Can't figure out 'undefined reference'
« Reply #3 on: October 05, 2011, 07:25:11 pm »
What entries do you have at your linker? In which configuration (Release or Debug; Static or Dynamic) do you compile?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

hayer

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Can't figure out 'undefined reference'
« Reply #4 on: October 05, 2011, 07:28:09 pm »
Dynamic linking. Debug.

"Project Build Options"
Linker settings
sfml-graphics-d
sfml-window-d
sfml-system-d
sfml-audio-d
sfml-network-d

"Compiler and debugger" -> "Global compiler settings" -> "Search Directories"
[Compiler]
D:\SFML2\sfml\sfml2\include\

[Linker]
D:\SFML2\my_build\lib\

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Can't figure out 'undefined reference'
« Reply #5 on: October 05, 2011, 08:44:58 pm »
As far as I know, g++ (respectively ld) requires a specific order: Libraries that depend on other libraries must be listed before them. Try
Code: [Select]
sfml-graphics-d
sfml-audio-d
sfml-network-d
sfml-window-d
sfml-system-d
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

danialpaul1

  • Newbie
  • *
  • Posts: 1
    • Yahoo Instant Messenger - danialpaul1@yahoo.com
    • View Profile
Can't figure out 'undefined reference'
« Reply #6 on: November 25, 2011, 08:21:42 pm »
yup but what's the benefit of Dynamic linking ? I don't think there is any important benefit !

sbroadfoot90

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
Can't figure out 'undefined reference'
« Reply #7 on: November 25, 2011, 09:38:04 pm »