eclipse c++,通过CMD作品编译,在Eclipse中不可行

发布于 2025-01-25 20:31:46 字数 2184 浏览 3 评论 0原文

我使用Winsock库有一个TCP客户端程序(TCPCLIENT.CPP)。如果我将命令行与以下呼叫一起使用:

g++ TCPClient.cpp -o TCPClient.exe -lws2_32

当我尝试使用mingw中的eclipse/c ++链接相同的脚本时,成功生成了 *.exe,则我似乎会生成 *.o文件,但生成时会遇到错误*.exe。 因此,如果ecplise/c ++执行以下(链接器调用),则会生成错误:

g++ -o TCPClient.exe TCPClient.o -lws2_32 

我得到多个错误:

输入c:\ mingw \ bin \ ld.exe:矮人错误:找不到abbrev编号84。
./src/tcpclient.o:cygming-crtbegin.c :(.text +0x2a0):
的多重定义 _mingw32_init_mainargs
c:/mingw/bin /../ lib/gcc/mingw32/6.3.0 /../../../../ crt2.o :(。text+0x2a0):首先定义此处 C:\ mingw \ bin \ ld.exe:矮人错误:找不到Abbrev编号84。 ./src/tcpclient.o:cygming-crtbegin.c :(.text +0x2e0):
的多重定义 maincrtStartup'c:/mingw/bin /../ lib/gcc/mingw32/6.3.0 /../../../../../ crt2.o :(。text+0x2e0):首先在此处定义C: \ mingw \ bin \ ld.exe:矮人错误:找不到abbrev编号84 ../src/tcpclient.o:cygming-crtbegin.c :( .. text +0x300): winmaincrtstartup' c:/mingw/bin /../ lib/gcc/mingw32/6.3.0 /../../../../../ crt2.o :(。text+0x300):首先在此处定义 C:\ mingw \ bin \ ld.exe:矮人错误:找不到Abbrev编号84。 ./src/tcpclient.o:cygming-crtbegin.c :(.text +0x320):atexit'c:/mingw/bin /../ lib/gcc/gcc/gcc/mingw32/6.3.0/的多个定义。 ./../../../../crt2.o :(.Text+0x320):首先在此处定义c:\ mingw \ bin \ ld.exe:dwarf错误:找不到abbrev编号84 ./ src/src/tcpclient.o :cygming-crtbegin.c :(。text+0x330): _onexit的多重定义' c:/mingw/bin /../ lib/gcc/mingw32/6.3.0 /../../../../../ crt2.o :(。text+0x330):首先在此处定义 C:\ mingw \ bin \ ld.exe:矮人错误:找不到Abbrev编号84。 ./src/tcpclient.o:cygming-crtbegin.c :(.text +0x340):
的多重定义 '__gcc_register_frame' c:/mingw/bin /../ lib/gcc/mingw32/6.3.0/crtbegin.o:cygming-crtbegin.c :(。text+0x0):首先 在这里定义 c:\ mingw \ bin \ ld.exe:矮人错误:找不到abbrev编号84.here

c:\ mingw \ bin \ ld.exe:矮人错误 如果使用CMD线并首先生成.o文件,然后尝试生成一个 *.exe,则会遇到相同的错误。 CMD行中的以下两个调用导致上面的错误:

g++ TCPClient.o -o TCPClient.exe -lws2_32

g++ TCPClient.o -o TCPClient.exe 

这意味着:如果在CMD行中,我只指定我要生成(A *.exe从我的 *.cpp中),一切正常。但是 - 作为用户 - 单独执行这两个步骤不起作用。

CMD线G ++调用似乎“知道”在这里该怎么做。作为用户,直接生成 *.exe时,我从未看到 *.o文件。但是我认为必须生成吗?我错了吗?为什么没有进一步规格的CMD线知道如何处理.o文件? ...是否可以从任何来源中找出对“ G ++”的调用,当通过命令行调用时会有什么?当然,我希望将相同的设置集成到Eclipse/C ++中。

I have a TCP Client program (TCPClient.cpp) using winsock library. An *.exe is generated successfully if I use command line with the following call:

g++ TCPClient.cpp -o TCPClient.exe -lws2_32

When I try to compile and link the same script within Eclipse/C++ using MinGW I seem to get the *.o file generated but I get an error when generating the *.exe.
Thus, the error is generated if Ecplise/C++ does the following (linker call):

g++ -o TCPClient.exe TCPClient.o -lws2_32 

I get multiple errors:

enter C:\MinGW\bin\ld.exe: Dwarf Error: Could not find abbrev number 84.
./src/TCPClient.o:cygming-crtbegin.c:(.text+0x2a0): multiple definition of
_mingw32_init_mainargs
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.text+0x2a0): first defined here
C:\MinGW\bin\ld.exe: Dwarf Error: Could not find abbrev number 84.
./src/TCPClient.o:cygming-crtbegin.c:(.text+0x2e0): multiple definition of
mainCRTStartup' c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.text+0x2e0): first defined here C:\MinGW\bin\ld.exe: Dwarf Error: Could not find abbrev number 84. ./src/TCPClient.o:cygming-crtbegin.c:(.text+0x300): multiple definition ofWinMainCRTStartup'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.text+0x300): first defined here
C:\MinGW\bin\ld.exe: Dwarf Error: Could not find abbrev number 84.
./src/TCPClient.o:cygming-crtbegin.c:(.text+0x320): multiple definition of atexit' c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.text+0x320): first defined here C:\MinGW\bin\ld.exe: Dwarf Error: Could not find abbrev number 84. ./src/TCPClient.o:cygming-crtbegin.c:(.text+0x330): multiple definition of_onexit'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.text+0x330): first defined here
C:\MinGW\bin\ld.exe: Dwarf Error: Could not find abbrev number 84.
./src/TCPClient.o:cygming-crtbegin.c:(.text+0x340): multiple definition of
`__gcc_register_frame'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/crtbegin.o:cygming-crtbegin.c:(.text+0x0): first
defined here
C:\MinGW\bin\ld.exe: Dwarf Error: Could not find abbrev number 84.here

The following is interesting:
I get the same errors if I use the cmd-line and first generate a .o file and then try to generate a *.exe. Both of the following calls in cmd-line result in the error from above:

g++ TCPClient.o -o TCPClient.exe -lws2_32

g++ TCPClient.o -o TCPClient.exe 

This means: If in cmd-line I only specify that I want to generate (a *.exe from my *.cpp) everything works fine. But - as a user - doing those two steps separately does not work.

Cmd-Line g++ call seems to "know" what to do here. As a user I never see the *.o file when directly generating a *.exe. But I think it must be generated anyway? Am I wrong? Why does cmd-line without further specification know how to deal with the .o file? ... Is it possible to find out from any source what a call to "g++" does when called via command line? Of course I want the same settings integrated in eclipse/c++.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

∞梦里开花 2025-02-01 20:31:46

g ++ tcpclient.cpp -o tcpclient.exe -lws2_32

如果您执行-O(大写字母,而不是零),则可以获得该错误,而不是-o对于EXE文件。

g++ TCPClient.cpp -o TCPClient.exe -lws2_32

You can get that error if you do -O (capital letter, not zero) instead of -o for the exe file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文