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

Author Topic: Can't Link SFML 2.0 on Mac OSX 10.7.2  (Read 3526 times)

0 Members and 1 Guest are viewing this topic.

Salepate

  • Newbie
  • *
  • Posts: 11
    • View Profile
Can't Link SFML 2.0 on Mac OSX 10.7.2
« on: October 30, 2011, 01:17:53 pm »
[updated]

Hey,

i've been trying to make SFML works, but all in vain.

I first tried with the SFML 2.0 snapshot, and then with the SFML git

So here's what i've done:

I retrieved the whole repository. and then used cmake. While doing cmake, the only warnings that i got were about some unbound keycodes. Otherwise it was successful. libs were created in SFML/lib (i tried both static & dynamic libs)
So here's the content of SFML/lib/ :
Code: [Select]

libsfml-audio-s.a libsfml-graphics.dylib libsfml-system.2.dylib
libsfml-audio.2.0.dylib libsfml-network-s.a libsfml-system.dylib
libsfml-audio.2.dylib libsfml-network.2.0.dylib libsfml-window-s.a
libsfml-audio.dylib libsfml-network.2.dylib libsfml-window.2.0.dylib
libsfml-graphics-s.a libsfml-network.dylib libsfml-window.2.dylib
libsfml-graphics.2.0.dylib libsfml-system-s.a libsfml-window.dylib
libsfml-graphics.2.dylib libsfml-system.2.0.dylib


here's what my Makefile project looks like:
Code: [Select]


# Tools
CXX=            g++
CFLAGS=         -Wall -ansi -lsfml-graphics
CLIBS =         -lsfml-graphics -lsfml-window -lsfml-system

# Dirs
SRCDIR=         src/
INCDIR=         include/
OBJDIR=         obj/

# Files
CPPFILES=       $(shell (for f in $$(find ./$(SRCDIR) -type f -name *.cpp); do basename $$f; done;))
OBJFILES=       $(CPPFILES:.cpp=.o)

# Output
BIN=            td610

###############################################################################
# Rules
###############################################################################
vpath   %.cpp $(SRCDIR)

all:    $(OBJFILES)
        $(CXX) -o$(BIN) $(addprefix $(OBJDIR),$(OBJFILES))


%.o:    %.cpp
        @echo "building $@ ($<)"
        @mkdir -p obj
        $(CXX) -o $(OBJDIR)$@ -c $< $(CFLAGS) $(CLIBS) -I$(INCDIR) -L/Users/Willy/Dev/SFML/lib/


And here's the result when I start compiling
Code: [Select]

building game.o (src/game.cpp)
g++ -o obj/game.o -c src/game.cpp -Wall -ansi -lsfml-graphics -lsfml-graphics -lsfml-window -lsfml-system -Iinclude/ -L/Users/Willy/Dev/SFML/lib/
i686-apple-darwin11-llvm-g++-4.2: -lsfml-graphics: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lsfml-graphics: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lsfml-window: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lsfml-system: linker input file unused because linking not done
building main.o (src/main.cpp)
g++ -o obj/main.o -c src/main.cpp -Wall -ansi -lsfml-graphics -lsfml-graphics -lsfml-window -lsfml-system -Iinclude/ -L/Users/Willy/Dev/SFML/lib/
i686-apple-darwin11-llvm-g++-4.2: -lsfml-graphics: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lsfml-graphics: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lsfml-window: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lsfml-system: linker input file unused because linking not done
g++ -o td610 obj/game.o obj/main.o
Undefined symbols for architecture x86_64:
  "sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)", referenced from:
      _main in main.o
  "sf::RenderWindow::RenderWindow(sf::VideoMode, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, sf::ContextSettings const&)", referenced from:
      _main in main.o
  "sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)", referenced from:
      _main in main.o
  "sf::RenderTarget::Clear(sf::Color const&)", referenced from:
      _main in main.o
  "sf::Window::Display()", referenced from:
      _main in main.o
  "sf::Window::IsOpened() const", referenced from:
      _main in main.o
  "sf::RenderWindow::~RenderWindow()", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [all] Error 1


Not to forget my main.cpp:
Code: [Select]

#include <iostream>
#include <SFML/Graphics.hpp>

using namespace sf;

int main(int argc, char **argv) {
        RenderWindow win( VideoMode(800, 600, 32), "test");
        while ( win.IsOpened() ) {
                win.Clear();
                win.Display();
        }
        return 0;
}                    


I'm not really experienced with Mac stuff, since I do not own any.

I just took a look at the System information and here's what I get :
Code: [Select]

Model Name: MacBook
  Model Identifier: MacBook6,1
  Processor Name: Intel Core 2 Duo
  Processor Speed: 2,26 GHz
  Number of Processors: 1
  Total Number of Cores: 2
  L2 Cache: 3 MB
  Memory: 4 GB
  Bus Speed: 1,07 GHz


I can't tell if it's a 64bits architecture nor a 32bits. I'd say it's a 64 one

Any help would be appreciated,

Salepate

Edit: I just happened to fix the undefined references, it now works but i still get those warnings. might I just ignore it?

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Can't Link SFML 2.0 on Mac OSX 10.7.2
« Reply #1 on: October 31, 2011, 07:08:54 pm »
Quote
i still get those warnings.
Which ones ?
SFML / OS X developer

Salepate

  • Newbie
  • *
  • Posts: 11
    • View Profile
Can't Link SFML 2.0 on Mac OSX 10.7.2
« Reply #2 on: November 01, 2011, 12:08:55 pm »
In fact, i haven't been fixing anything at all, it just happened to work on another Mac Os X.

the warnings i keep gettings are those like
Code: [Select]

linker input file unused because linking not done


and, no matter the way I build SFML libs,  I won't be able to compile any project that use them, i can't get rid of the undefined symbols errors
Code: [Select]

Undefined symbols for architecture x86_64:


Edit: It seems like someone else has the same errors, i might find what I need here
http://www.sfml-dev.org/forum/viewtopic.php?t=6162

I'll keep you informed

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Can't Link SFML 2.0 on Mac OSX 10.7.2
« Reply #3 on: November 01, 2011, 06:16:07 pm »
These two posts are not related.

You're doing the compilation wrong. Instead to give the linker optionS to your compiler when compiling the two source files you should pass these options when "merging" the object files together.
SFML / OS X developer

Salepate

  • Newbie
  • *
  • Posts: 11
    • View Profile
Can't Link SFML 2.0 on Mac OSX 10.7.2
« Reply #4 on: November 01, 2011, 09:47:41 pm »
Quote from: "Hiura"
These two posts are not related.

You're doing the compilation wrong. Instead to give the linker optionS to your compiler when compiling the two source files you should pass these options when "merging" the object files together.


Yeah, i'd fixed that. .

Right now, i'm still getting the "undefined symbols for architecture" error message, that's if I don't give options
Code: [Select]
-lsfml-graphics -lsfml-window -lsfml-system
 when merging object files together. (these options wont let it work saying that library -lsfml-graphics wasn't found)

And here's my current Makefile
Code: [Select]

# Tools
CXX= g++
CFLAGS= -Wall -ansi
CLIBS = -lsfml-graphics -lsfml-window -lsfml-system

# Dirs
SRCDIR= src/
INCDIR= include/
OBJDIR= obj/

# Files
CPPFILES= $(shell (for f in $$(find ./$(SRCDIR) -type f -name *.cpp); do basename $$f; done;))
OBJFILES= $(CPPFILES:.cpp=.o)

# Output
BIN= td610

###############################################################################
# Rules
###############################################################################
vpath %.cpp $(SRCDIR)

all: $(OBJFILES)
$(CXX) -o $(BIN) $(addprefix $(OBJDIR),$(OBJFILES)) $(CFLAGS) $(CLIBS)


%.o: %.cpp
@echo "\033[32mbuilding $@ ($<)\033[0m"
@mkdir -p obj
$(CXX) -o $(OBJDIR)$@ -c $< $(CFLAGS) -I$(INCDIR)


# Cleaning !
.PHONY: clean cleanall

clean:
rm -rf $(OBJDIR)

cleanall: clean
rm -f $(BIN)


Might I be missing something ?

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Can't Link SFML 2.0 on Mac OSX 10.7.2
« Reply #5 on: November 01, 2011, 11:15:25 pm »
You haven't installed SFML properly. Or, you forget the "-L/Users/Willy/Dev/SFML/lib/" part in your new Makefile.
SFML / OS X developer

Salepate

  • Newbie
  • *
  • Posts: 11
    • View Profile
Can't Link SFML 2.0 on Mac OSX 10.7.2
« Reply #6 on: November 02, 2011, 12:12:48 am »
Hu? I proceeded to make install (with sudo), do I really need to check that folder too?

I'll start from scratch again and report here when I'm done