first time installation. getting error ld. exe cannot find -lsprite

I installed code blocks first time. I am using windows 10, code blocks version 20.03. When i am trying to compile code i am getting error:
ld.exe cannot find -lsprite
ld.exe cannot find -lbgi
error : ld returned 1 exit status.
I am running hello world code:

#include <iostream>

using namespace std;

int main()
{
cout << "Hello world!" << endl;
return 0;
}
Last edited on
The code is valid. I don't recommend using code blocks. Try Visual Studio. You can run code online while learning until you figure it out:

cpp.sh
I am using windows 10, code blocks version 20.03.

Condolences.

ld.exe cannot find -lsprite
ld.exe cannot find -lbgi
error : ld returned 1 exit status.

When you install Code::Blocks in Windows, it usually takes along some version of the MinGw compiler.
ld.exe is the MinGw linker.
Those error say the linker cannot find the libraries ‘bgi’ and ‘sprite’.

Browsing Internet, it seems bgi could be the “Borland Graphics Interface […] a graphics library bundled with several Borland compilers for the DOS operating systems since 1987” (Wikipedia), while sprite could be part of the SFML library.

It looks like you want to link against those libraries, but you haven’t provided your compiler the proper information (the directories) to find them.

#include <iostream>

using namespace std;

int main()
{
cout << "Hello world!" << endl;
return 0;
}

I’m afraid if you don’t explain what you’re really trying to do, we can’t help you.
I just want to know that why am i getting those errors and how to resolve them?
I just want to know that why am i getting those errors and how to resolve them?

You are getting those errors because you’re trying to link against the mentioned libraries the wrong way.
Either you haven’t installed them, or their aren’t in the directories you specified to the compiler, or you missed to specify the directories.

You can resolve those errors by providing the compiler the right information.
Nah, lsprite is not SFML.

OP, just make a new, empty project. Don't use one of the existing project templates.

Go into your project/build settings and remove any linker options.
I tested my C:B 20.03 install, twice creating a new project. 1st using the Console application template wizard, 2nd time using the Empty project template.

Both compiled C++ "Hello World" code without a problem.

@gsmehta7, something about your installation is borked. I couldn't even begin to try to guess what without a lot more information.

You might try uninstalling C:B from your system, and deleting the install dir. Then follow the instructions for C:B here:
https://www.learncpp.com/cpp-tutorial/installing-an-integrated-development-environment-ide/
and
https://www.learncpp.com/cpp-tutorial/writing-your-first-program/

Good luck! I hope you get your problems solved.

And if/when you can compile code in C:B successfully let us know what you did. That could help others in the future who have the same/similar problems.
Topic archived. No new replies allowed.