【发布时间】:2013-10-15 09:58:21
【问题描述】:
我有两个.exes。他们需要在运行时使用彼此的功能。一种是基于对话的应用程序.exe,另一种是主应用程序.exe。现在主应用程序需要使用基于对话框的应用程序功能。但是在编译时,它可以 bot 定位 called function 的存在,因为 dialog based applications .lib 不可用。因为如果我向.lib 创建基于对话框的应用程序,那么程序将在运行时失败。所以,我需要拨打一个.exe 到另一个.exe。
当我尝试打电话时,
TestClass tc;/* Call dialog based application exe functions*/
tc.MyTest();
它会抛出类似的错误
1>CallExe.obj : error LNK2001: unresolved external symbol "public: __thiscall TestClass::~TestClass(void)" (??1TestClass@@QAE@XZ)
1>CallExe.obj : error LNK2001: unresolved external symbol "public: void __thiscall TestClass::MyTest(void)" (?MyTest@TestClass@@QAEXXZ)
1>CallExe.obj : error LNK2001: unresolved external symbol "public: __thiscall TestClass::TestClass(void)" (??0TestClass@@QAE@XZ)
Main application.cpp
int _tmain(int argc, _TCHAR* argv[])
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
TestClass tc;/* Call dialog based application exe functions*/
tc.MyTest();
// set the size of the structures
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
LPCTSTR szCmdline = (LPCTSTR)(TEXT("Dialog.exe"));
// start the program up
if(!CreateProcess(TEXT("D:\\Rasmi's\\Personal\\Visual Studio\\Dialog\\Debug\\Dialog.exe"), // the path
argv[1], // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi ) // Pointer to PROCESS_INFORMATION structure
)
{cout << "Unable to create\n";}
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
return 0;
}
在Dialog.exe
TestClass::TestClass(void)
{
}
TestClass::~TestClass(void)
{
}
void TestClass::MyTest()
{
cout << "This is my Test Class \n";
}
【问题讨论】:
-
为什么不将两个应用程序中使用的对话框放在您从两个 exe 引用的单独库中?
-
这不起作用,需要 DLL。如果您不解决核心问题,这也可能会“在运行时失败”。
标签: c++ visual-studio-2010 mfc dialog linker