# Makefile generated by Eclipse CDT doesn't work in FreeBSD



## AlexF (Mar 24, 2010)

I created HelloWorld C++ project in Ubuntu, Eclipse CDT. CDT generates makefile which can be executed from command line: make. It works well in original Ubuntu location.
Now I move the whole project tree to FreeBSD computer and try to build makefile here. Result is:


```
# 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
```

Makefile looks like this:

```
################################################################################
# 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
...
```

I get error message on every -include line. Manually written makefile works in FreeBSD:


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

Why GCC on FreeBSD doesn't understand CDT generated makefile? GCC version on Ubuntu is:
gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1
GCC version on FreeBSD is:
4.2.1 20070719 [FreeBSD]


----------



## graudeejs (Mar 24, 2010)

make your own makefile 
They are easy to create.
Besides as much as I have used generated makefiles, manually created makefiles, were much smaller, simper and much more portable


----------



## SirDice (Mar 24, 2010)

FreeBSD's make file format is slightly different. Use devel/gmake if you need the same one as on Linux.


----------



## AlexF (Mar 24, 2010)

Yes, I can write my own makefile, this is not a problem for HelloWorld project  But my actual CDT workspace in Ubuntu contains many of projects, with using third-party libraries, and I need a way to use existing makefiles as is. I want to copy the whole workspace to FreeBSD and just build it from the command line.
Maybe GCC installed on FreeBSD doesn't understand -include lines? It my GCC version is up-to-date?


----------



## AlexF (Mar 24, 2010)

SirDice, sorry for stupid question, but my FreeBSD experience is only two days  I understand from your post, that I need to install the gmake package on FreeBSD, and use gmake instead of make to build Linux-generated files, is this correct?


----------



## graudeejs (Mar 24, 2010)

AlexF said:
			
		

> SirDice, sorry for stupid question, but my FreeBSD experience is only two days  I understand from your post, that I need to install the gmake package on FreeBSD, and use gmake instead of make to build Linux-generated files, is this correct?



No,
By default you are using make which is included in FreeBSD base system.
For example

```
make -f Makefile
```

you need to install gmake (probably already installed) and use

```
gmake -f Makefile
```

for this to work you need to configure your Eclipse, somewhere related to GNU utilities...


----------



## AlexF (Mar 24, 2010)

Just typing gmake instead of make solved the problem, thanks a lot!


----------



## graudeejs (Mar 24, 2010)

I'm just saying, that you can configure Eclipse to use gmake by default, so you don't need to type gmake yourself


----------

