how to link libws2_32.a?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kiberg
    New Member
    • Jul 2007
    • 12

    how to link libws2_32.a?

    Hi,

    I have a problem to compile my socket program.
    I want to use winsock.h.
    I need link libws2_32.a (for dev-c++) .
    I found a libws2_32.a file and link it, but i have a next error:
    ....
    gcc: c:\documents and settings\ervin\ asztal\programm ing tcp sockets for the beginner\source code\dev-c++\chat1.rc: linker input file unused since linking not done
    gcc: libws2_32.a: linker input file unused since linking not done
    ....


    What can I do ?
    Please let me know.

    Thanks,

    Takeshi Honda
  • ruskalym
    New Member
    • Sep 2007
    • 65

    #2
    Originally posted by kiberg
    gcc: c:\documents and settings\ervin\ asztal\programm ing tcp sockets for the beginner\source code\dev-c++\chat1.rc: linker input file unused since linking not done
    gcc: libws2_32.a: linker input file unused since linking not done
    ....
    Hi, the message you get is a GCC warning.
    Linking is done at the linking step, this message usually appears when you specify linking flags at compiling : gcc -c johndoe.c -o johndoe.o -Lpath/to/mylibrary -lmylibrary.
    These -L and -l flags have no sense there, they should be used when building the target binary : gcc johndoe.o otherfile.o -o mybinary -L... -l...
    or passed to ld if you call it manually.

    Comment

    • kiberg
      New Member
      • Jul 2007
      • 12

      #3
      Thanks,
      I linking folowing files:
      libws2_32.a Chat1.cpp Chat1.rc Chat1.h

      but is a new error:

      gcc: Compilation of header file requested

      This error show when I linking chat1.h..But if I don't linking it then showing following errors:

      gcc: libws2_32.a: linker input file unused since linking not done
      gcc: Chat1.rc: linker input file unused since linking not done


      Please help me!

      Comment

      • ruskalym
        New Member
        • Sep 2007
        • 65

        #4
        Please tell me the full command you're using when running GCC.

        Comment

        • kiberg
          New Member
          • Jul 2007
          • 12

          #5
          I only wrote file names...
          So, dev c++ -> options -> copiler options -> Add the following comands when calling copiler, and I write following:
          libws2_32.a Chat1.cpp Chat1.rc Chat1.h

          I dont write commands....
          I probaly following:
          gcc -a libws2_32.a -cpp Chat1.cpp -rc Chat1.rc -h Chat1.h

          But I get following errors:
          gcc: gcc: No such file or directory
          gcc: unrecognized option `-cpp'
          gcc: unrecognized option `-rc'
          gcc: unrecognized option `-h'
          gcc: Compilation of header file requested

          I dont understand it.:S

          Comment

          • kiberg
            New Member
            • Jul 2007
            • 12

            #6
            and if I write following:
            gcc -c libws2_32.a -c Chat1.cpp -c Chat1.rc -c Chat1.h

            Then retry only is a error:
            gcc: Compilation of header file requested...... .....

            Comment

            • ruskalym
              New Member
              • Sep 2007
              • 65

              #7
              Try this :

              gcc Chat1.cpp Chat1.rc -o Chat1.exe -L/path/to/library/if/not/in/same/directory -lws2_32

              Comment

              • ruskalym
                New Member
                • Sep 2007
                • 65

                #8
                If this doesn't work, try adding option -mwindows

                Comment

                • kiberg
                  New Member
                  • Jul 2007
                  • 12

                  #9
                  Copiler and linker output:

                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccUfdaaa.o: In function `WinMain':
                  //C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:29: multiple definition of `WinMain@16'
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:29: first defined here
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccUfdaaa.o: In function `GetTextandAddL ine(char *, HWND__ *, int)':
                  //C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:38: multiple definition of `GetTextandAddL ine(char *, HWND__ *, int)'
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:38: first defined here
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccUfdaaa.o: In function `DlgProc(HWND__ *, unsigned int, unsigned int, long)':
                  //C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:48: multiple definition of `DlgProc__FP6HW ND__UiUil@16'
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:48: first defined here
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccUfdaaa.o: In function `ConnectDlgProc (HWND__ *, unsigned int, unsigned int, long)':
                  //C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:190: multiple definition of `ConnectDlgProc __FP6HWND__UiUi l@16'
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:190: first defined here
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccUfdaaa.o: In function `ListenDlgProc( HWND__ *, unsigned int, unsigned int, long)':
                  //C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:249: multiple definition of `ListenDlgProc_ _FP6HWND__UiUil @16'
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:249: first defined here
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccUfdaaa.o: In function `ListenOnPort(i nt)':
                  //C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:329: multiple definition of `ListenOnPort(i nt)'
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:329: first defined here
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccUfdaaa.o: In function `TryConnect(lon g, int)':
                  //C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:289: multiple definition of `TryConnect(lon g, int)'
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:289: first defined here
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccUfdaaa.o: In function `WinMain':
                  //C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:29: multiple definition of `Title'
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:29: first defined here
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccUfdaaa.o: In function `WinMain':
                  //C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:30: multiple definition of `hInst'
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:30: first defined here
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccUfdaaa.o: In function `WinMain':
                  //C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:33: multiple definition of `fromlen'
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:33: first defined here
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccUfdaaa.o: In function `WinMain':
                  //C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:29: multiple definition of `hwnd'
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:29: first defined here
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccUfdaaa.o: In function `WinMain':
                  //C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:29: multiple definition of `hStatus'
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:29: first defined here
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccUfdaaa.o: In function `WinMain':
                  //C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:30: multiple definition of `s'
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:30: first defined here
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccUfdaaa.o: In function `WinMain':
                  //C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:30: multiple definition of `from'
                  C:\DOCUME~1\erv in\LOCALS~1\Tem p\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:30: first defined here

                  Why don't work?

                  Comment

                  • lksiow
                    New Member
                    • Jun 2009
                    • 1

                    #10
                    Originally posted by kiberg
                    Hi,

                    I have a problem to compile my socket program.
                    I want to use winsock.h.
                    I need link libws2_32.a (for dev-c++) .
                    I found a libws2_32.a file and link it, but i have a next error:
                    ....
                    gcc: c:\documents and settings\ervin\ asztal\programm ing tcp sockets for the beginner\source code\dev-c++\chat1.rc: linker input file unused since linking not done
                    gcc: libws2_32.a: linker input file unused since linking not done
                    ....


                    What can I do ?
                    Please let me know.

                    Thanks,

                    Takeshi Honda





                    Hi Takeshi Honda,

                    I am a beginner in programming. Can u kindly instruct me on how to link libws2_32.a to the project?

                    Thank you in advance.

                    Cheers
                    Siow

                    Comment

                    • donbock
                      Recognized Expert Top Contributor
                      • Mar 2008
                      • 2427

                      #11
                      Originally posted by kiberg
                      and if I write following:
                      gcc -c libws2_32.a -c Chat1.cpp -c Chat1.rc -c Chat1.h

                      Then retry only is a error:
                      gcc: Compilation of header file requested...... .....
                      The -c switch means compile or assemble the following file, but do not link. You definitely don't want to compile libsw2_32.a or Chat1.h. Personally, I typically use the -c switch when I'm using individual gcc invocations to compile each source file. You don't need it when you specify all of the source files on a single line.

                      I'm not familiar with the .rc suffix, what kind of file is Chat1.rc?

                      Comment

                      • newb16
                        Contributor
                        • Jul 2008
                        • 687

                        #12
                        That message is 2 years old btw.

                        Comment

                        Working...