rainit2006 / C-Program

C# Program knowledge
0 stars 0 forks source link

常见error #2

Open rainit2006 opened 7 years ago

rainit2006 commented 7 years ago

cannot open include file "afxres.h" ◦Microsoft Visual Studio Professional以上で作成されたC/C++プロジェクトを、無償公開Express版でビルドしたとき上記エラーメッセージが表示されることがある。 ◦Express版にはMFC(Microsoft Foundation Class)本体は含まれないため、MFCを利用しているプロジェクトには対応できません。 ◦対策: afxres.hからwinres.hに書き換える ◦http://qiita.com/yohhoy/items/7c2a37cfcbb7fd6f26a1

MFC does not support WINVER less than 0x0501. All MFC apps define the WINVER macro value somewhere if you didn't define it yourself. I assume MS has removed the definition by default on its own header files and is now making mandatory that you explicitly define it. So, to solve your problem, either put the #define in your 'preprocessor' compiler options, or at the top of your precompiled header (ie stdafx.h). Note 0x501 is Windows XP support. 0x600 is Vista, 0x601 is Windows 7 — and how sad am I for remembering that! 解决方法: 在stdafx.h文件里定义WINVER和_WIN32_WINNT

define WINVER 0x0A00

 #define _WIN32_WINNT 0x0A00  

Source Control - Git. You are trying to edit read-only files. Do you want to mark ... Here are the steps I went through to fix it: 1.Open Visual Studio options (Tools -> Options) 2.Change the "Source Control Plug-In" to "None" (Source Control -> Plug-in Selection) 3.Restart Visual Studio

找不到common\platform.cpp文件。 工程:windirstat 发现windirstat工程的common下有platform.cpp文件显示,但是无法打开。从VS2015里删除它重新编译即解决。

error RC1106: invalid option: -ologo_RC you are using 6.x version of SDK which has a version of RC.exe with no support for switch -nologo. You can swtich your SDK to 7.0A verion 。

工程->property pages->Resources->General->Suppress Startup Banner设置成NO

其他,下面方法没有解决该问题: How to: Modify the Target Framework and Platform Toolset? https://msdn.microsoft.com/en-us/library/ff770576.aspx 开打相应Project的vcxproj文件,在 段落里,追加 v4.5。如果已存在 节点则修改其版本号。

LNK1327 failure during running mt.exe 'Configuration Properties->Linker->Manifest File' ->Generate Manifest: 选择NO

Values of attribute "level" not equal in different manifest snippets 'Configuration Properties->Linker->Manifest File' may be your solution. The 'UAC Execution Level' I think sets this for you in the generated .manifest file, and that by changing that to 'requireAdministrator'

VS2015不显示代码了 可能是VS2015的Bug。重新启动VS2015后,它会自动update,然后问题就解决了。

LNK2001 unresolved external symbol . 关于wds::authors和wds::translators..... 。 文件是aboutdlg.obj This error often means that some function has a declaration, but not a definition. 发现aboutdlg.cpp里有一处代码

using wds::authors;

而在wds_constants.h文件里,有下面定义。 extern ccontact_t authors[]; 也就是说这个authors是引用外部的变量。而整个工程里没有关于author数组的定义和赋值,所以发生了LINK时的引用错误。 这个author数组是用于在about对话框里显示作者信息的,没有什么影响,所以在Aboutdlg.cpp代码里给author数组赋值让程序运行通过就行了。

rainit2006 commented 7 years ago

luaconf工程上build时报错: LINK1181,cannot open input file '........\build\luajt2_win32.lib' 发现luaconf工程属性页里,Linker->input->Additioanl Dependencies设定内容是: '........\build\luajt2_$(Platform).lib;%(AddtionalDependencies)'

没找到好办法,后来把luajt2_win32.lib文件放到build目录下让其编译通过

//------------------------------------------------------------------------------ // 範囲選択モード typedef enum { MODE_NUM = 0, //時刻がなく、パケット番号で範囲選択する MODE_TIME //時刻で範囲選択する } VG_MODE;

extern VG_MODE g_nMode;

endif


对策方法:创建一个如下的 Mode.cpp源文件即可。

include "stdafx.h"

include "Mode.h"

VLOG_MODE g_nMode;

rainit2006 commented 6 years ago

here's a code snippet

main(int argc, char* argv[])
{
cout<<"number of arguments:" << argc<<endl;

for (int i=0; i<argc; i++)
       cout << "argument " << i << ": " << argv[i] << endl;
}

