Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Compiling ohNet on FreeBSD
22-12-2014, 03:54 PM
Post: #11
RE: Compiling ohNet on FreeBSD
Hi Simon,

thanks for your continuing support.

I just tried to implement the changes you suggested.

First, I built the code generation tools you mentioned after I compiled and installed mono. This worked flawlessly, there were no errors and I think these tools are now in place (I didn't gmake install them, tough).

Thanks for the clarification regarding the needed modifications. My Makefile now looks like this:

Code:
root@testus_1:/usr/local/ohnet # diff Makefile.orig Makefile
279a280,290
> # added for FreeBSD-compatibility
> ifeq ($(platform), FreeBSD)
>     platform_cflags = $(version_specific_cflags) -fPIC -DPLATFORM_FREEBSD
>     platform_linkflags = $(version_specific_linkflags) -pthread
>         linkopts_ohNet = -Wl,-soname,libohNet.so
>     osbuilddir = Posix
>     osdir = Posix
>     endian ?= LITTLE
> endif
>
>
288a300,307
>
> # added for FreeBSD-compatibility
> ifeq ($(freebsd), 1)
>       platform = FreeBSD
>       detected_openhome_system = FreeBSD
>       detected_openhome_architecture = x86
> endif
>

Also, the Os.c file has been modified like this:

Code:
root@testus_1:/usr/local/ohnet # diff Os/Posix/Os.c.orig Os/Posix/Os.c
28c28
< #ifndef PLATFORM_MACOSX_GNU
---
> #if !defined(PLATFORM_MACOSX_GNU) && !defined(PLATFORM_FREEBSD)
39c39
< #ifdef PLATFORM_MACOSX_GNU
---
> #if defined(PLATFORM_MACOSX_GNU) || defined(PLATFORM_FREEBSD)
58c58
< #ifdef PLATFORM_MACOSX_GNU
---
> #if defined(PLATFORM_MACOSX_GNU) || defined(PLATFORM_FREEBSD)
636c636
< #ifdef PLATFORM_MACOSX_GNU
---
> #if defined(PLATFORM_MACOSX_GNU) || defined(PLATFORM_FREEBSD)
985c985
< #ifdef PLATFORM_MACOSX_GNU
---
> #if defined(PLATFORM_MACOSX_GNU) || defined(PLATFORM_FREEBSD)
1034c1034
< #if defined(PLATFORM_MACOSX_GNU)
---
> #if defined(PLATFORM_MACOSX_GNU) || defined(PLATFORM_FREEBSD)
1132c1132
< #ifdef PLATFORM_MACOSX_GNU
---
> #if defined(PLATFORM_MACOSX_GNU) || defined(PLATFORM_FREEBSD)
1258c1258
< #ifndef PLATFORM_MACOSX_GNU
---
> #if !defined(PLATFORM_MACOSX_GNU) && !defined(PLATFORM_FREEBSD)
1368c1368
< #ifdef PLATFORM_MACOSX_GNU
---
> #if defined(PLATFORM_MACOSX_GNU) || defined(PLATFORM_FREEBSD)
1380c1380
< #ifdef PLATFORM_MACOSX_GNU
---
> #if defined(PLATFORM_MACOSX_GNU) || defined(PLATFORM_FREEBSD)

Please note that for Os.c I somewhat changed my modification as I saw it necessary, as there were not only "#ifndef PLATFORM_MACOSX_GNU"-lines, but also these: "#ifdef PLATFORM_MACOSX_GNU". Please have a short look and tell me if this is correct or if I should revert this. In my logical understanding it makes sense.

Compilation with above changes still fails with:

Code:
gcc -o Build/Obj/Posix/Release/Os.o -c -fexceptions -Wall  -pipe -D_GNU_SOURCE -D_REENTRANT -DDEFINE_LITTLE_ENDIAN -DDEFINE_TRACE -g -O2 -fvisibility=hidden   -fPIC -Werror -IBuild/Include/  Os/Posix/Os.c
Os/Posix/Os.c:29:28: error: linux/netlink.h: No such file or directory
Os/Posix/Os.c:30:30: error: linux/rtnetlink.h: No such file or directory
cc1: warnings being treated as errors
Os/Posix/Os.c: In function 'OsSemaphoreDestroy':
Os/Posix/Os.c:341: warning: implicit declaration of function 'TEMP_FAILURE_RETRY'
Os/Posix/Os.c: In function 'CreateHandle':
Os/Posix/Os.c:649: error: '__FD_SETSIZE' undeclared (first use in this function)
Os/Posix/Os.c:649: error: (Each undeclared identifier is reported only once
Os/Posix/Os.c:649: error: for each function it appears in.)
Os/Posix/Os.c: In function 'adapterChangeObserverThread':
Os/Posix/Os.c:1283: warning: type-punning to incomplete type might break strict-aliasing rules
Os/Posix/Os.c:1285: warning: implicit declaration of function 'NLMSG_OK'
Os/Posix/Os.c:1285: error: dereferencing pointer to incomplete type
Os/Posix/Os.c:1285: error: 'NLMSG_DONE' undeclared (first use in this function)
Os/Posix/Os.c:1286: error: dereferencing pointer to incomplete type
Os/Posix/Os.c:1286: error: 'RTM_NEWADDR' undeclared (first use in this function)
Os/Posix/Os.c:1287: error: dereferencing pointer to incomplete type
Os/Posix/Os.c:1287: error: 'RTM_DELADDR' undeclared (first use in this function)
Os/Posix/Os.c:1288: error: dereferencing pointer to incomplete type
Os/Posix/Os.c:1288: error: 'RTM_NEWLINK' undeclared (first use in this function)
Os/Posix/Os.c:1291: warning: implicit declaration of function 'NLMSG_NEXT'
Os/Posix/Os.c:1291: warning: assignment makes pointer from integer without a cast
Os/Posix/Os.c: In function 'SetInterfaceChangedObserver_Linux':
Os/Posix/Os.c:1323: error: storage size of 'addr' isn't known
Os/Posix/Os.c:1331: error: 'PF_NETLINK' undeclared (first use in this function)
Os/Posix/Os.c:1331: error: 'NETLINK_ROUTE' undeclared (first use in this function)
Os/Posix/Os.c:1336: error: 'AF_NETLINK' undeclared (first use in this function)
Os/Posix/Os.c:1337: error: 'RTMGRP_LINK' undeclared (first use in this function)
Os/Posix/Os.c:1337: error: 'RTMGRP_IPV4_IFADDR' undeclared (first use in this function)
Os/Posix/Os.c:1323: warning: unused variable 'addr'
Common.mak:421: recipe for target 'Build/Obj/Posix/Release/Os.o' failed
gmake: *** [Build/Obj/Posix/Release/Os.o] Error 1

Greetings,
airflow
Find all posts by this user
22-12-2014, 04:30 PM
Post: #12
RE: Compiling ohNet on FreeBSD
It looks like the PLATFORM_FREEBSD define isn't being set. (You can see this from the compiler command line - the line starting gcc -o). Can you try editing Makefile to move the block starting
else ifeq ($(freebsd), 1)
to around line 60 (the point shown in the diff from my previous post)? At the same time, you can remove the similar section at line 288 in the diff you just posted.

This may fix the build. At the very least it should reduce the number of errors you get compiling OS.c. (Your changes to this file look spot on btw.)
Find all posts by this user
26-12-2014, 03:25 PM
Post: #13
RE: Compiling ohNet on FreeBSD
(22-12-2014 04:30 PM)simonc Wrote:  It looks like the PLATFORM_FREEBSD define isn't being set. (You can see this from the compiler command line - the line starting gcc -o). Can you try editing Makefile to move the block starting
else ifeq ($(freebsd), 1)
to around line 60 (the point shown in the diff from my previous post)? At the same time, you can remove the similar section at line 288 in the diff you just posted.

This may fix the build. At the very least it should reduce the number of errors you get compiling OS.c. (Your changes to this file look spot on btw.)

Hello again, I hope you had a merry Christmas!

I tried implementing the changes you suggested. I was confused about the precise destination of where to move the paragraph to. Line 60 is within multiple convoluted if/else-clauses. So I tried different places. With some the platform-paramater wasn't properly set, with others I assume it was, but compilation failed with the following error:

Code:
root@testus_1:/usr/local/ohnet # gmake all nocpp11=yes freebsd=1
CROSS_COMPILE:
Machine reported by compiler is: amd64-undermydesk-freebsd
Machine reported by uname is: FreeBSD
Building for system FreeBSD and architecture x64
mkdir -p
usage: mkdir [-pv] [-m mode] directory_name ...
Makefile:428: recipe for target 'make_obj_dir' failed
gmake: *** [make_obj_dir] Error 64

In my understanding this is because the variable objdir is not set in my platform-section. So I added the following one:

Code:
# added for FreeBSD-compatibility
ifeq ($(platform), FreeBSD)
    platform_cflags = $(version_specific_cflags) -fPIC -DPLATFORM_FREEBSD
    platform_linkflags = $(version_specific_linkflags) -pthread
        linkopts_ohNet = -Wl,-soname,libohNet.so
    osbuilddir = Posix
    objdir = Build/Obj/$(osbuilddir)/$(build_dir)/   #<-- added this
    osdir = Posix
    endian ?= LITTLE
endif

Actually this fixed the above problem, and compilation begins. It ends later with

Code:
rsync -u Os/*.inl Build/Include/OpenHome
Ascii.o -c -fexceptions -Wall  -pipe -D_GNU_SOURCE -D_REENTRANT -DDEFINE_LITTLE_ENDIAN -DDEFINE_TRACE -g -O2 -fvisibility=hidden  -fPIC -DPLATFORM_FREEBSD -Werror -IBuild/Include/  OpenHome/Ascii.cpp
gmake: Ascii.o: Command not found
Common.mak:231: recipe for target 'Build/Obj/Posix/Release/Ascii.o' failed
gmake: *** [Build/Obj/Posix/Release/Ascii.o] Error 127

I've no clue with this one. Should the file Ascii.o be there? I couldn't find it with find. Did I set objdir to the wrong location?

Greetings,
airflow
Find all posts by this user
31-12-2014, 01:17 PM
Post: #14
RE: Compiling ohNet on FreeBSD
I think you'll need to add something like
Code:
compiler = gcc -o $(objdir)
link = ${CROSS_COMPILE}g++ $(platform_linkflags)
ar = ${CROSS_COMPILE}ar rc $(objdir)
to your ifeq ($(platform), FreeBSD) section.

The compiler assignment should fix your immediate problem. The other lines will fix problems later in the build process.
Find all posts by this user
03-01-2015, 02:17 AM
Post: #15
Rainbow RE: Compiling ohNet on FreeBSD
(31-12-2014 01:17 PM)simonc Wrote:  The compiler assignment should fix your immediate problem. The other lines will fix problems later in the build process.

I implemented above changes. It fixed the previous errors.

Building fails now with the following lines:

Code:
gcc -o Build/Obj/Posix/Release/Os.o -c -fexceptions -Wall  -pipe -D_GNU_SOURCE -D_REENTRANT -DDEFINE_LITTLE_ENDIAN -DDEFINE_TRACE -g -O2 -fvisibility=hidden  -fPIC -DPLATFORM_FREEBSD -Werror -IBuild/Include/  Os/Posix/Os.c
Os/Posix/Os.c:40:53: error: SystemConfiguration/SystemConfiguration.h: No such file or directory
Os/Posix/Os.c:41:22: error: execinfo.h: No such file or directory
Os/Posix/Os.c:67:1: error: "MSG_NOSIGNAL" redefined
In file included from Os/Posix/Os.c:23:
/usr/include/sys/socket.h:461:1: error: this is the location of the previous definition
Os/Posix/Os.c:1138: error: expected specifier-qualifier-list before 'SCDynamicStoreRef'
cc1: warnings being treated as errors
Os/Posix/Os.c: In function 'DestroyInterfaceChangedObserver':
Os/Posix/Os.c:1370: warning: implicit declaration of function 'DestroyInterfaceChangedObserver_MacDesktop'
Os/Posix/Os.c: In function 'OsNetworkSetInterfaceChangedObserver':
Os/Posix/Os.c:1382: warning: implicit declaration of function 'SetInterfaceChangedObserver_MacDesktop'
Common.mak:421: recipe for target 'Build/Obj/Posix/Release/Os.o' failed

I tried researching similar errors in the internet, but didn't succeed. I did find this thread, though! ;-)

greetings,
airflow
Find all posts by this user
05-01-2015, 10:59 AM
Post: #16
RE: Compiling ohNet on FreeBSD
SystemConfiguration/SystemConfiguration.h is included inside a PLATFORM_MACOSX_GNU ifdef. The compiler command in your post suggests this isn't set for you.

Have you removed this ifdef as part of your local changes? Or done anything to cause PLATFORM_MACOSX_GNU to be defined?
Find all posts by this user
05-01-2015, 06:37 PM
Post: #17
RE: Compiling ohNet on FreeBSD
(05-01-2015 10:59 AM)simonc Wrote:  SystemConfiguration/SystemConfiguration.h is included inside a PLATFORM_MACOSX_GNU ifdef. The compiler command in your post suggests this isn't set for you.

Have you removed this ifdef as part of your local changes? Or done anything to cause PLATFORM_MACOSX_GNU to be defined?

I haven't done anything to define PLATFORM_MACOSX_GNU, but I have indeed modified file Os/Posix/Os.c as described in this post:

Code:
#if defined(PLATFORM_MACOSX_GNU) || defined(PLATFORM_FREEBSD)
#include <SystemConfiguration/SystemConfiguration.h>
#include <execinfo.h>
#endif

I thought this was necessary, as I understood the contents of Os.c as the inclusion of certain network-functions of the OS, where there are different sys-flavours supported (e.g. Linux or MAC, where MAC is using BSD as its basis). But now I changed these lines back to its original state:

Code:
#ifdef PLATFORM_MACOSX_GNU
#include <SystemConfiguration/SystemConfiguration.h>
#include <execinfo.h>
#endif

In the end the diff to the original looks now like this (only 2 changes):
Code:
root@testus_1:/usr/local/share/ohnet # diff Os/Posix/Os.c.orig  Os/Posix/Os.c
28c28
< #ifndef PLATFORM_MACOSX_GNU
---
> #if !defined(PLATFORM_MACOSX_GNU) && !defined(PLATFORM_FREEBSD)
1258c1258
< #ifndef PLATFORM_MACOSX_GNU
---
> #if !defined(PLATFORM_MACOSX_GNU) && !defined(PLATFORM_FREEBSD)

With this setup, compilation fails with these lines:

Code:
gcc -o Build/Obj/Posix/Release/Os.o -c -fexceptions -Wall  -pipe -D_GNU_SOURCE -D_REENTRANT -DDEFINE_LITTLE_ENDIAN -DDEFINE_TRACE -g -O2 -fvisibility=hidden  -fPIC -DPLATFORM_FREEBSD -Werror -IBuild/Include/  Os/Posix/Os.c
cc1: warnings being treated as errors
Os/Posix/Os.c: In function 'OsSemaphoreDestroy':
Os/Posix/Os.c:341: warning: implicit declaration of function 'TEMP_FAILURE_RETRY'
Os/Posix/Os.c: In function 'CreateHandle':
Os/Posix/Os.c:649: error: '__FD_SETSIZE' undeclared (first use in this function)
Os/Posix/Os.c:649: error: (Each undeclared identifier is reported only once
Os/Posix/Os.c:649: error: for each function it appears in.)
Os/Posix/Os.c: In function 'DestroyInterfaceChangedObserver':
Os/Posix/Os.c:1373: warning: implicit declaration of function 'DestroyInterfaceChangedObserver_Linux'
Os/Posix/Os.c: In function 'OsNetworkSetInterfaceChangedObserver':
Os/Posix/Os.c:1385: warning: implicit declaration of function 'SetInterfaceChangedObserver_Linux'
Common.mak:421: recipe for target 'Build/Obj/Posix/Release/Os.o' failed
gmake: *** [Build/Obj/Posix/Release/Os.o] Error 1
Find all posts by this user
05-01-2015, 07:22 PM
Post: #18
RE: Compiling ohNet on FreeBSD
Getting close now!

You can fix the error at line 341 by enabling the local define of TEMP_FAILURE_RETRY for PLATFORM_FREEBSD (line 59 in my code; may have moved slightly with your diffs).

The above change may also fix the error at line 649. If not, try searching for where to find a definition of FD_SETSIZE or what define to use in its place.

You can fix the errors at lines 1373 and 1385 by modifying the ifdefs inside DestroyInterfaceChangedObserver and OsNetworkSetInterfaceChangedObserver such that the functions have an empty implementation for PLATFORM_FREEBSD.
Find all posts by this user
05-01-2015, 10:17 PM
Post: #19
RE: Compiling ohNet on FreeBSD
(05-01-2015 07:22 PM)simonc Wrote:  Getting close now!

:-)

Quote:You can fix the error at line 341 by enabling the local define of TEMP_FAILURE_RETRY for PLATFORM_FREEBSD (line 59 in my code; may have moved slightly with your diffs).

The above change may also fix the error at line 649. If not, try searching for where to find a definition of FD_SETSIZE or what define to use in its place.

And did that and yep, both errors are gone.

Quote:You can fix the errors at lines 1373 and 1385 by modifying the ifdefs inside DestroyInterfaceChangedObserver and OsNetworkSetInterfaceChangedObserver such that the functions have an empty implementation for PLATFORM_FREEBSD.

I'm not sure with that one. You mean this section:

Code:
static void DestroyInterfaceChangedObserver(OsContext* aContext)
{
#ifdef PLATFORM_MACOSX_GNU
# ifndef PLATFORM_IOS
    DestroyInterfaceChangedObserver_MacDesktop(aContext);
# endif /* !PLATFORM_IOS */
#else /* !PLATFOTM_MACOSX_GNU */
    DestroyInterfaceChangedObserver_Linux(aContext);
#endif /* PLATFOTM_MACOSX_GNU */
}


