undefined reference to WinMain@16 (codeblocks)

后端 未结 7 1717
天命终不由人
天命终不由人 2020-12-30 08:18

When I compile my secrypt.cpp program, my compiler shows the error \"undefined reference to WinMain@16\". my code is as follows

secrypt.h :



        
相关标签:
7条回答
  • 2020-12-30 08:40

    When there's no project, Code::Blocks only compiles and links the current file. That file, from your picture, is secrypt.cpp, which does not have a main function. In order to compile and link both source files, you'll need to do it manually or add them to the same project.

    Contrary to what others are saying, using a Windows subsystem with main will still work, but there will be no console window.

    Your other attempt, compiling and linking just trial.cpp, never links secrypt.cpp. This would normally result in an undefined reference to jRegister(), but you've declared the function inside main instead of calling it. Change main to:

    int main()
    {
        jRegister();
    
        return 0;
    }
    
    0 讨论(0)
  • 2020-12-30 08:40

    Well I know this answer is not an experienced programmer's approach and of an Old It consultant , but it worked for me .

    the answer is "TRY TURNING IT ON AND OFF" . restart codeblocks and it works well reminds me of the 2006 comedy show It Crowd .

    0 讨论(0)
  • 2020-12-30 08:50
    1. You need to open the project file of your program and it should appear on Management panel.

    2. Right click on the project file, then select add file. You should add the 3 source code (secrypt.h, secrypt.cpp, and the trial.cpp)

    3. Compile and enjoy. Hope, I could help you.

    0 讨论(0)
  • 2020-12-30 08:52

    You should create a new project in Code::Blocks, and make sure it's 'Console Application'.

    Add your .cpp files into the project so they are all compiled and linked together.

    0 讨论(0)
  • 2020-12-30 08:53

    I was interested in setting up graphics for Code Blocks when I ran into a this error: (took me 2 hrs to solve it)

    I guess you need to have a bit of luck with this. In my case i just changed the order of contents in Settings menu->Compiler and Debugger->Global compiler settings->Linker settings->Other Linker Options: The working sequence is: -lmingw32 -lSDL -lSDLmain

    0 讨论(0)
  • 2020-12-30 09:03

    Open the project you want to add it.

    Right click on the name. Then select, add in the active project. Then the cpp file will get its link to cbp.

    0 讨论(0)
提交回复
热议问题