# Building Kernel Errors



## Mark Muscat (Aug 16, 2016)

I am having trouble compiling an untouched copy of the Kernel (Generic).

I started out by adding a few print lines (uprintf) to the /usr/src/sys/dev/usb/usb_hid.c. The idea is to see the program work thoroughly when attaching a usb hid device, but that's beside the point.

However, when I try to build the Kernel (
`# make buildkernel KERNCONF=[I]MYKERNEL[/I]` ) I get the following two errors:


```
/usr/src/sys/dev/pci/pcivar.h:303:1:error: implicit declaration of function 'BUS_READ_IVAR' is invalid in C99
```


```
/usr/src/sys/dev/pci/pcivar.h:303:1:error: implicit declaration of function 'BUS_WRITE_IVAR' is invalid in C99
```

As I have said above I have not touched the config file of the Kernel and neither this specific file mentioned in the errors. Any ideas as to what might be causing this? Thanks

*EDIT* I have also tried building the original GENERIC version of the Kernel, with the same results.


----------



## SirDice (Aug 16, 2016)

Revert your changes, apparently you changed something that broke things.


----------



## Maxnix (Aug 16, 2016)

I found this on Stack Overflow: http://stackoverflow.com/questions/9182763/implicit-function-declarations-in-c; should be your case.


----------



## tobik@ (Aug 16, 2016)

Mark Muscat said:


> *EDIT* I have also tried building the original GENERIC version of the Kernel, with the same results.


Are your kernel sources in sync with your current FreeBSD version? How did you get the sources?


----------



## youngunix (Aug 16, 2016)

`BUS_READ_IVAR` does not exist in (10):

CURRENT: /sys/dev/pci/pcivar.h #updated on _Tue Aug 9_
STABLE: /sys/dev/pci/pcivar.h #updated on _Sun Jul 24_

RELEASE: /sys/dev/pci/pcivar.h #updated on _Mon Apr 4_

Post the output of `uname -a`.


----------



## Mark Muscat (Aug 17, 2016)

**UPDATE**
I have checked my FreeBSD and it is 11.0-CURRENT. As far as I know this is not the stable version. What I will do now is redownload the latest source and attempt to rebuild the Kernel (with the idea of having 11.0-Stable). Any ideas how to do this please? I know it has to do with _SVN_ but I down't know the specific URL needed to update the_/usr/src. _As soon as I figure it out I will be updating this thread.

Thanks for your support.

[ Answering the questions you asked me ]

executing `uname -a` It outputs FreeBSD FreeBSD_Test 11.0-CURRENT FreeBSD 11.0-CURRENT #0 r296485

Apparently, since it was not me who installed this system (our admin), it is not the stable version and I will have to update it to the 11-Stable OR Release as I have said above.

**UPDATE #2**
I created a new directory `mkdir src_11_stable` and downloaded the latest stable version of FreeBSD (11), using the command:

`svn checkout https://svn.FreeBSD.org/base/stable/11`

This downloaded the source files in the said depository (Took a while).

As soon as this was done, I built the new Kernel (`make buildkernel`), having it finally successfully built.

Followed by a installation of the kernel (`make installkernel`) and a reboot, the new stable FreeBSD 11.0 [PRERELEASE] is now on my system.

Hopefully this will not prompt any more problems in the future and this post will help others finding themselves in similar situations.


----------



## youngunix (Aug 17, 2016)

You need to read the following articles from the manual:

Using FreeBSD-STABLE
Building World and Kernel
To keep things neat and organized, the source you check out should be in /usr/src. If you are planning on building ports, you need to checkout the ports tree that matches the development branch you are using.


----------



## youngunix (Aug 17, 2016)

BTW, you mentioned that your "admin" is the one that installed the OS, is this a production machine or just for testing?


----------



## SirDice (Aug 18, 2016)

Mark Muscat said:


> I created a new directory  mkdir src_11_stable and downloaded the latest stable version of FreeBSD (11), using the command:
> 
> svn checkout https://svn.FreeBSD.org/base/stable/11
> 
> ...


You need to update the _whole_ system, not just the kernel. At the moment you have an up to date kernel with out of date userland.

Handbook: 23.6. Rebuilding World


----------



## Mark Muscat (Aug 22, 2016)

youngunix said:


> BTW, you mentioned that your "admin" is the one that installed the OS, is this a production machine or just for testing?


It is for testing mainly, I am working on a virtual machine and a solo machine, on which I test my devices and programs


----------

