对于一个Windows应用程序,我试图得到CreateWindow()它WndProc()(或我的版本)成为一个单独的类的一部分,它是在开始时创建的,_tWinMain()但是因为尝试将函数转移到GameHandler.h,GameHandler.cpp我不断得到"未解析的外部符号_WinMain @" 16" .它们最初是全局函数,main.cpp并且一切都编译得很好然后我决定将它们移动到GameHandler,因为我得到的是未解析的外部,即使我试图将它们移回main.cpp.
我在VS2010中这样做,该项目是作为Windows应用程序创建的,并且在属性中没有设置特定的入口点(我仔细检查过,因为我发现的每个解决方案都说是因为它是一个控制台应用程序 - 这不是' T).
我目前拥有的代码如下所示.实际项目有几千行其他代码我遗漏了,因为我认为它不相关(但很高兴证明是错误的.虽然实际的窗口创建代码是相关的,但我不认为代码本身是问题(除了我留下的),它是GameWindowProc()和/或CreateGameWindow()的位置或它们的调用方式.实际的窗口创建代码取自NeHe的教程.试图仅编译以下代码给出上述未解决的外部因素.
main.cpp中:
#include <Windows.h>
#include "GameManager.h"
#ifndef USEGMGR
bool CreateGameWindow(char* title, int width, int height, int bits, bool fullScreenFlag);
LRESULT CALLBACK GameWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
#endif
int APIENTRY _tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
LPTSTR lpCmdLine, int nCmdShow)
{
GameManager::Startup();
GameManager* GMgr = GameManager::GetInstance();
GMgr->SetProgramState(GAME_MODE);
while(GMgr->GetProgramState() != GAME_MODE) // Normally this would be if …Run Code Online (Sandbox Code Playgroud) 我的问题在于以下背景:
file1.h
#include "graphwnd.h"
#include "file2.h"
class XXX:
{
....various things....
protected:
CGraphWnd graph_wnd_sensor1D;
}
Run Code Online (Sandbox Code Playgroud)
file1.cpp
#include "file1.h"
(... various stuff ...)
void main(){
OnInitGraph(&graph_wnd_1_sensor2D, rect_1_sensor2D);
graph_wnd_sensor1D.ShowWindow(SW_HIDE);
myYYY.Init();
}
(... various stuff ...)
Run Code Online (Sandbox Code Playgroud)
这里graph_wnd_sensor1D有一个值,ShowWindow有效
档案2.h
extern CGraphWnd graph_wnd_sensor1D;
class YYY:
{
void YYY::Init(){
graph_wnd_sensor1D.ShowWindow(SW_SHOW);
}
....various things....
}
Run Code Online (Sandbox Code Playgroud)
这里,在init中,应用程序崩溃,因为graph_wnd_sensor1D与前一个信息的信息不同.
在文件2.cpp中我想使用graph_wnd_sensor1D.但视觉效率
CMyTabCtrl.obj : error LNK2001: external symbol unresolved "class CGraphWnd graph_wnd_sensor1D"
Run Code Online (Sandbox Code Playgroud)
这是我的(好吧不是我的:))代码:
/*
* This Code Was Created By Jeff Molofee 2000
* A HUGE Thanks To Fredric Echols For Cleaning Up
* And Optimizing This Code, Making It More Flexible!
* If You've Found This Code Useful, Please Let Me Know.
* Visit My Site At nehe.gamedev.net
*/
#include <windows.h> // Header File For Windows
#include <gl\gl.h> // Header File For The OpenGL32 Library
#include <gl\glu.h> // Header File For The GLu32 Library
#include <gl\GLaux.h> // Header File For The …Run Code Online (Sandbox Code Playgroud) 在链接过程中,Visual Studio告诉我D3DCompileFromFile是一个未解析的外部符号.
error LNK2019: unresolved external symbol _D3DCompileFromFile@36
Run Code Online (Sandbox Code Playgroud)
我的程序编译正常,但在链接时失败.我目前将我的(项目属性 - >配置属性 - >链接器 - >常规 - >)其他库目录设置为:$(WindowsSDK_LibraryPath_x86)
请有人让我知道我错过了什么.
另外,您需要DirectX SDK吗?我已经知道了,但我已经阅读了关于Windows 8的内容.
编辑:还注意到我也得到了D3D11CreateDeviceAndSwapChain.
error LNK2019: unresolved external symbol _D3D11CreateDeviceAndSwapChain@48
Run Code Online (Sandbox Code Playgroud)
谢谢.
我有一个编译好的静态库(让我们称之为A),它依赖于另一个静态库(让我们称之为B).
我也有项目X,它使用库A.所以在XI中包括B然后,在它下面,包括A,都在stdafx.h中.我这样做是使用#pragma comments.项目X编译得很好.
然而,我有项目Y也使用库A.但是,即使项目Y的stdafx.h是X的IDENTICAL,Y也不编译,给出"未解析的外部符号"错误.更奇怪的是,错误是指来自库A中引用的函数的库B中的函数.
有谁知道为什么会发生这种情况?对不起,如果我不清楚; 有这么多代码我不知道从哪里开始包含它.谢谢!
我下载了Crypto++5.62并使用默认项目设置构建它.在我的项目中,我设置了路径,cryptopp.lib并在"附加依赖项"中定义了它的名称.Crypto ++和我的项目 - VS 2008.
在构建我的项目期间,我得到:
main.obj : error LNK2001: unresolved external symbol
"class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const CryptoPP::DEFAULT_CHANNEL" (?DEFAULT_CHANNEL@CryptoPP@@3V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@B)
main.obj : error LNK2001: unresolved external symbol
"bool (__cdecl* CryptoPP::g_pAssignIntToInteger)(class type_info const &,void *,void const *)" (?g_pAssignIntToInteger@CryptoPP@@3P6A_NABVtype_info@@PAXPBX@ZA)
Run Code Online (Sandbox Code Playgroud)
dumpbin /all cryptopp.lib 在公共符号部分显示我
19471C _imp_?DEFAULT_CHANNEL@CryptoPP@@3V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@B
1D6F30 __imp_?g_pAssignIntToInteger@CryptoPP@@3P6A_NABVtype_info@@PAXPBX@ZA
Run Code Online (Sandbox Code Playgroud)
那怎么了?为什么链接器找不到符号?
UPD:
我的项目设置中的链接器命令行
/OUT:"C:\Projects\crypto_hash\Debug\crypto_hash.exe" /NOLOGO /LIBPATH:"e:\libs\cryptopp\cryptopp562\cryptopp\Win32\DLL_Output\Debug" /MANIFEST /MANIFESTFILE:"Debug\crypto_hash.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Projects\crypto_hash\Debug\crypto_hash.pdb" /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT cryptopp.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
我正试图通过Google Test框架+ Visual Studio 2013进行我的第一次单元测试.但是我遇到了以下错误并且无法理解原因.
1> ------ Build build:Project:FirstGoogleTest,Configuration:Debug Win32 ------
2> ------ Build build:Project:googleTest,Configuration:Debug Win32 ------
1> MyMultiplier.cpp
2> gtest_main.cc
1> main.cpp
1>生成代码...
2> gtest-all.cc
1> FirstGoogleTest.vcxproj - > D:_Vault\Workspaces\UnitTestLearning\FirstGoogleTest\Debug\FirstGoogleTest. exe
2>生成代码...
2> googleTest.vcxproj - > D:_Vault\Workspaces\UnitTestLearning\FirstGoogleTest\Debug\googleTest.lib
3> ------ Build build:Project:MyMultiplier_UnitLevelTest,Configuration:Debug Win32 - -----
3> MyMultiplier_UnitLevelTest.cpp
3> MyMultiplier_UnitLevelTest.obj:错误LNK2019:未解析的外部符号"public:unsigned int __thiscall
MyMultiplier :: multiply(unsigned int,unsigned int)"(?multiply @ MyMultiplier @@ QAEIII @ Z )在函数"private:virtual void __thiscall MyMultiplier_multiplyNormalSmallValues_Test :: TestBody(void)"中引用(?TestBody @MyMultiplier_multiplyNormalSmallValues_Test @@ EAEXXZ)
3> D:_Vault\Wo rkspaces\UnitTestLearning\FirstGoogleTest\Debug\MyMultiplier_UnitLevelTest.exe:致命错误LNK1120:1未解析的外部因素
==========构建:2成功,1失败,0最新,0跳过==== ======
解决方案结构如下:https:
//www.dropbox.com/s/0cu8eqr7pz3ajaz/Untitled.png …
我一直遇到使用SFML的cmake和Visual Studio 2013的问题.当我尝试编译我的程序时,我正在为使用SFML的所有东西获得未解析的外部.我在多台机器上遇到过这个问题,在某些情况下还有一些其他的库.
我正在使用以下命令生成我的Visual Studio项目(在VisualStudioProject文件夹中):
Z:/Coding/cmake/cmake-3.1.1-win32-x86/bin/cmake.exe -G"Visual Studio 12"..
这是我的CMakeLists.txt(它实际上是从我写的python脚本生成的,但我怀疑这很重要).我可以确认正确找到所有库.
cmake_minimum_required (VERSION 2.6)
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib )
project(Game)
include_directories( Z:/Coding/Libraries/SFML/SFML-2.2/include Z:/Coding/Game/src/win32 Z:/Coding/Game/src )
find_library( SFML-GRAPHICS NAMES sfml-graphics PATHS Z:/Coding/Libraries/SFML/SFML-2.2/lib NO_DEFAULT_PATH )
find_library( SFML-WINDOW NAMES sfml-window PATHS Z:/Coding/Libraries/SFML/SFML-2.2/lib NO_DEFAULT_PATH )
find_library( SFML-SYSTEM NAMES sfml-system PATHS Z:/Coding/Libraries/SFML/SFML-2.2/lib NO_DEFAULT_PATH )
add_executable( win32 "Z:/Coding/Game/apps/win32.cpp" )
target_link_libraries( win32 ${SFML-GRAPHICS} ${SFML-WINDOW} ${SFML-SYSTEM} )
Run Code Online (Sandbox Code Playgroud)
这是我简单的SFML测试程序:
#include <string>
#include <iostream>
#include <SFML/Graphics.hpp>
using namespace std;
int main(int argc, char *argv[])
{ …Run Code Online (Sandbox Code Playgroud) 更新 Android Studio 后,我遇到了 Navigation-args 错误
构建失败的 API“BaseVariant.getApplicationIdTextResource”已过时,并已替换为“ApplicationVariant.applicationId”。它将在 Android Gradle 插件 9.0 版本中删除。有关详细信息,请参阅待定。要确定调用 BaseVariant.getApplicationIdTextResource 的内容,请在命令行上使用 -Pandroid.debug.obsoleteApi=true 来显示更多信息。:app:compileDebugKotlin SearchNsdFragmentDirections.kt 未解析的参考:R 未解析的参考:R org.gradle.api.GradleException:编译错误。查看日志了解更多详情
有什么想法吗?
我尝试恢复 gradle-wrapper 属性并恢复其他库...
尝试将一个新的 C++ 项目与 SFML 链接起来,我做了以下事情:
我从http://www.sfml-dev.org/tutorials/2.0/start-vc.php复制了示例 main() 。
当我尝试构建程序时,我收到 15 个 LNK2019 未解决的外部错误:
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::String(char const *,class std::locale const &)" (__imp_??0String@sf@@QAE@PBDABVlocale@std@@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::~String(void)" (__imp_??1String@sf@@QAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" …Run Code Online (Sandbox Code Playgroud)