0

For the life of me, I can't get scons to link these SFML libraries. I believe I followed everything the scons website says to do regarding library linking, so I'm at a loss as to what to do:

import fnmatch
import os

#Setup environment
file_match = "*.cpp"

#Recursive Glob method to find all source files
matches = []
for root, dirnames, filenames in os.walk("src/"):
    for filename in filenames:
        if fnmatch.fnmatch(filename, file_match):
            matches.append(os.path.join(root, filename))

#Compile the program
env = Environment();
env.Append(LIBS = ["sfml-graphics","sfml-window","sfml-system"]);
env.Append(LIBPATH = "/usr/local/lib");
env.Program(target = "Game", source = matches)

EDIT: This code works, apparently. It appears my computer just needed a couple days off to fix itself.

Azmisov
  • 6,493
  • 7
  • 53
  • 70
  • 2
    Please excuse the silly question but how does scons not linking the SFML libraries manifest? Linking errors (maybe you need to add more libs that SFML needs - i.e. OpenGL + co)? Runtime errors (perhaps you're mixing debug/non-debug, sigle threaded/multi threaded libs)? – Eugen Constantin Dinca Aug 05 '12 at 01:28
  • I'm trying to emulate this (http://www.sfml-dev.org/tutorials/1.6/graphics-window.php) in scons. But it gives messages like: "undefined reference to sf::Window::Close()" – Azmisov Aug 05 '12 at 04:35
  • Your SCons code looks correct. We need to isolate if the problem is with SCons or with the actual compilation, I suspect the later. As @EugenConstantinDinca suggested, you need to make sure you list all the necessary libraries AND in the right order. Which OS are you using? They mention a SFML_DYNAMIC variable, looks like you didnt define that. – Brady Aug 05 '12 at 08:58
  • Also, can you post the compiler commands generated by SCons. That can be quite helpful in finding the solution. – Brady Aug 05 '12 at 09:00
  • Have you checked that you are using the correct libraries. Make sure that you shouldn't be using a debug library or something similar. Check the output and look for which libraries are linked when the linker is running. Lastly check that the nm command (outputs linker symbols) displays the exact same symbols in the library as the links is complaining about. If this is wrong, there might be a problem with calling conventions and such. – daramarak Aug 14 '12 at 16:47
  • Okay, I tried it again today and it magically worked. I have no clue why it wasn't working before. – Azmisov Aug 15 '12 at 01:40

0 Answers0