void OsNetworkSetInterfaceChangedObserver(OsContext* aContext, InterfaceListChanged aCallback, void* aArg)
{
#ifdef PLATFORM_MACOSX_GNU
# ifndef PLATFORM_IOS
    SetInterfaceChangedObserver_MacDesktop(aContext, aCallback, aArg);
# endif /* !PLATFORM_IOS */
#else /* !PLATFOTM_MACOSX_GNU */
    SetInterfaceChangedObserver_Linux(aContext, aCallback, aArg);
#endif /* PLATFOTM_MACOSX_GNU */
}

I understand that I could a section like

Code:
#ifdef PLATFORM_FREEBSD
#endif /* PLATFORM_FREEBSD */

but what should come inside - what's an "empty implementation"?
Find all posts by this user
05-01-2015, 11:57 PM
Post: #20
RE: Compiling ohNet on FreeBSD
(05-01-2015 10:17 PM)airflow Wrote:  I'm not sure with that one. You mean this section:

Code:
static void DestroyInterfaceChangedObserver(OsContext* aContext)
{
#ifdef PLATFORM_MACOSX_GNU
# ifndef PLATFORM_IOS
    DestroyInterfaceChangedObserver_MacDesktop(aContext);
# endif /* !PLATFORM_IOS */
#else /* !PLATFOTM_MACOSX_GNU */
    DestroyInterfaceChangedObserver_Linux(aContext);
#endif /* PLATFOTM_MACOSX_GNU */
}


