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?
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";
}
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'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
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.
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 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.