• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            mooyee's blog

            C++博客 首頁 新隨筆 聯系 聚合 管理
              3 Posts :: 2 Stories :: 1 Comments :: 0 Trackbacks
            有網友問到,他在鏈接的時候,產生一堆錯誤

            我們還是先看他的代碼吧.
            ?1//?acetest2.cpp?:?Defines?the?entry?point?for?the?console?application.
            ?2//
            ?3
            ?4//?client.cpp
            ?5
            ?6#include?"ace/OS_main.h"
            ?7#include?"ace/OS_NS_string.h"
            ?8#include?"ace/OS_NS_sys_socket.h"
            ?9#include?"ace/OS_NS_unistd.h"
            10#include?"ace/OS_NS_stdlib.h"
            11#include?"ace/OS_NS_stdio.h"
            12#include?"ace/OS_NS_netdb.h"
            13#include?"ace/Default_Constants.h"
            14
            15ACE_RCSID(SOCK_SAP,?client,?"client.cpp,v?4.10?2005/01/21?02:19:20?ossama?Exp")
            16
            17/*?BSD?socket?client?*/
            18
            19int
            20ACE_TMAIN?(int?argc,?ACE_TCHAR?*argv[])
            21{
            22??//?Initialize?WinSock?DLL?on?Win32
            23??ACE_OS::socket_init?(ACE_WSOCK_VERSION);
            24
            25??struct?sockaddr_in?saddr;
            26??struct?hostent?*hp;
            27??const?ACE_TCHAR?*host?=?argc?>?1???argv[1]?:?ACE_DEFAULT_SERVER_HOST;
            28??u_short?port_num?=
            29????htons?(argc?>?2???ACE_OS::atoi?(argv[2])?:?ACE_DEFAULT_SERVER_PORT);
            30??int?sockbufsize?=?argc?>?3???ACE_OS::atoi?(argv[3])?:?0;
            31??char?buf[BUFSIZ];
            32??ACE_HANDLE?s_handle;
            33??int?w_bytes;
            34??int?r_bytes;
            35??int?n;
            36
            37??//?Create?a?local?endpoint?of?communication.
            38??if?((s_handle?=?ACE_OS::socket?(PF_INET,?SOCK_STREAM,?0))?==?ACE_INVALID_HANDLE)
            39????ACE_OS::perror?(ACE_TEXT("socket")),?ACE_OS::exit?(1);
            40
            41??//?If?a?sockbufsize?was?specified,?set?it?for?both?send?and?receive.
            42??if?(sockbufsize?>?0)
            43??{
            44????if?(ACE_OS::setsockopt?(s_handle,?SOL_SOCKET,?SO_SNDBUF,
            45??????(const?char?*)?&sockbufsize,
            46??????sizeof?(sockbufsize))?!=?0)
            47??????ACE_OS::perror?(ACE_TEXT("SO_SNDBUF")),?ACE_OS::exit?(1);
            48????if?(ACE_OS::setsockopt?(s_handle,?SOL_SOCKET,?SO_RCVBUF,
            49??????(const?char?*)?&sockbufsize,
            50??????sizeof?(sockbufsize))?!=?0)
            51??????ACE_OS::perror?(ACE_TEXT("SO_RCVBUF")),?ACE_OS::exit?(1);
            52??}

            53
            54??//?Determine?IP?address?of?the?server.
            55??if?((hp?=?ACE_OS::gethostbyname?(ACE_TEXT_ALWAYS_CHAR(host)))?==?0)
            56????ACE_OS::perror?(ACE_TEXT("gethostbyname")),?ACE_OS::exit?(1);
            57
            58??//?Set?up?the?address?information?to?contact?the?server.
            59??ACE_OS::memset?((void?*)?&saddr,?0,?sizeof?saddr);
            60??saddr.sin_family?=?AF_INET;
            61??saddr.sin_port?=?port_num;
            62??ACE_OS::memcpy?(&saddr.sin_addr,?hp->h_addr,?hp->h_length);
            63
            64??//?Establish?connection?with?remote?server.
            65??if?(ACE_OS::connect?(s_handle,
            66????reinterpret_cast<sockaddr?*>?(&saddr),
            67????sizeof?saddr)?==?-1)
            68????ACE_OS::perror?(ACE_TEXT("connect")),?ACE_OS::exit?(1);
            69
            70??//?Send?data?to?server?(correctly?handles?"incomplete?writes"?due?to
            71??//?flow?control).
            72
            73??while?((r_bytes?=?ACE_OS::read?(ACE_STDIN,?buf,?sizeof?buf))?>?0)
            74????for?(w_bytes?=?0;?w_bytes?<?r_bytes;?w_bytes?+=?n)
            75??????if?((n?=?ACE_OS::send?(s_handle,?buf?+?w_bytes,
            76????????r_bytes?-?w_bytes))?<?0)
            77????????ACE_OS::perror?(ACE_TEXT("write")),?ACE_OS::exit?(1);
            78
            79??if?(ACE_OS::recv?(s_handle,?buf,?1)?==?1)
            80????ACE_OS::write?(ACE_STDOUT,?buf,?1);
            81
            82??//?Explicitly?close?the?connection.
            83??if?(ACE_OS::closesocket?(s_handle)?==?-1)
            84????ACE_OS::perror?(ACE_TEXT("close")),?ACE_OS::exit?(1);
            85??return?0;
            86}

            87
            88
            89

            直接編譯,產生如下錯誤
            ------?Build?started:?Project:?acetest2,?Configuration:?Debug?Win32?------

            Compiling
            acetest2.cpp
            Linking
            acetest2.obj?:?error?LNK2019:?unresolved?external?symbol?
            "__declspec(dllimport)?int?__cdecl?ace_os_main_i(class?ACE_Main_Base?&,int,char?*?*?const)"?(__imp_?ace_os_main_i@@YAHAAVACE_Main_Base@@HQAPAD@Z)?referenced?in?function?_main
            acetest2.obj?:?error?LNK2019:?unresolved?external?symbol?
            "__declspec(dllimport)?public:?__thiscall?ACE_Main_Base::ACE_Main_Base(void)"?(__imp_??0ACE_Main_Base@@QAE@XZ)?referenced?in?function?"public:?__thiscall?ACE_Main::ACE_Main(void)"?(??0ACE_Main@@QAE@XZ)
            acetest2.obj?:?error?LNK2019:?unresolved?external?symbol?
            "__declspec(dllimport)?int?__cdecl?ACE_OS::closesocket(void?*)"?(__imp_?closesocket@ACE_OS@@YAHPAX@Z)?referenced?in?function?"int?__cdecl?ace_main_i(int,char?*?*?const)"?(?ace_main_i@@YAHHQAPAD@Z)
            acetest2.obj?:?error?LNK2019:?unresolved?external?symbol?
            "__declspec(dllimport)?int?__cdecl?ACE_OS::write(void?*,void?const?*,unsigned?int)"?(__imp_?write@ACE_OS@@YAHPAXPBXI@Z)?referenced?in?function?"int?__cdecl?ace_main_i(int,char?*?*?const)"?(?ace_main_i@@YAHHQAPAD@Z)
            acetest2.obj?:?error?LNK2019:?unresolved?external?symbol?
            "__declspec(dllimport)?int?__cdecl?ACE_OS::recv(void?*,char?*,unsigned?int,int)"?(__imp_?recv@ACE_OS@@YAHPAXPADIH@Z)?referenced?in?function?"int?__cdecl?ace_main_i(int,char?*?*?const)"?(?ace_main_i@@YAHHQAPAD@Z)
            acetest2.obj?:?error?LNK2019:?unresolved?external?symbol?
            "__declspec(dllimport)?int?__cdecl?ACE_OS::send(void?*,char?const?*,unsigned?int,int)"?(__imp_?send@ACE_OS@@YAHPAXPBDIH@Z)?referenced?in?function?"int?__cdecl?ace_main_i(int,char?*?*?const)"?(?ace_main_i@@YAHHQAPAD@Z)
            acetest2.obj?:?error?LNK2019:?unresolved?external?symbol?
            "__declspec(dllimport)?int?__cdecl?ACE_OS::read(void?*,void?*,unsigned?int)"?(__imp_?read@ACE_OS@@YAHPAX0I@Z)?referenced?in?function?"int?__cdecl?ace_main_i(int,char?*?*?const)"?(?ace_main_i@@YAHHQAPAD@Z)
            acetest2.obj?:?error?LNK2019:?unresolved?external?symbol?
            "__declspec(dllimport)?int?__cdecl?ACE_OS::connect(void?*,struct?sockaddr?*,int)"?(__imp_?connect@ACE_OS@@YAHPAXPAUsockaddr@@H@Z)?referenced?in?function?"int?__cdecl?ace_main_i(int,char?*?*?const)"?(?ace_main_i@@YAHHQAPAD@Z)
            acetest2.obj?:?error?LNK2019:?unresolved?external?symbol?
            "__declspec(dllimport)?void?*?__cdecl?ACE_OS::memcpy(void?*,void?const?*,unsigned?int)"?(__imp_?memcpy@ACE_OS@@YAPAXPAXPBXI@Z)?referenced?in?function?"int?__cdecl?ace_main_i(int,char?*?*?const)"?(?ace_main_i@@YAHHQAPAD@Z)
            acetest2.obj?:?error?LNK2019:?unresolved?external?symbol?
            "__declspec(dllimport)?void?*?__cdecl?ACE_OS::memset(void?*,int,unsigned?int)"?(__imp_?memset@ACE_OS@@YAPAXPAXHI@Z)?referenced?in?function?"int?__cdecl?ace_main_i(int,char?*?*?const)"?(?ace_main_i@@YAHHQAPAD@Z)
            acetest2.obj?:?error?LNK2019:?unresolved?external?symbol?
            "__declspec(dllimport)?struct?hostent?*?__cdecl?ACE_OS::gethostbyname(char?const?*)"?(__imp_?gethostbyname@ACE_OS@@YAPAUhostent@@PBD@Z)?referenced?in?function?"int?__cdecl?ace_main_i(int,char?*?*?const)"?(?ace_main_i@@YAHHQAPAD@Z)
            acetest2.obj?:?error?LNK2019:?unresolved?external?symbol?
            "__declspec(dllimport)?int?__cdecl?ACE_OS::setsockopt(void?*,int,int,char?const?*,int)"?(__imp_?setsockopt@ACE_OS@@YAHPAXHHPBDH@Z)?referenced?in?function?"int?__cdecl?ace_main_i(int,char?*?*?const)"?(?ace_main_i@@YAHHQAPAD@Z)
            acetest2.obj?:?error?LNK2019:?unresolved?external?symbol?
            "__declspec(dllimport)?void?__cdecl?ACE_OS::exit(int)"?(__imp_?exit@ACE_OS@@YAXH@Z)?referenced?in?function?"int?__cdecl?ace_main_i(int,char?*?*?const)"?(?ace_main_i@@YAHHQAPAD@Z)
            acetest2.obj?:?error?LNK2019:?unresolved?external?symbol?
            "__declspec(dllimport)?void?__cdecl?ACE_OS::perror(char?const?*)"?(__imp_?perror@ACE_OS@@YAXPBD@Z)?referenced?in?function?"int?__cdecl?ace_main_i(int,char?*?*?const)"?(?ace_main_i@@YAHHQAPAD@Z)
            acetest2.obj?:?error?LNK2019:?unresolved?external?symbol?
            "__declspec(dllimport)?void?*?__cdecl?ACE_OS::socket(int,int,int)"?(__imp_?socket@ACE_OS@@YAPAXHHH@Z)?referenced?in?function?"int?__cdecl?ace_main_i(int,char?*?*?const)"?(?ace_main_i@@YAHHQAPAD@Z)
            acetest2.obj?:?error?LNK2019:?unresolved?external?symbol?
            "__declspec(dllimport)?int?__cdecl?ACE_OS::atoi(char?const?*)"?(__imp_?atoi@ACE_OS@@YAHPBD@Z)?referenced?in?function?"int?__cdecl?ace_main_i(int,char?*?*?const)"?(?ace_main_i@@YAHHQAPAD@Z)
            acetest2.obj?:?error?LNK2019:?unresolved?external?symbol?
            "__declspec(dllimport)?int?__cdecl?ACE_OS::socket_init(int,int)"?(__imp_?socket_init@ACE_OS@@YAHHH@Z)?referenced?in?function?"int?__cdecl?ace_main_i(int,char?*?*?const)"?(?ace_main_i@@YAHHQAPAD@Z)
            Debug
            /acetest2.exe?:?fatal?error?LNK1120:?17?unresolved?externals

            解決方法,是正確的鏈接ace(x).lib
            其中, release版對應的是ace.lib,debug對應的是aced.lib
            同時,還要確保編輯器能正確找到ace(x).lib的位置.

            簡單的辦法是加入下面的代碼
            #ifdef?_DEBUG
            #pragma??comment?(lib,
            "aced.lib")
            #else
            #pragma??comment?(lib,
            "ace.lib")
            #endif


            ?

            posted on 2006-03-29 09:49 stone 閱讀(2770) 評論(0)  編輯 收藏 引用 所屬分類: 網絡編程, ACE
            国产精品成人久久久久三级午夜电影 | 久久精品国产免费观看| 中文字幕久久亚洲一区| 日韩人妻无码精品久久免费一| 久久综合九色综合欧美狠狠| 无码八A片人妻少妇久久| 91精品国产91久久久久久蜜臀 | 久久精品女人天堂AV麻| 久久久久久夜精品精品免费啦| 精品一久久香蕉国产线看播放| 色妞色综合久久夜夜| 久久99久久99小草精品免视看| 伊人久久大香线蕉综合Av | 99久久国产综合精品网成人影院 | 91亚洲国产成人久久精品网址| 久久亚洲精品国产亚洲老地址| 久久高清一级毛片| 久久水蜜桃亚洲av无码精品麻豆| 国产高潮久久免费观看| 久久天天躁狠狠躁夜夜网站 | 欧美一区二区三区久久综合| 久久综合久久性久99毛片| 精品无码久久久久久国产| 国产午夜免费高清久久影院| 国产综合久久久久久鬼色| 久久精品中文字幕一区| 91久久精品视频| 久久99精品国产| 蜜臀久久99精品久久久久久小说 | 日韩精品久久无码中文字幕| 亚洲欧美国产日韩综合久久| 国产91久久综合| 久久99精品国产| 伊人久久免费视频| 99热精品久久只有精品| 久久se精品一区二区| 久久夜色tv网站| 99久久精品国产毛片| 精品国产综合区久久久久久| 色噜噜狠狠先锋影音久久| 日本福利片国产午夜久久|