how to install external libraries on codeblocks

Started by
11 comments, last by rAm_y_ 9 years, 2 months ago

hi so i was trying to install things like sdl , allegro , sfml for a long time i followed many online tutorials but non seem to fit if some one could give me a tutorial or something to help me install sdl and/or sfml that would be great . im using windows 8 64 bit , codeblocks with the deafault compiler the gcc port (MinGW) . thanks biggrin.png

Advertisement

Personally, when I was first learning to do this, I struggled quite a bit. It can get a little tricky depending on a few things, but is generally pretty straightforward (in hindsight).

I'll link to this for sfml using codeblocks and gcc/mingw, since it explains better than I could begin to and should get you up and running. You'll want to decide whether to use dynamic or static libraries. There's plenty of information out there, including this site, discussing the pros/cons of each.

For other libraries, you'll often have to build them first, which is a bit tricky the first few times as well. Though, plenty of tutorials out there explain building libraries.

Beginner here <- please take any opinions with grain of salt

i've tried the exact same steps but still got an error

i've tried the exact same steps but still got an error


Here is an important lesson to learn: saying "I get an error" makes it practically impossible for people to help you. The error contains a lot more detail than just its presence. The text that is part of the error might not mean anything to you yet but without it no one can really help you.

photo added

Moving to For Beginners.

Offhand, I'd say to make sure you're linking in the correct order (i.e. graphics, window, then system). Make sure you're setting things either globally, or make sure you're linking and compiling in the same mode (debug or release).

If you're trying to link statically, I'd recommend trying to get it up and running dynamically first, as static with sfml gets a little awkward as you need to link all the dependencies and include things with your project, amongst other things.

Lastly, you may want to build sfml yourself, if you're doing absolutely everything else correctly. I don't mean to complicate things further, but it's possible there are minor things keeping it from working for you that aren't due to user error (newer/older version of codeblocks, your version of gcc, etc, etc).

But, keep at it, you'll get it working, and sfml will make your life much easier (going by your thread on keyboard input).

Feel free to keep posting updates, I think most here can be sympathetic enough to keep walking you through it. It's a tough thing to get a handle on at first.

Beginner here <- please take any opinions with grain of salt

thanks for the help ill try it out tommorow

Offhand, I'd say to make sure you're linking in the correct order (i.e. graphics, window, then system). Make sure you're setting things either globally, or make sure you're linking and compiling in the same mode (debug or release).

That's a runtime error, not a linker error. Linking sequence won't have an effect under normal circumstances.

If you're trying to link statically, I'd recommend trying to get it up and running dynamically first, as static with sfml gets a little awkward as you need to link all the dependencies and include things with your project, amongst other things.

According to the screenshot he is already linking dynamically. Granted, it would be better if he described what exactly he was doing instead of posting a single screen shot and then letting people guess, but the problem appears to be a symbol not being found in one of SFML's DLLs.

Lastly, you may want to build sfml yourself, if you're doing absolutely everything else correctly. I don't mean to complicate things further, but it's possible there are minor things keeping it from working for you that aren't due to user error (newer/older version of codeblocks, your version of gcc, etc, etc).

Here I can agree with. The error looks weird but without further information my guess would be a name mangling issue. Especially with MinGW having the library precompiled for your exact flavor of the compiler is important (there are up to three different exception models for Windows and two big different runtimes you might be using).
Additionally my personal advise would be to start learning C++ with one of the MSVC Express editions when you are working on Windows to begin with. It's far easier to get working, precompiled binaries for most common libraries for that compiler. Using MinGW will in most cases require you to compile the libraries you need yourself. That is not a bad thing at all, but when you are starting out that's not something I recommend dealing with as well as everything else.


Additionally my personal advise would be to start learning C++ with one of the MSVC Express editions when you are working on Windows to begin with. It's far easier to get working, precompiled binaries for most common libraries for that compiler. Using MinGW will in most cases require you to compile the libraries you need yourself. That is not a bad thing at all, but when you are starting out that's not something I recommend dealing with as well as everything else.

Great advice I think. In hindsight, I do recall having some issues on windows with codeblocks, mingw and sfml as well, and ended up just using visual studio. I had wanted to stay with codeblocks as it's what I use to compile on linux and I'm familiar with it, but once I tried to compile on windows, I had the damndest time with mingw/sfml/glfw/everything library-wise. I remember banging my head against the desk trying to get a mingw version working that supported c++14. Certainly some user-error on many of those fronts, I'm always a bit lost with all things windows :P I don't mean to bash anyone who maintains those libraries/compilers. But, ended up just doing visual studio and had a much easier time with things.

Beginner here <- please take any opinions with grain of salt

This topic is closed to new replies.

Advertisement