# Where are the .a files in SFML 2.0?

## Recommended Posts

I am trying to use Code::Blocks to write up my supernoob first 2D graphics of a deformed excuse for a shape on my screen.

All seemed to be well and good, I added the SFML-2.0\include\ folder and followed the documentation for my incredible green circle, my IDE was smiling brightly upon me as I it recognized the RenderWindow term and allowed me to place in parameters without proceeding to mock me by filling my log up with red text and references to objects that I never even wrote. Upon excitedly hitting the F9 key to build and run my new AAA game that was going to make me millions of dollars and revolutionize the market, I was finally spammed with the sadistic shit that the IDE was taking pleasure in letting out on me with an error message on almost every line.

It's relatively the same error each time:

Anyway. Some Google searches suggested that I hadn't placed in the appropriate library files (I had linked to the .lib's beforehand) and so I went on to fix my problem based on my own incompetence when... there's no ".a files" at all. It clearly suggests that they are in the lib folder. But there are only the basic libraries (system, system-s, system-d, window-s etc.) in .lib format.

If I can't even figure this one out I might as well seek a new career line as a catholic priest. So someone please tell me what the heck I'm doing wrong before I repent to the good lord for all my wrongs and move to Russia where I can spank mutant deer with my new acquired religious friends. You guys are about to determine my future.

Edited by Exoaria

##### Share on other sites

It's relatively the same error each time:
'undefined reference to _imp___ZN2kfjalCOLORskfjaCOMMUNISTSsfllRENDERTARGETasfkPOLLjsfhjdCHILDSUPPORTsRNS_fkhsfaBLUEkljghf'

I assume you found it 'funny' to modify this error. Because if not, whatever is missing has nothing to do with SFML.

Never modify error messages. Always post them verbatim.

For the actual problem, either download the correct distribution of SFML for your compiler or build it yourself.

As a side node, this problem has nothing to do with graphics programming. It's purely a basic library issue.

##### Share on other sites

It's relatively the same error each time:
'undefined reference to _imp___ZN2kfjalCOLORskfjaCOMMUNISTSsfllRENDERTARGETasfkPOLLjsfhjdCHILDSUPPORTsRNS_fkhsfaBLUEkljghf'

I assume you found it 'funny' to modify this error. Because if not, whatever is missing has nothing to do with SFML.

Never modify error messages. Always post them verbatim.

For the actual problem, either download the correct distribution of SFML for your compiler or build it yourself.

As a side node, this problem has nothing to do with graphics programming. It's purely a basic library issue.

