C ++未定义的引用WinMain @ 16(Code :: Blocks) [英] C++ undefined reference to WinMain@16 (Code::Blocks)
问题描述
我正在学习C ++与Code :: Blocks,每次我试图创建一个新类,我得到一个错误消息:
code>未定义引用`WinMain @ 16'
:
主类
#includeLime.h
#include< iostream>
using namespace std;
int main()
{
石灰;
return 0;
}
Lime类(.ccp):
#includeLime.h
#include< iostream>
using namespace std;
Lime :: Lime()
{
cout<<Hi!
}
Lime标题(.h):
#ifndef LIME_H
#define LIME_H
class Lime
{
public:
Lime
};
#endif
如果有人知道如何解决它,请告诉我! / p>
尝试:
设置
- > Compiler
,点击构建选项
标签,选中复选框
将当前编译文件的目录显式添加到编译器搜索目录
PS
下一次创建新类时,在文件策略
部分,请确保选中复选框
添加项目路径
- p> NOT 选择
使用相对路径
I'm learning C++ with Code::Blocks, and everytime i try to create a new class, I get an error message saying:
undefined reference to `WinMain@16'
Here's the code I've been using:
Main Class
#include "Lime.h" #include <iostream> using namespace std; int main() { Lime lime; return 0; }
Lime Class (.ccp):
#include "Lime.h" #include <iostream> using namespace std; Lime::Lime() { cout<<"Hi!"; }
Lime Header (.h):
#ifndef LIME_H #define LIME_H class Lime { public: Lime(); }; #endif
If someone knows, how to fix it, please, tell me!
解决方案Try this:
Settings
->Compiler
, click the tabBuild options
, select the checkboxExplicitly add currently compiling file's directory to compiler search dirs
P.S.
Next time when you create a new class, in the
File policy
section, make sure you select checkboxes
Add path to project
Header and implementation file shall be in same folder
However, do NOT select
Use relative path
这篇关于C ++未定义的引用WinMain @ 16(Code :: Blocks)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!