In the output I get

number of arguments:2
argument 0: c
argument 1: p

Why ?

发现工程里“Character Set”(工程右键->Properties->Configuration Properties->General)是“Use Unicode Character Set”, 改成“Use Multi-Byte Character Set”就正常动作了。

rainit2006 commented 6 years ago
rainit2006 commented 6 years ago
rainit2006 commented 6 years ago

c1xx :fatal error c1038:无法打开源文件 用editor打开 工程的vcproj文件,搜索对应的文件内容删除。 一般多是如下内容

<File
    RelativePath=".\xxxxx.cpp">
</File>
rainit2006 commented 6 years ago

LIBCMTD.lib与libcpmtd冲突的解决方法 http://blog.csdn.net/x_iya/article/details/11939037

error: 1>uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) 已经在 LIBCMTD.lib(new.obj) 中定义

解决方法: 编译工具:VS2008 项目--〉属性--〉配置属性--〉链接器--〉输入--〉附加依赖项--〉Nafxcwd.lib Libcmtd.lib 项目--〉属性--〉配置属性--〉链接器--〉输入--〉忽略特定库--〉Nafxcwd.lib;Libcmtd.lib

若有如下警告: LINK : warning LNK4098: 默认库“uafxcwd.lib”与其他库的使用冲突;请使用 /NODEFAULTLIB:library

请注意忽略特定库中二个库之间是否少了分号,如:Nafxcwd.lib;Libcmtd.lib,然后重新生成就没有这个警告了。若是Nafxcwd.lib Libcmtd.lib,就会报这个错误。 image

rainit2006 commented 6 years ago

ソースコードが元のバージョンと異なります

如果是在debug下: 1.检查工程配置是否设置正确。 C++>General->Debug Information Format->Program Database (/Zi) C++>Optimization->Optimization->Disabled (/Od) Linker->Debugging->Generate Debug Info->Yes (/DEBUG) Linker->Debugging->Generate Program Database File->$(TargetDir)$(TargetName).pdb

2.如果工程配置没问题,请打开:   Tools->Option->debugging->General 找到 Require source files to exactly match the original version 不要打勾

  即:工具->选项->调试里->常规 找到 要求原文件与原始版本完全匹配 不要打勾

rainit2006 commented 6 years ago

外部シンボル、未解決 解説: XXXX.obj : 外部シンボル ""void __cdecl my_func(void)" (?my_func@@YAXXZ)" は未解決です

というエラーが出る。XXXX.cpp 内では void my_func() が定義されていない。関数のプロトタイプだけしかを与えていない場合でもソースファイルはコンパイルできるので、XXXX.obj が生成され、 XXXX.obj に 「my_func関数を外部参照している」という情報が記述される。リンカはオブジェクトファイルをリンクする前に、他のオブジェクトファイルとライブラリファイルの中に、外部参照である my_func関数の定義があるか検索し、正しくリンクできるかどうかを確認する。検索した中に void my_func() の定義が存在しなかった場合、このエラーが起こる。

外部参照の例としては、関数やグローバル変数、ラベルなどがあり得る。

解決法: 外部シンボルとして提示されたシンボルが自分で定義したシンボルか、ライブラリによって提供されるものかどうかで対応法が変わる。 自分で定義したシンボルの場合は、その関数の定義をしているかどうかを確認する。定義したはずなのに、このエラーが出る場合は、名前を間違えていないか、定義しているソースがちゃんとプロジェクトに入っているかどうか(コンパイルされるか)をチェックする。

ライブラリによって提供されるシンボルの場合は、ライブラリファイルとリンクしているかが重要なポイントとなる。例えば、 InitCommonControlsEx 関数は、Comctl32.lib の中に実体の情報が入っている。ただし、デフォルトの設定でビルドしても、Comctl32.lib はリンクされないため、このエラーが出る。これを解決するには、プロジェクトにライブラリファイルを追加すればよい。もう一つの方法は、メニューの 『プロジェクト→設定』 からか Alt + F7 キーを押して プロジェクトの設定 ダイアログを表示し、プロジェクトを選択してリンクタブから 『オブジェクト/ライブラリ モジュール』 に 『Comctl32.lib』 を追加する。デフォルトでライブラリファイルは 『C:\Program Files\Microsoft Visual Studio\VC98\Lib』 にあるが、Platform SDK をインストールした場合は、そちらが最新のものである。 もう一つの原因として、ライブラリファイルのバージョンがヘッダファイルと異なる可能性もある。