ACE應用程序鏈接錯誤? error LNK2019 的解決辦法
?
讀者水平:初級
摘要:文本簡要指出如何正確編譯和鏈接ACE應用程序。
對于新手來說,ACE開發(fā)環(huán)境,會是一團謎團,如何正確配置開發(fā)者機器,快速體驗ACE,
就是本系列文章的目的。本文僅解決如何解決LNK2019錯誤
環(huán)境:
??







下面的代碼是服務的主程序
//
@file:?RegisterServer.cpp?:
// @description:?Defines?the?entry?point?for?the?GameService?Daemon?application.
// @date:?2006-07-06
// @author:?Jiangtao<2005119@gmail.com>
#ifdef?_DEBUG
#define ???ACE_NDEBUG?0
#define ???ACE_NTRACE?0
#endif
#include? " stdafx.h "
#include? " ACE/Filecache.h "
#include? " ACE/Log_Msg.h "
#include? " ACE/OS_NS_signal.h "
#include? " ACE/Service_Config.h "
#ifdef?ACE_HAS_SIG_C_FUNC
#pragma?message?( " ACE_HAS_SIG_C_FUNC " )
extern ? " C "
{
#endif ?/*?ACE_HAS_SIG_C_FUNC?*/
? // ?call?exit()?so?that?static?destructors?get?called
? static ? void
??handler?( int )
?{
??delete?(ACE_Filecache? * )?ACE_Filecache::instance?();
??ACE_OS::exit?( 0 );
?}
#ifdef?ACE_HAS_SIG_C_FUNC
}
#endif ?/*?ACE_HAS_SIG_C_FUNC?*/
int ?ACE_TMAIN( int ?argc,?ACE_TCHAR * ?argv[])
{
?ACE_DEBUG((LM_INFO,ACE_TEXT( " 啟動服務\n " )));
?ACE_Service_Config?daemon;
?ACE_OS::signal?(SIGCHLD,?SIG_IGN);
? // ?SigAction?not?needed?since?the?handler?will?shutdown?the?server.
?ACE_OS::signal?(SIGINT,?(ACE_SignalHandler)?handler);
?ACE_OS::signal?(SIGUSR2,?(ACE_SignalHandler)?handler);
? if ?(daemon.open?(argc,?argv,?ACE_DEFAULT_LOGGER_KEY,? 0 )? != ? 0 )
??ACE_ERROR_RETURN?((LM_ERROR,? " %p\n " ,? " open " ),? 1 );
? // ?The?configured?service?creates?threads,?and?the
? // ?server?won't?exit?until?the?threads?die.
? // ?Run?forever,?performing?the?configured?services?until?we?receive
? // ?a?SIGINT.
? return ? 0 ;
}
// @description:?Defines?the?entry?point?for?the?GameService?Daemon?application.
// @date:?2006-07-06
// @author:?Jiangtao<2005119@gmail.com>
#ifdef?_DEBUG
#define ???ACE_NDEBUG?0
#define ???ACE_NTRACE?0
#endif
#include? " stdafx.h "
#include? " ACE/Filecache.h "
#include? " ACE/Log_Msg.h "
#include? " ACE/OS_NS_signal.h "
#include? " ACE/Service_Config.h "
#ifdef?ACE_HAS_SIG_C_FUNC
#pragma?message?( " ACE_HAS_SIG_C_FUNC " )
extern ? " C "
{
#endif ?/*?ACE_HAS_SIG_C_FUNC?*/
? // ?call?exit()?so?that?static?destructors?get?called
? static ? void
??handler?( int )
?{
??delete?(ACE_Filecache? * )?ACE_Filecache::instance?();
??ACE_OS::exit?( 0 );
?}
#ifdef?ACE_HAS_SIG_C_FUNC
}
#endif ?/*?ACE_HAS_SIG_C_FUNC?*/
int ?ACE_TMAIN( int ?argc,?ACE_TCHAR * ?argv[])
{
?ACE_DEBUG((LM_INFO,ACE_TEXT( " 啟動服務\n " )));
?ACE_Service_Config?daemon;
?ACE_OS::signal?(SIGCHLD,?SIG_IGN);
? // ?SigAction?not?needed?since?the?handler?will?shutdown?the?server.
?ACE_OS::signal?(SIGINT,?(ACE_SignalHandler)?handler);
?ACE_OS::signal?(SIGUSR2,?(ACE_SignalHandler)?handler);
? if ?(daemon.open?(argc,?argv,?ACE_DEFAULT_LOGGER_KEY,? 0 )? != ? 0 )
??ACE_ERROR_RETURN?((LM_ERROR,? " %p\n " ,? " open " ),? 1 );
? // ?The?configured?service?creates?threads,?and?the
? // ?server?won't?exit?until?the?threads?die.
? // ?Run?forever,?performing?the?configured?services?until?we?receive
? // ?a?SIGINT.
? return ? 0 ;
}
服務加載的配置文件
?







?
出錯提示:
?












?
問題分析
出錯信息顯示,不能解析函數(shù)ace_os_wmain_i()以及? ACE_Service_Config::open()。
從這里可以看出,鏈接器需要UNICODE版本的ace庫,而我們在生成ACE的時候,并沒有生成寬字符
的UNICODE版本。
解決辦法:
打開項目的屬性頁,找到配置屬性,在字符集中,選擇多字節(jié)字符集。再重新編譯,問題解決。
?
?