error LNK2001: Nichtaufgelöstes externes Symbol; Please Help!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Falk Fassmann

    error LNK2001: Nichtaufgelöstes externes Symbol; Please Help!

    Hello people,

    I have some problem with Debugging in MS Visual C++.
    I want to generate a TCP/IP-Socket. The compiling-process is fine but
    when I debugg the project there's occuring some errors like: 'error
    LNK2001: Nichtaufgelöste s externes Symbol "unsigned int __stdcall
    socket(int,int, int)" (?socket@@$$FYG IHHH@Z)"'

    "Nichtaufgelöst es externes Symbol" means "unresolved external symbol"

    Here is a smaller C++-file which creates the same error.

    #define AF_INET 2 /* internetwork: TCP, etc. */
    #define SOCK_STREAM 1 /* stream socket */

    void main(){
    unsigned int __stdcall socket(int af, int type, int protocol);
    unsigned int iClient;
    iClient = socket(AF_INET, SOCK_STREAM, 0);
    }

    I think there's some problem with the symbol "__stdcall" , that Visual
    C++ has a problem with C++- and C-code.

    I have also tried
    '"extern "C" { unsigned int __stdcall socket(int af, int type, int
    protocol);
    }'
    but the same message occured.

    Who can help?

    Falk Fassmann
  • Kevin Goodsell

    #2
    Re: error LNK2001: Nichtaufgelöste s externes Symbol; Please Help!

    Falk Fassmann wrote:[color=blue]
    > Hello people,
    >
    > I have some problem with Debugging in MS Visual C++.
    > I want to generate a TCP/IP-Socket. The compiling-process is fine but
    > when I debugg the project there's occuring some errors like: 'error
    > LNK2001: Nichtaufgelöste s externes Symbol "unsigned int __stdcall
    > socket(int,int, int)" (?socket@@$$FYG IHHH@Z)"'
    >
    > "Nichtaufgelöst es externes Symbol" means "unresolved external symbol"
    >
    > Here is a smaller C++-file which creates the same error.
    >
    > #define AF_INET 2 /* internetwork: TCP, etc. */
    > #define SOCK_STREAM 1 /* stream socket */
    >
    > void main(){[/color]

    In C++ main returns int.
    [color=blue]
    > unsigned int __stdcall socket(int af, int type, int protocol);[/color]

    __stdcall is not standard C++. Please leave non-standard things out when
    posting here. If the non-standard thing is the problem, then this is the
    wrong place to ask.
    [color=blue]
    > unsigned int iClient;
    > iClient = socket(AF_INET, SOCK_STREAM, 0);[/color]

    Well, I see no definition for the socket() function, so the linker error
    is not particularly surprising. You can't use a function if it doesn't
    have a definition. Supply a definition and the problem should go away.
    [color=blue]
    > }
    >
    > I think there's some problem with the symbol "__stdcall" , that Visual
    > C++ has a problem with C++- and C-code.[/color]

    If that's the case then you should ask in a Visual C++ group.

    -Kevin
    --
    My email address is valid, but changes periodically.
    To contact me please use the address from a recent posting.

    Comment

    • Falk Fassmann

      #3
      Re: error LNK2001: Nichtaufgelöste s externes Symbol; Please Help!

      Thanks for your message, but this isn't solving my problems.

      When I leave "__stdcall" out, it occures an other error:
      error LNK2001: Nichtaufgelöste s externes Symbol "unsigned int __cdecl
      socket(int,int, int)" (?socket@@$$FYA IHHH@Z)

      The definition of:
      "unsigned int iClient;
      iClient = socket(AF_INET, SOCK_STREAM, 0);"

      was: "unsigned int __stdcall socket(int af, int type, int protocol);"

      now: "unsigned int socket(int af, int type, int protocol);"

      It's the declaration of the function "socket" from winsock.h.


      Falk



      Kevin Goodsell <usenet1.spamfr ee.fusion@never box.com> wrote in message news:<6EX5b.78$ Yt.56@newsread4 .news.pas.earth link.net>...[color=blue]
      > Falk Fassmann wrote:[color=green]
      > > Hello people,
      > >
      > > I have some problem with Debugging in MS Visual C++.
      > > I want to generate a TCP/IP-Socket. The compiling-process is fine but
      > > when I debugg the project there's occuring some errors like: 'error
      > > LNK2001: Nichtaufgelöste s externes Symbol "unsigned int __stdcall
      > > socket(int,int, int)" (?socket@@$$FYG IHHH@Z)"'
      > >
      > > "Nichtaufgelöst es externes Symbol" means "unresolved external symbol"
      > >
      > > Here is a smaller C++-file which creates the same error.
      > >
      > > #define AF_INET 2 /* internetwork: TCP, etc. */
      > > #define SOCK_STREAM 1 /* stream socket */
      > >
      > > void main(){[/color]
      >
      > In C++ main returns int.
      >[color=green]
      > > unsigned int __stdcall socket(int af, int type, int protocol);[/color]
      >
      > __stdcall is not standard C++. Please leave non-standard things out when
      > posting here. If the non-standard thing is the problem, then this is the
      > wrong place to ask.
      >[color=green]
      > > unsigned int iClient;
      > > iClient = socket(AF_INET, SOCK_STREAM, 0);[/color]
      >
      > Well, I see no definition for the socket() function, so the linker error
      > is not particularly surprising. You can't use a function if it doesn't
      > have a definition. Supply a definition and the problem should go away.
      >[color=green]
      > > }
      > >
      > > I think there's some problem with the symbol "__stdcall" , that Visual
      > > C++ has a problem with C++- and C-code.[/color]
      >
      > If that's the case then you should ask in a Visual C++ group.
      >
      > -Kevin[/color]

      Comment

      • Kevin Goodsell

        #4
        Re: error LNK2001: Nichtaufgelöste s externes Symbol; Please Help!

        Falk Fassmann wrote:
        [color=blue]
        > Thanks for your message, but this isn't solving my problems.[/color]

        Please don't top-post. Re-read section 5 of the FAQ for posting guidelines.


        [color=blue]
        >
        > When I leave "__stdcall" out, it occures an other error:
        > error LNK2001: Nichtaufgelöste s externes Symbol "unsigned int __cdecl
        > socket(int,int, int)" (?socket@@$$FYA IHHH@Z)
        >
        > The definition of:
        > "unsigned int iClient;
        > iClient = socket(AF_INET, SOCK_STREAM, 0);"
        >
        > was: "unsigned int __stdcall socket(int af, int type, int protocol);"
        >
        > now: "unsigned int socket(int af, int type, int protocol);"[/color]

        This is not a definition. I still think the problem is that there is no
        definition for socket(). Where you get that definition and how you
        supply it to the linker are not covered by the topic of this group. It
        probably is covered in the documentation for the winsock library and
        your compiler.
        [color=blue]
        >
        > It's the declaration of the function "socket" from winsock.h.[/color]

        That is not a standard C++ header.

        You might consider taking this to a group that discusses WinSock.

        -Kevin
        --
        My email address is valid, but changes periodically.
        To contact me please use the address from a recent posting.

        Comment

        Working...