I think that for anyone after spending days upon days sitting in front of a screen trying to understand the headache of C++ and OpenGL you will do absolutely anything to try and lighten the load. However in case I needed to reiterate, I got about 50 error messages upon trying to compile them, all starting with `_imp___ and then followed by lots of gibberish with random words inserted into them. If you'd like to see them all in their non-hilarious format, that's super. Here they are.

Personally I prefer the communist child support alterations.

Anyway, I had no idea this was not related to Graphics Programming. I have not had this issue at all until I tried to use Code::Blocks with SFML.
I just want to know where the .a files are, then I'll leave you alone and go buy some kittens. (SFML 2.0 is perfectly compatible with Code::Blocks and the GNU GCC Compiler)

##### Share on other sites

You are asking other people to help you, but at the same time you are actively sabotaging their attempts to do so by supplying fake information. Just because you cannot read the strings does not mean no one else can. And while I'm very far from an expert of individual compiler's C++ name mangling, just be glancing at the strings you can verify it's indeed SFML functions missing. I suggest for the future to try and find humour in things that do not actively sabotage other people's attempt to help you.

Nevertheless, the solution of my original post still stand: download whichever precompiled distribution is for your compiler or build the library yourself. I do not know if there is a precompiled distribution of SFML for your preferred flavour of MinGW, but the last time I tried it compiling it yourself was extremely easy.

##### Share on other sites

//EDIT:  See the correction offered below.

Different operating systems follow different naming conventions for certain file types -- the .lib files you're seeing are the files you need on Windows, and the information you're seeing online about .a files refers to the same files on Linux or Unix systems.

BitMaster's suggested solution to your problem is correct.  You will need to install the correct distribution for your compiler and OS and correctly configure Code::Blocks, or alternatively build the library yourself, and then configure Code::Blocks to use the resulting files.  The errors you're seeing indicate that SFML has not been included in your project correctly.

##### Share on other sites

Different operating systems follow different naming conventions for certain file types -- the .lib files you're seeing are the files you need on Windows, and the information you're seeing online about .a files refers to the same files on Linux or Unix systems.

Actually, when using MinGW or its derivatives most libraries will obey the libXXX.a pattern even on Windows.

##### Share on other sites

Actually, when using MinGW or its derivatives most libraries will obey the libXXX.a pattern even on Windows.

Thanks for the correction!

##### Share on other sites

Alright, thanks BitMaster. I get where I was going wrong now, I didn't understand that those errors were telling me I was using a version of SFML for my wrong compiler.

I don't even know.
Honestly I should be able to understand this but, c'mon, I just want to display a blue circle.
My computer hates me.

I'm sure that I've put everything in its right space though.

EDIT: Okay, I rebuilt it and now I'm not getting the error above anymore. But now I'm getting the errors seen in the original post again! Except this time I've linked up the .a files and everything seems to be set using the MinGW version.

EDIT 2: Here's everything as it should be, and you can see the errors down below.

Edited by Exoaria

##### Share on other sites

Please do not post screenshots, copy and paste the actual errors. I don't have a Code::Blocks here but one of the panes displays the actual compiler output and allows easy copy and pasting. Take special note of any warnings that are generated before the errors are generated.

If a rebuild completely changes the kind of linker problems you get like this, that suggests you have done something wrong or at least fishy. How is that project generated? Directly modifying the Code::Blocks settings will generally not be possible if the project is automatically generated by CMake for example.

##### Share on other sites

Do you have access to the Makefile? I am sure that there is a nifty way of adding the library directories to the codeblocks config, but I am unfamiliar with codeblocks.

You should have a -L flag in the linking line of the makefile, if the libs are not in the usual place for your OS. If you built the libraries yourself, you may have forgot to install them. Typically installing the libs will place them correctly.

Have you checked out the sfml-dev.org site? It is a wealth of info on getting up and running with SFML.

http://en.sfml-dev.org/forums/index.php?topic=10971.msg75687

##### Share on other sites

hello

i understood you were linking against the static lib

did you define the "SFML_STATIC"  in the codeblock "defines"

good luck

##### Share on other sites

Assuming you're using the default CodeBlocks GNU GCC compiler:

Under project build options-> Linker settings, you should link these files in order:

sfml-graphics-s

sfml-window-s

sfml-system-s

Instead of the actual file name!

and the lib folder in Search Directories->Linker tab

Under Compiler settings->#defines

add this text: "SFML_STATIC" (without quotes)

Now the program should work, at least it did for me.

Edited by Kenric

##### Share on other sites

Your first batch of errors were undefined references to SFML functions, so that means your program could find the headers but not the .a files, or that you had the wrong .a files.

Your second batch of errors were undefined references to non-SFML functions. These functions were because even the same compiler (GCC/MinGW) can be compiled with different settings. The specific functions (which I know from prior googling when encountering the same problem), is because the library you downloaded is compiled using one type of compiled settings for exception handling, and the compiler you are using is compiled using a different type of settings for exception-handling.

Your third set of errors, which is your first set of errors again, is saying that it can't find certain SFML functions.

Because you are linking to the SFML libraries statically, wassime mentioned that you need to define 'SFML_STATIC' in your compiler settings. See here. That page actually describes your 2nd problem also... but that was resolved when you recompiled SFML from scratch.

"Honestly I should be able to understand this but, c'mon, I just want to display a blue circle."

You are encountering standard C++ frustrations, so, for the record, these problems aren't really SFML-specific.

You'll encounter these kind of issues even after years of C++ experience. Or, at least I do.

Some of these issues may hopefully get addressed in future C++ standards, but others likely won't.

You'll learn to interpret these errors also... but sometimes an error can mean one of half a dozen different problems. Future C++ compilers are working on improving the readability of compiler error messages.

tldr: I think wassime is correct.

##### Share on other sites

Thanks for all the input and contribution to my problem guys!
The problem ended up being that none of the builds were compatible with my compiler. I needed to download a Nightly Build. I simply replaced the contents of the Nightly SFML with the ones in the current directory, rebuilt my C++ file and everything is working now.

My circle is on screen and I'm ready to sell it to Microsoft for a mere \$120,000,000 and the rights to Halo.

##### Share on other sites

Congrats mate! Every time you find a solution in a problem that gets you crazy, write the solution somewhere (like explaining it to children: step1,2,3,4 etc) or post it in your blog or something. Someone else might have the same problem or you might face it again, sometime later.

Well done ;)

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628305
• Total Posts
2981967

• 9
• 13
• 11
• 12
• 11