Exporting makefile from Eclipse CDT
- by Alex Farber
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:
alex@alex-linux:~/workspace/HelloWorld/Release$ ls
HelloWorld main.d main.o makefile objects.mk sources.mk subdir.mk
alex@alex-linux:~/workspace/HelloWorld/Release$ rm HelloWorld main.d main.o
alex@alex-linux:~/workspace/HelloWorld/Release$ ls
makefile objects.mk sources.mk subdir.mk
alex@alex-linux:~/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
alex@alex-linux:~/workspace/HelloWorld/Release$ ./HelloWorld
OK
alex@alex-linux:~/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.