如何通过g ++链接wsock32库? [英] How to link wsock32 library through g++?
问题描述
我在windows上使用minGW,试图编译一个c ++程序。我在那里使用套接字,所以我试图链接(不包括...我已经包括winsock.h)的wsock32库。我知道-L开关是用于连接的,但以下命令都不起作用:
g ++ C:\program.cpp -Lwsock32.lib
g ++ C:\program.cpp -LC:\windows\system32\wsock32.dll
g ++ C:\program.cpp -lC:\ windows \ system32 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
我应该怎么做?
解决方案 L 选项用于设置链接器应该查找库/ dll的目录。
-l <
$ b 这意味着
<$ p
g ++ C:\ Program Files.cpp -LC:\Windows\System32 -lwsock32
应该是从常规Windows命令提示符编译程序的命令。
我怀疑你的编译器可能会自动查找system32,所以你可能只想跳过 -L
选项。
I'm using minGW on windows, trying to compile a c++ program. I've used sockets in there, so I'm trying to link (not include... I've already included winsock.h) the wsock32 library. I know that the -L switch is for linking but none of the following commands work:
g++ C:\program.cpp -Lwsock32.lib
g++ C:\program.cpp -LC:\windows\system32\wsock32.dll
g++ C:\program.cpp -lC:\windows\system32\wsock32.dll
g++ C:\program.cpp -LC:\windows\system32\wsock32.lib
what should I do??
解决方案 The -L
option is for setting the directory where the linker should look for libraries/dlls.
The -l
option is for naming the libraries/dlls you want to link with.
That would mean
g++ C:\Program.cpp -LC:\Windows\System32 -lwsock32
should be the command to compile your program from your regular windows command prompt.
I suspect your compiler may look in system32 automatically, so you may want to just try to skip the -L
option.
这篇关于如何通过g ++链接wsock32库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文