有人可以在visual studio 2008中解释链接器属性中这两个声明之间的区别(请尽可能简单,我是C++世界的新手)
编辑:如果可能,你可以给我两个小程序来显示效果
整个错误输出是:
LNK2019 unresolved external symbol wWinMain referenced in function "int __cdecl __scrt_common_main_seh(void)" (?__scrt_common_main_seh@@YAHXZ) kachna-tracker C:\dev\kachna-tracker\MSVCRT.lib(exe_wwinmain.obj)
Run Code Online (Sandbox Code Playgroud)
这是从Qt Creator导入的项目,只有在我尝试构建Release
版本时才会出现此错误,Debug
版本运行得很好.据我所知,除了使用库的调试版本(例如qtmain.lib
/ qtmaind.lib
)之外,Debug
和Release
配置之间的链接器配置没有区别.
我发现这个错误可以固定由子系统设置/SUBSYSTEM:CONSOLE
,而不是/SUBSYSTEM:WINDOWS
,这确实不解决这个问题,但我建立一个GUI应用程序,一个永久打开控制台窗口是相当难看,也可能只修复了症状而不是原因.
如何解决这个错误?
我试图找出如何找到下载文件集或摆脱此错误的位置.这个难以捉摸的'basewin.h'无处可寻.所以我不知道我是否错过了一个图书馆或者是什么.我也试过切换'windows.h'和'basewin.h'语句.我试过禁用预编译头文件.显然,这个文件包含"basewindow"类的信息.
我正在使用visual studio 2013,我正在使用win32项目.我正在尝试从微软教程网站运行该示例http://msdn.microsoft.com/en-us/library/windows/desktop/ff684181 (v = vs.85).aspx.任何帮助将非常感谢.这是代码:
#include <windows.h>
#include <d2d1.h>
#pragma comment(lib, "d2d1")
#include "basewin.h"
template <class T> void SafeRelease(T **ppT)
{
if (*ppT)
{
(*ppT)->Release();
*ppT = NULL;
}
}
class MainWindow : public BaseWindow<MainWindow>
{
ID2D1Factory *pFactory;
ID2D1HwndRenderTarget *pRenderTarget;
ID2D1SolidColorBrush *pBrush;
D2D1_ELLIPSE ellipse;
void CalculateLayout();
HRESULT CreateGraphicsResources();
void DiscardGraphicsResources();
void OnPaint();
void Resize();
public:
MainWindow() : pFactory(NULL), pRenderTarget(NULL), pBrush(NULL)
{
}
PCWSTR ClassName() const { return L"Circle Window Class"; }
LRESULT HandleMessage(UINT uMsg, WPARAM wParam, …
Run Code Online (Sandbox Code Playgroud) 我的代码抛出了这个错误:
1>MSVCRTD.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol WinMain referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
1>C:\Users\thequantumforge\Desktop\scripts\Visual Studio 2013\Projects\newtonsmethod\x64\Debug\newtonsmethod.exe : fatal error LNK1120: 1 unresolved externals
Run Code Online (Sandbox Code Playgroud)
代码如下:
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <cfloat>
#include <chrono>
using namespace std;
const long double h = LDBL_EPSILON;
long double equation(long double x) {
return (pow(x, 3) - x + 1);
}
long double intercept(long double x) {
// x_n+1 = xn - f(xn)/f'(xn)
long double deriv = (equation(x + …
Run Code Online (Sandbox Code Playgroud) 我试图使用不显示控制台窗口的CMake,Qt和Visual Studio构建可执行文件.
我发现这篇文章和这个答案
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ENTRY:mainCRTStartup")
Run Code Online (Sandbox Code Playgroud)
但是我想知道QtCreator如何能够构建一个没有这个/ ENTRY标志的可执行文件而不显示控制台窗口?
我需要做些什么来修复程序中未初始化的错误?该程序假设打印一个数字具有的除数,但仍然显示错误,表示变量c未初始化.
/*
/ Name: Ralph Lee Stone
/ Date: 10/10/2013
/ Project: RLStone3_HW_08
/ Description: This program gets a positive value and determines the number of divisors it has.
*/
#include <iostream>
using namespace std;
int DivisorCount(int x)
{
int counter = 0;
for(int c; x < c; c++)
{
if (x%c==0)
counter++;
}
return counter;
}
int main()
{
int x;
cout << "Please a positive value: ";
cin >> x;
cout << x << "has this many divsors: …
Run Code Online (Sandbox Code Playgroud) 我该如何解决此错误:
Error 1 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
Run Code Online (Sandbox Code Playgroud)
我还定义了cai.cpp中的所有函数.但是由于代码行太多,我没有上传它.我确实将.h文件包含在cai.cpp中.我对这个错误的问题感到困惑.
main.cpp文件
#include "cai.h"
int main()
{
CAI test;
test.StartTest();
}
Run Code Online (Sandbox Code Playgroud)
cai.h文件
class CAI
{
public:
void StartTest();
bool AskRandomMultiplicationQuestion();
bool AskRandomDivisioQuestion();
private:
void PrintRandomGoodJob();
void PrintRandomEncouragementMessage();
int ChooseRandomNumber();
void PrintTestSummary(int, int, int);
};
Run Code Online (Sandbox Code Playgroud)