CodeLite C++, can not open .exe file of the project when using iostream library

Hello
I recently changed the IDE I use to CodeLite, and I seem to get a problem. I made my first testing Hello World program to test if everything is OK, and it runs without errors both in IDE when pressing ctrl+F5, and from .exe file in ../Project1/build-Debug/bin/ of the project.

1
2
3
4
5
6
7
8
  #include <stdio.h>
  
  int main(int argc, char **argv)
  {
      printf("Hello world\n");
      char a = getchar();
      return 0;
  }


Although, if I try to include iostream library, which I prefer to work with, even though in IDE when I hit run everything works without any errors, when I try to open the executable file in /bin/ it can't run the program and shows error message "Fails to continue code execution, system could not find libstdc++-6.dll. To fix this problem try to reinstall the program".
It's obvious that I can't always open the IDE to run the programs I made, especially if I'd want to share them, but at the same time I am too used to the iostream library, that I can't just leave it. Is there any way to fix this?
Last edited on
The code you wrote is C code, not C++. <stdio.h> is a C header, the C++ equivalent is <cstdio>.

CodeLite is probably compiling it as C instead of C++. I don't use CodeLite so that is just a guess.

Here's one version of "Hello World" in C++:
1
2
3
4
5
6
7
8
9
#include <iostream>

int main()
{
   std::cout << "Hello World!" << '\n';

   // the output statement could be written like this:
   // std::cout << "Hello World!\n";
}
What operating system are you running?

Your error says it can't find a library, check and make sure that library is in your path.


I'm not really sure about that. Yeah, I tried to use the <cstdio> library, and it worked fine as well, plus the source file is the .cpp file, and the project in CodeLite is the g++ simple executable project, so I'm not really sure what is wrong in here.

Maybe I'll still try to change to <cstdio>, although I feel like similar problem will arise with other standart libraries and headers.

Still, thanks for the help (to be honest I never knew that stdio.h is the C header, not C++).
I am running it on Windows 10 x64

I'm not really sure how to use the IDE yet, I installed CodeLite like yesterday, before I was using Visual Studio, where you did not have to care about standart C++ libraries like <iostream> or others
EptatProgamer wrote:
I am running it on Windows 10 x64

Dump CodeLite, get Visual Studio 2022 Community instead. It's free for non-commerical use.
https://visualstudio.microsoft.com/downloads/

VS 2022 admittedly can be a hog on HD space, but since you are on Windows 10 x64 it is probably gonna be a much better fit for your programming needs IMO. A combined code editor, compiler and debugger in one package. One of the best for Windows-based development.

Plus it is currently the only C++ compiler that is 100% compliant with the C++20 standard. That may not be a concern at the moment for you, but it is something to consider.

One thing to note, if'n you do get VS the C++ workload has to be manually selected for install, it isn't part of the default.

If VS is not something you want consider Code::Blocks.
https://www.codeblocks.org/downloads

The C::B website is currently unavailable, so unable to download the installer. ::sad::

Here's some helpful tips for installing either VS or C::B:
https://www.learncpp.com/cpp-tutorial/installing-an-integrated-development-environment-ide/
First take a look at your path.
You probably need to know where libstdc++-6.dll is on your system.

You might want to read up on what dll is, and how your program uses it.

Also in the future you need to decide if you want your program to dynamically link at run time, or if you want to statically link to the library.

I don't use codelite so I can't give specific advice, but when you understand your problem the solution should be easy enough to Google.

I think what you want is change your compiler settings so that it statically links to that library, but understanding the problem is probably going to help you more in the future.
I might actually consider

I did use VS 2019 before, and I have some experience. I was afraid it was too heavy IDE for my laptop, so I thought of some other variants that I can use.

CodeLite just seemed a pretty good one for the case - it is a pretty light program, simple HelloWorld projects in it don't weight over 5MB, and overall it seemed a bit suiting IDE for me, transferring from beginner in C++ to middle, although now when you mentioned it and it's flaws, I might try Visual Studio back again instead.

Thanks for the suggestion anyway. :)
There is an alternate download site for the current Code::Blocks version, 20.03:
https://sourceforge.net/projects/codeblocks/files/Binaries/20.03/Windows/
Topic archived. No new replies allowed.