SFML community forums

Help => Graphics => Topic started by: hayer on October 05, 2011, 06:59:34 pm

Title: Can't figure out 'undefined reference'
Post by: hayer 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:
Title: Can't figure out 'undefined reference'
Post by: Nexus 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.
Title: Can't figure out 'undefined reference'
Post by: hayer 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

?_?
Title: Can't figure out 'undefined reference'
Post by: Nexus 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?
Title: Can't figure out 'undefined reference'
Post by: hayer 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\
Title: Can't figure out 'undefined reference'
Post by: Nexus 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
Title: Can't figure out 'undefined reference'
Post by: danialpaul1 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 !
Title: Can't figure out 'undefined reference'
Post by: sbroadfoot90 on November 25, 2011, 09:38:04 pm
http://bit.ly/tOuXmK