void OsNetworkSetInterfaceChangedObserver(OsContext* aContext, InterfaceListChanged aCallback, void* aArg)
{
#ifdef PLATFORM_MACOSX_GNU
# ifndef PLATFORM_IOS
    SetInterfaceChangedObserver_MacDesktop(aContext, aCallback, aArg);
# endif /* !PLATFORM_IOS */
#else /* !PLATFOTM_MACOSX_GNU */
    SetInterfaceChangedObserver_Linux(aContext, aCallback, aArg);
#endif /* PLATFOTM_MACOSX_GNU */
}

I understand that I could a section like

Code:
#ifdef PLATFORM_FREEBSD
#endif /* PLATFORM_FREEBSD */

but what should come inside - what's an "empty implementation"?

An empty implementation is exactly what you showed above - an ifdef/endif with nothing in between.

Since there are other ifdefs in these functions already, you'll need to do something like
Code:
static void DestroyInterfaceChangedObserver(OsContext* aContext)
{
#ifdef PLATFORM_MACOSX_GNU
# ifndef PLATFORM_IOS
    DestroyInterfaceChangedObserver_MacDesktop(aContext);
# endif /* !PLATFORM_IOS */
#elif PLATFORM_FREEBSD
#else /* !PLATFOTM_MACOSX_GNU */
    DestroyInterfaceChangedObserver_Linux(aContext);
#endif /* PLATFOTM_MACOSX_GNU */
}
(plus similar for OsNetworkSetInterfaceChangedObserver)
Find all posts by this user


Forum Jump: