PNcoder258
PNcoder258

Reputation: 3

why my code is showing error undefined reference to `WinMain@16'?

I wanted to use a function which I have defined on file h3.cpp in main.cpp for which I created a file h3.h and declared that particular function in the header file. but my file h3.cpp is not getting compiled and showing error--

undefined reference to `WinMain@16'--

//main.cpp
#include<iostream>
#include"h3.h"

using namespace std;
int main(){
    intlog();
    log("hello");

    return 0;
}
//h3.cpp

#include<iostream>
#include"h3.h"
void log(const char* message){
    std::cout<<message<<std::endl;
}
void intlog(){
    log("world");
}
//h3.h(HEADER FILE)

#pragma once
#include<iostream>
void log(const char* message);
void intlog();

Upvotes: 0

Views: 364

Answers (1)

3CxEZiVlQ
3CxEZiVlQ

Reputation: 38893

Do changes in the project settings if you are using Visual Studio.

Go to the Project menu, your project properties, Linker, System and change the SubSystem option from Windows (/SUBSYSTEM:WINDOWS) to Console (/SUBSYSTEM:CONSOLE) via the drop-down list.

Do changes in the project/target options if you're using Code::Blocks.

Goto Build Targets, the default setting for Type: GUI application - is incorrect for your project, change it to Console application via the drop-down list.

Upvotes: 2

Related Questions