Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 15
  1. #1
    Utente di HTML.it L'avatar di unit1
    Registrato dal
    Feb 2004
    Messaggi
    354

    MinGWStudio includere librerire

    Per programmare in c[winsock] devo linkare una libreria libwinsock32.a il problama e che non so come fare.

    il uso MinGWStudio per compliare i sorgenti c, ho aggiunto il percorso della caretella bin alla variabile path e uso il comando gcc -o file.exe file.c

  2. #2
    Credo che tu debba prima compilare (con l'opzione -c mi sembra) il tuo programma e poi linkarlo a quest'altra libreria.
    Folle e' l'uomo che parla alla luna.
    Stolto chi non le presta ascolto.

  3. #3
    Utente di HTML.it L'avatar di unit1
    Registrato dal
    Feb 2004
    Messaggi
    354
    con l'opzione -o crea un file con estensione .o, ora?
    ti faccio leggere l'help:
    codice:
    Usage: gcc [options] file...
    Options:
      -pass-exit-codes         Exit with highest error code from a phase
      --help                   Display this information
      --target-help            Display target specific command line options
      (Use '-v --help' to display command line options of sub-processes)
      -dumpspecs               Display all of the built in spec strings
      -dumpversion             Display the version of the compiler
      -dumpmachine             Display the compiler's target processor
      -print-search-dirs       Display the directories in the compiler's search path
    
      -print-libgcc-file-name  Display the name of the compiler's companion library
      -print-file-name=<lib>   Display the full path to library <lib>
      -print-prog-name=<prog>  Display the full path to compiler component <prog>
      -print-multi-directory   Display the root directory for versions of libgcc
      -print-multi-lib         Display the mapping between command line options and
                               multiple library search directories
      -print-multi-os-directory Display the relative path to OS libraries
      -Wa,<options>            Pass comma-separated <options> on to the assembler
      -Wp,<options>            Pass comma-separated <options> on to the preprocessor
    
      -Wl,<options>            Pass comma-separated <options> on to the linker
      -Xlinker <arg>           Pass <arg> on to the linker
      -save-temps              Do not delete intermediate files
      -pipe                    Use pipes rather than intermediate files
      -time                    Time the execution of each subprocess
      -specs=<file>            Override built-in specs with the contents of <file>
      -std=<standard>          Assume that the input sources are for <standard>
      -B <directory>           Add <directory> to the compiler's search paths
      -b <machine>             Run gcc for target <machine>, if installed
      -V <version>             Run gcc version number <version>, if installed
      -v                       Display the programs invoked by the compiler
      -###                     Like -v but options quoted and commands not executed
      -E                       Preprocess only; do not compile, assemble or link
      -S                       Compile only; do not assemble or link
      -c                       Compile and assemble, but do not link
      -o <file>                Place the output into <file>
      -x <language>            Specify the language of the following input files
                               Permissible languages include: c c++ assembler none
                               'none' means revert to the default behavior of
                               guessing the language based on the file's extension
    
    Options starting with -g, -f, -m, -O, -W, or --param are automatically
     passed on to the various sub-processes invoked by gcc.  In order to pass
     other options on to these processes the -W<letter> options must be used.
    
    For bug reporting instructions, please see:
    <URL:http://www.mingw.org/bugs.shtml>.
    grazie per avermi risposto.

  4. #4
    Mi sa che l'help e' incompleto.
    Cmq bastava farti un giro su Google.
    Prova:

    gcc -o file.exe -llibwinsock32.a file.o
    Folle e' l'uomo che parla alla luna.
    Stolto chi non le presta ascolto.

  5. #5
    Utente di HTML.it L'avatar di unit1
    Registrato dal
    Feb 2004
    Messaggi
    354
    il file si chiama serve.cpp
    >gcc -c serve.cpp
    >gcc -o serve.exe -libwsock32.a serve.o

    C:\MinGWStudio\MinGW\bin\..\lib\gcc-lib\mingw32\3.3.1\..\..\..\..\mingw32\bin\ld
    .exe: cannot find -libwsock32.a


    e pure il nome della libraria quello, esiste la libreria: C:\MinGWStudio\MinGW\lib\libwsock32.a

  6. #6
    gcc -o serve.exe -libwsock32.a serve.o
    Con due elle:

    gcc -o serve.exe -llibwsock32.a serve.o
    Folle e' l'uomo che parla alla luna.
    Stolto chi non le presta ascolto.

  7. #7
    Utente di HTML.it L'avatar di MMarzia
    Registrato dal
    Mar 2001
    Messaggi
    1,781
    linguaggio nel titolo..
    io sono festosamente cicciottello :: e. cartman

    t'amo senza sapere come, nč quando nč da dove,
    t'amo direttamente senza problemi nč orgoglio:
    cosė ti amo perchč non so amare altrimenti

  8. #8
    Utente di HTML.it L'avatar di unit1
    Registrato dal
    Feb 2004
    Messaggi
    354
    codice:
    >gcc -o serve.exe -llibwsock32.a serve.o
    C:\MinGWStudio\MinGW\bin\..\lib\gcc-lib\mingw32\3.3.1\..\..\..\..\mingw32\bin\ld
    .exe: cannot find -llibwsock32.a
    non funziona ancora :master:


    porebbe essere che essendo gcc un programma originariamente creato per linux veda le librerie di linux? dove posso trovare un esempio?

  9. #9
    Originariamente inviato da unit1
    non funziona ancora :master:


    porebbe essere che essendo gcc un programma originariamente creato per linux veda le librerie di linux? dove posso trovare un esempio?
    prova prima cosė

    gcc -o serve.exe serve.o -lwsock32

    il "lib" va tolto perchč lo aggiunge automaticamente
    edit:
    dimenticavo che va tolto anche il ".a"

    se non va

    gcc -o serve.exe serve.o -lwsock32 -L/MinGWStudio/MinGW/lib

    se non fuziona

    gcc -o serve.exe serve.o /MinGWStudio/MinGW/lib/libwsock32.a


    dovrebbero funzionare tutti e tre i modi

  10. #10
    Ma sta cosa:

    C:\MinGWStudio\MinGW\bin\..\lib\gcc-lib\mingw32\3.3.1\..\..\..\..\mingw32\bin\ld
    .exe

    e' normale?
    Folle e' l'uomo che parla alla luna.
    Stolto chi non le presta ascolto.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.