Exporting makefile from Eclipse CDT

Posted by Alex Farber on Stack Overflow See other posts from Stack Overflow or by Alex Farber
Published on 2010-03-24T13:08:56Z Indexed on 2010/03/24 13:13 UTC
Read the original article Hit count: 855

Filed under:
|
|

I have C++ project in the Ubuntu OS, Eclipse CDT. My final goal is to build the project binaries for FreeBSD OS. The first test. I create simple C++ CDT project with main.cpp file: cout << "OK" << endl; and build it. Then I open Terminal window in Release directory:

[email protected]:~/workspace/HelloWorld/Release$ ls
HelloWorld  main.d  main.o  makefile  objects.mk  sources.mk  subdir.mk
[email protected]:~/workspace/HelloWorld/Release$ rm HelloWorld  main.d  main.o
[email protected]:~/workspace/HelloWorld/Release$ ls
makefile  objects.mk  sources.mk  subdir.mk
[email protected]:~/workspace/HelloWorld/Release$ make
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o"main.o" "../main.cpp"
Finished building: ../main.cpp

Building target: HelloWorld
Invoking: GCC C++ Linker
g++  -o"HelloWorld"  ./main.o   
Finished building target: HelloWorld

[email protected]:~/workspace/HelloWorld/Release$ ./HelloWorld
OK
[email protected]:~/workspace/HelloWorld/Release$ 

So far, so good. Now I copy the whole project tree to FreeBSD and trying to build it:

$ cd /home/alex/project  
$ ls
main.cpp  release
$ cd release
$ ls
makefile objects.mk sources.mk subdir.mk
$ make
"makefile", line 5: Need an operator
"makefile", line 10: Need an operator
"makefile", line 11: Need an operator
"makefile", line 12: Need an operator

CDT-generated makefile doesn't work. This is makefile beginning:

$ Automatically-generated file. Do not edit!


-include ../makefile.init

RM := rm -rf

$ All of the sources participating in the build are defined here
-include sources.mk
-include subdir.mk
-include objects.mk
...

Line 5 is -include ../makefile.init. Really, there is no such file. But it works by some way on Ubuntu computer. What is the trick, how can I build this?

BTW, manually written makefile works:

all:
    g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o"main.o" "../main.cpp"
    g++  -o"HelloWorld"  ./main.o

Note: $ in makefile is actually #, I replaced it because # creates formatting problems inside of stackoverflow pre block.

© Stack Overflow or respective owner

Related posts about eclipse-cdt

Related posts about makefile