0
I have authored the following Hello World C++ example...


#include <iostream>

using namespace std;

int main(){

    cout << "Hello World!";

    return 0;
}

...however, I am getting the following error message.
"e:\reality\visual studio\" && g++ first.cpp -o first && "

e:\reality\visual studio\"first

c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):
(.text.startup+0xa0): undefined reference to `WinMain@16'

collect2.exe: error: ld returned 1 exit status
JΛYDΞV
  • 8,532
  • 3
  • 51
  • 77
  • Well first of all your missing an angle bracket in `` – JΛYDΞV Feb 26 '22 at 07:00
  • Secondly, it looks like your using a Unix Style path to referenc the Mingw executable binary. `c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0)` **You are suppose to use backslashes in windows** forward slashes are for, well.. every other system ever invented (i.e. Linux, Unix, MacOS). – JΛYDΞV Feb 26 '22 at 07:02
  • hey JΛYÐΞV what should I do to overcome this problem of unix pathy?? – Dev Gopal Ray Feb 26 '22 at 07:17
  • I would suggest not to quit your job, instead do exciting things on a part time basis. – Dev Gopal Ray Feb 26 '22 at 07:21
  • how can I connect with u if I face further problems in this? your insta or whatsapp – Dev Gopal Ray Feb 26 '22 at 07:22
  • Its been a while since I have used MinGW for compiling C++, but basicly, MingGW allows you to use a Linux based Compiler (GNU's GCC Compiler) while on a windows device. That said, somtimes configuring your environment will require you to write paths correctly for windows. You need to convert your forwards slashes to backslashes by using escaped backslashes. That means 2 backslashes for every one forward slash. – JΛYDΞV Feb 26 '22 at 07:23
  • I don't wana teach no body. If you got more questions just ask them here. – JΛYDΞV Feb 26 '22 at 07:24
  • what you need to do, is create this task, and get it working. Also take note of the backslashes in the `arg` key https://code.visualstudio.com/docs/cpp/config-mingw#_build-helloworldcpp – JΛYDΞV Feb 26 '22 at 07:25
  • Can u suggest any other compiler that I should install instead of mingw for vs code?? – Dev Gopal Ray Feb 26 '22 at 07:26
  • Click that link, and view that task. That task is how you write simple automation for compiling your CPP in VSCode – JΛYDΞV Feb 26 '22 at 07:26
  • If your new to C++ you should probably start with Visual Studio 2022, instead of Visual Studio Code. Visual Studio 2022 uses MVSC, and it also uses special files that you don't have to use a compiler with, the IDE will just automate the whole compilation process – JΛYDΞV Feb 26 '22 at 07:28
  • If your new to programming, and if C++ is where you want to start, thats great. Im a Computer Science student, and they tought me C & C++ first – JΛYDΞV Feb 26 '22 at 07:29
  • However, if you want to learn VS Code, and how to ptogram, then you should learn either Node.js or Python – JΛYDΞV Feb 26 '22 at 07:29
  • I highly suggest Node.js, its a JavaScript based runtime that simple, dynamicly typed, and no compiler needed. – JΛYDΞV Feb 26 '22 at 07:30
  • C++ is tough. You should work with a book in an IDE, not an editor. VS Code is an editor, while Visual Studio 2022 is an IDE (Integrated Development Environment), which means that the program you write is intertwined with the environment you are using to write it. – JΛYDΞV Feb 26 '22 at 07:32
  • I know python and code python on jupyter. – Dev Gopal Ray Feb 26 '22 at 07:32
  • java script is the next one I will learn . – Dev Gopal Ray Feb 26 '22 at 07:33
  • Oh okay great. Well if your looking for control over memory, then C++ is what you want – JΛYDΞV Feb 26 '22 at 07:33
  • for c++ i used to code on online compilers like gdb or on codechef – Dev Gopal Ray Feb 26 '22 at 07:33
  • JavaScript and python are nothing alike, and at the same time, there almost exectly the same. Its really useful to know both honestly. But if you want to learn a compiled language using VS Code, then I very Highly recommend TypeScript. Which is Compiled Staticly Typed JavaScript (Transpilled actually) – JΛYDΞV Feb 26 '22 at 07:34
  • GDB is a debugger, its the GNU debugger for GCC. – JΛYDΞV Feb 26 '22 at 07:35
  • On windows though, I suggest using Visual Studio 2022, and if you want to create software, check out the Windows SDK – JΛYDΞV Feb 26 '22 at 07:35
  • To be honest I actually perfer C over C++. – JΛYDΞV Feb 26 '22 at 07:36
  • C++ is a messy nasty language. Its really overrated. – JΛYDΞV Feb 26 '22 at 07:36
  • Its got the worst syntax of any modern language thats heavily used. – JΛYDΞV Feb 26 '22 at 07:37
  • i also think c is a better language – Dev Gopal Ray Feb 26 '22 at 07:37
  • 1
    i will try visual studio and windows SDK. – Dev Gopal Ray Feb 26 '22 at 07:38
  • Anyway, I have gave you plenty to think about. Last bit of advice. If you do want to use MingGW on VSCode, you need to get the tasks up and running. Not only do the help you compile, but also build & run your software. Also if your not going to using an integrated development environment, your going to need to use a build technology like Make or CMake, assuming you write more than one file. – JΛYDΞV Feb 26 '22 at 07:40
  • Visual Studio 2022 was made for C++ C & C# – JΛYDΞV Feb 26 '22 at 07:40
  • VS Code really speciallizes in Python, JavaScript, CSS/HTML, the dynamic languages & markup – JΛYDΞV Feb 26 '22 at 07:41
  • 1
    thank you for the wonderful advises. I will really look forward to use those softwares. You gave a great input to my programming life. – Dev Gopal Ray Feb 26 '22 at 07:44

0 Answers0