views:

617

answers:

3

I'm trying to build a very simple c++ program in eclipse and I'm getting a very silly error:


**** 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.


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"?

Thx in advance!

A: 

I use eclipse CDT 3.5 on OSX 10.5 and it works -

**** 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

I am using the default settings

In settings->C/C++ Build->Settings->Mac OSX C++ linker the comand line pattern is

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

Mark
Thx for your help!
hdx
A: 

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

I then changed the "Current toolchanin" select box to "MacOSX gcc" and that fixed it :)

hdx
A: 

To further clarify this issue, the solution isn't necessarily to use the MacOSX gcc toolchain. 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}

Note the lack of spaces between ${OUTPUT_PREFIX} and ${OUTPUT}. This is the crux of the problem. Simply add a space between those two terms, and your problem is solved.

agodbehere
Where is this pattern?
hdx