Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

CLI SFML/MinGW FUCK

Name: Anonymous 2012-04-29 1:33

What's up /prog/, need to draw on your collective experience.

So, basically, I'm wanting to compile shit from the command line using MinGW. Beyond that, I'm learning how to include and use external libraries like SFML... Well, trying to learn.

Anyway, I've put my headers and library files in the <MinGW root>include & lib folders - so I think it's reading those. The strange part starts here...

I know that I'm using the correct version of the SFML SDK and that my source code is using members and classes that actually exist. And yet I get obfuscated stuff like this:

...dir... undefined reference to '_imp___ZN2sf6Windo5closeEv'
( this refers to a member function of the Window class - Window.isOpen() which I use in my source)

How am I getting an undefined reference? Is this something to do with the library files I'm not understanding?

Name: Anonymous 2012-04-29 1:36

Or... sorry, that probably actually refers to Window.closed()... but, yeah, anyway

Name: Anonymous 2012-04-29 2:17

Check the forums? I see that SFML 2.0 has a Window.close() method and 1.6 doesn't. Your problem may still be a mismatch with the two different versions.

Name: Anonymous 2012-04-29 11:25

undefined reference means that you've forgotten to link some library. How do you run your compiler?

Name: Anonymous 2012-04-29 22:42

Thanks for the replies. I've tried compiling it quite a few different ways on the command line and am getting some different errors now.

I guess, just to be thorough, here's my directory layout:

SFML's include folder was copied to c:\mingw\include\sfml.

SFML's lib folder was copied to c:\mingw\lib\sfml.

I've been able to compile and assemble it with the line:
g++ -c main.cpp

And I've been trying to link it with something like this:
g++ -o main main.o -lsfml-graphics-s -lsfml-window-s -lsfml-system-s

And it's saying it can't find those library files. So anyway, I've been trying various versions of that. Like with -llibsfml-graphics-s.a (the actual file name),  trying to specify the search directory with -L (still not sure I'm using the right format though), etc.

Still a little fuzzy on dynamic vs. static linking and what I need to do to *do* each too.

Thanks again.

Name: FIXED IT! 2012-04-30 0:08

Finally figured it out.

I had to define the macro SFML_STATIC to statically link it. I did this in the source with #define. Not sure if that's the ideal way to do it.

Then it linked with:
g++ -o main main.o -Lc:\mingw\lib\sfml -lsfml-graphics-s -lsfml-window-s -lsfml-system-s

Name: Anonymous 2012-04-30 1:07

>>6

add -DSFML_STATIC to the options when compiling the .c file, and this will do the compilation with the macro defined. There should be an option for this in the Makefile somewhere. If it isn't documented, you can try doing a search for SFML_STATIC and see what variables get that value and under what conditions. You could also start at the rule for creating .o files from .c files, and look at the variable that generates the options.

Name: Anonymous 2012-04-30 12:14

ITT;
Fucking Sepples

Name: bampu pantsu 2012-05-29 4:41

bampu pantsu

Don't change these.
Name: Email:
Entire Thread Thread List