简体   繁体   English

出于愚蠢的原因,无法在OS X的Eclipse CDT中构建c ++项目

[英]Having trouble building c++ project in Eclipse CDT in OS X for a silly reason

I'm trying to build a very simple c++ program in eclipse and I'm getting a very silly error: 我正在尝试在Eclipse中构建一个非常简单的c ++程序,但出现了一个非常愚蠢的错误:


**** Internal Builder is used for build               ****
g++ -O0 -g3 -Wall -c -fmessage-length=0 -oMyFirst.o ../MyFirst.cpp
g++ -oLinkedLists MyFirst.o
ld: unknown option: -oLinkedLists
collect2: ld returned 1 exit status
Build error occurred, build is stopped

Time consumed: 403 ms. 消耗时间:403毫秒。


The problem is that g++ in osx does not like the -o flag in the "g++ -oLinkedLists MyFirst.o" command right next to the executable file name... Does anybody know how to either configure g++ to accept that or how to configure the builder in eclipse such that there's a space between the -o flag and and file name like this: "g++ -o LinkedLists MyFirst.o"? 问题是osx中的g ++不喜欢可执行文件名旁边的“ g ++ -oLinkedLists MyFirst.o”命令中的-o标志...是否有人知道如何配置g ++来接受它或如何配置eclipse中的生成器,使得-o标志和文件名之间有一个空格,例如:“ g ++ -o LinkedLists MyFirst.o”?

Thx in advance! 提前谢谢!

To further clarify this issue, the solution isn't necessarily to use the MacOSX gcc toolchain. 为了进一步阐明此问题,解决方案不一定要使用MacOSX gcc工具链。 The problem is with the command line pattern for the linker in the toolchain. 问题出在工具链中链接程序的命令行模式上。 All you need to do to fix the problem is to edit the command line pattern to ensure there are spaces between each term. 解决此问题所需要做的就是编辑命令行模式,以确保每个术语之间都有空格。

By default, the command line pattern for the Linux gcc linker is something like: ${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT}${INPUTS} 默认情况下,Linux gcc链接器的命令行模式类似于:$ {COMMAND} $ {FLAGS} $ {OUTPUT_FLAG} $ {OUTPUT_PREFIX} $ {OUTPUT} $ {INPUTS}

Note the lack of spaces between ${OUTPUT_PREFIX} and ${OUTPUT}. 请注意,$ {OUTPUT_PREFIX}和$ {OUTPUT}之间没有空格。 This is the crux of the problem. 这是问题的症结所在。 Simply add a space between those two terms, and your problem is solved. 只需在这两个术语之间添加一个空格,即可解决您的问题。

Mark actually pointed me in the right direction but what I had to do to make it work was to go to: Project >> Properties >> C/C++ Build >> Tool Chain Editor 马克实际上向我指出了正确的方向,但是要使其正常运行,我要做的是转到:项目>>属性>> C / C ++构建>>工具链编辑器

I then changed the "Current toolchanin" select box to "MacOSX gcc" and that fixed it :) 然后,我将“当前工具通道”选择框更改为“ MacOSX gcc”,并进行了修复:)

I use eclipse CDT 3.5 on OSX 10.5 and it works - 我在OSX 10.5上使用Eclipse CDT 3.5,它可以正常工作-

**** Internal Builder is used for build               ****
g++ -I/opt/local/include -O0 -g3 -Wall -c -fmessage-length=0 -osrc/tet.o ../src/tet.cpp
g++ -o tet src/tet.o
Build complete for project tet

I get a space in the link line for my executable tet 我在链接行中为可执行Tet留了一个空格

I am using the default settings 我正在使用默认设置

In settings->C/C++ Build->Settings->Mac OSX C++ linker the comand line pattern is 在settings-> C / C ++ Build-> Settings-> Mac OSX C ++链接器中,命令行模式为

${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} $ {COMMAND} $ {FLAGS} $ {OUTPUT_FLAG} $ {OUTPUT_PREFIX} $ {OUTPUT} $ {INPUTS}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM