简体   繁体   中英

Using SFML for Codeblocks C++ appears ERROR library SFML

I have a problem when I tried to install SFML on Codeblocks. Well, first I install codeblocks: codeblocks-20.03mingw-setup.exe. That's compile correctly after that I download SFML 2.5.1: GCC 5.1.0 TDM (SJLJ) - Code::Blocks - 32-bit.

Following, I extract the SFML file.The problem comes I COPY THE CONTENT OF "BIN" INSIDE OF MY CODEBLOCKS PROJECT. A video helps me to do all of before, I WROTE ALL THE LIBRARIES: GRAPHICS, WINDOW, NETWORK, AUDIO, SYSTEM BUT NOTHING. I show you the error:

cannot find -lsfml-audio-d-2

And continue with network, window,system, graphics

At the ends:

error: ld returned 1 exit status

what's wrong? help me please. I have to make a video game using CODEBLOCKS as soon as I fixed this problem. I'll so thankful for your answers.

On the SFML download website ( https://www.sfml-dev.org/download/sfml/2.5.1/ ), it says:
The compiler versions have to match 100%!

The CodeBlocks 20.03 MinGW installation includes version 8.1.0 of the GCC compiler (as is stated on the download page: http://www.codeblocks.org/downloads/26 ).

Your downloaded version of SFML thus is only intended to work with version 5.1.0 of GCC, but you have version 8.1.0. This can result in a number of errors.

There are a few possibilities to fix your issue:

  1. You could theoretically compile SFML yourself with your specific compiler, but this option may be quite complicated.

  2. You could use a compiler with the matching version. On the SFML download website, there are some links to the needed compilers. After having installed a compiler, you will have to configure CodeBlocks to detect the new compiler on your system (reference: Adding compiler to code::blocks ). Now, in order to add SFML to your project, I would suggest to use this official guide: https://www.sfml-dev.org/tutorials/2.5/start-cb.php

  3. You could use an environment like MSYS2 (which I use personally) to have a package manager to manage your compiler and libraries installations. This way, your compiler installation and your libraries should work with each other. But in order to use this compiler in CodeBlocks, CodeBlocks would have to be configured.

I would suggest that you refer to option 2 because it probably is the quickest solution.

Feel free to ask if you have any more questions. I know from personal experience that setting up SFML (or any other C++ library) to work with your IDE may be quite tricky.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM