Porting to FreeBSD
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Porting to FreeBSD
Hello!
I'm making a FreeBSD port of FreeCAD, and I had to make several little changes for it to compile and run. Some of them are just including some headers or adding some conditional preprocessor options (like adding || defined(FC_OS_BSD) in several places) but some of them are a bit bigger.
The main changes are related to the use of the the deprecated function ftime() (that's now being replaced for gettimeofday()) that in FreeBSD requires the static lib -lcompat and is a nightmare to build as you can't link static and dynamic libraries (as some of the FreeCAD core functions are compiled as dynamic libraries), and the code for finding the home path in Application::FindHomePath(), that for Linux uses /proc/self/exe, that is not available on BSDs, so I had to add a FC_OS_FREEBSD conditional and use a sysctl call to get it.
I have several patches for the FreeBSD port system, but perhaps some of them can be included in the FreeCAD code. Any interest on this?
BTW, with the changes FreeCAD runs just fine on FreeBSD.
References:
man ftime: "This function is obsolete. Don't use it. If the time in seconds suffices, time(2) can be used; gettimeofday(2) gives microseconds;"
I'm making a FreeBSD port of FreeCAD, and I had to make several little changes for it to compile and run. Some of them are just including some headers or adding some conditional preprocessor options (like adding || defined(FC_OS_BSD) in several places) but some of them are a bit bigger.
The main changes are related to the use of the the deprecated function ftime() (that's now being replaced for gettimeofday()) that in FreeBSD requires the static lib -lcompat and is a nightmare to build as you can't link static and dynamic libraries (as some of the FreeCAD core functions are compiled as dynamic libraries), and the code for finding the home path in Application::FindHomePath(), that for Linux uses /proc/self/exe, that is not available on BSDs, so I had to add a FC_OS_FREEBSD conditional and use a sysctl call to get it.
I have several patches for the FreeBSD port system, but perhaps some of them can be included in the FreeCAD code. Any interest on this?
BTW, with the changes FreeCAD runs just fine on FreeBSD.
References:
man ftime: "This function is obsolete. Don't use it. If the time in seconds suffices, time(2) can be used; gettimeofday(2) gives microseconds;"
Re: Porting to FreeBSD
By all means, yes!dpello wrote:I have several patches for the FreeBSD port system, but perhaps some of them can be included in the FreeCAD code. Any interest on this?
Re: Porting to FreeBSD
I don't know if you found a good solution for this. If not, I think you can also use Qt's QTime class internally or maybe the boost library offers something useful.The main changes are related to the use of the the deprecated function ftime() (that's now being replaced for gettimeofday()) that in FreeBSD requires the static lib -lcompat and is a nightmare to build as you can't link static and dynamic libraries (as some of the FreeCAD core functions are compiled as dynamic libraries),
Re: Porting to FreeBSD
I just replaced ftime() with the now standard getimeofday(), It was just used in two files. The thing is it's still used in windows, so I added conditional compiling and redefined the timeb struct when compiling on "not windows", something like this:wmayer wrote: I don't know if you found a good solution for this. If not, I think you can also use Qt's QTime class internally or maybe the boost library offers something useful.
Base/TimeInfo.h:
Code: Select all
#if defined(FC_OS_WIN32)
#include <sys/timeb.h>
#else
#include <sys/time.h>
#endif
...
#if !defined(FC_OS_WIN32)
struct timeb
{
int64_t time;
unsigned short millitm;
};
#endifCode: Select all
void TimeInfo::setCurrent(void)
{
#if defined (WIN32)
_ftime( &timebuffer );
#else
struct timeval t;
gettimeofday(&t, NULL);
timebuffer.time = t.tv_sec;
timebuffer.millitm = t.tv_usec / 1000;
#endif
}Where will be a good place to send the patches? Open an Issue? Make a github fork?
Thanks.
Re: Porting to FreeBSD
If you already have a github account then I think a fork is the most convenient. If you don't have an account you don't need to create one extra for this. Then you can also attach the patch file to this thread.Where will be a good place to send the patches? Open an Issue? Make a github fork?
Thanks.
Re: Porting to FreeBSD
I'm sending a pull request in github then.
Thanks!
Thanks!
Re: Porting to FreeBSD
Pull Request sent and Travis CI build tests passed.
Re: Porting to FreeBSD
Thanks! It's merged now.
Re: Porting to FreeBSD
Great!
There is another thing I forgot to mention. As you can see, I'm new to FreeCAD code base, so I'm still trying to get a global image of all the parts.
In the FreeBSD port Makefiles (not related with the freecad makefiles), I'm needing to pass a define for KDL_USE_NEW_TREE_INTERFACE for the Mod/Robot to compile. As this looks something specific to the FreeBSD library versions or something like that, I didn't include that on the patches, but perhaps I can also add a conditional ( if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD) ) to the CMakeLists.txt of Mod/Robot, to include a add_definitions(-DKDL_USE_NEW_TREE_INTERFACE).
What do you think? If it's ok, I'll test it on my system and then I'll make another pull request.
Thanks!
There is another thing I forgot to mention. As you can see, I'm new to FreeCAD code base, so I'm still trying to get a global image of all the parts.
In the FreeBSD port Makefiles (not related with the freecad makefiles), I'm needing to pass a define for KDL_USE_NEW_TREE_INTERFACE for the Mod/Robot to compile. As this looks something specific to the FreeBSD library versions or something like that, I didn't include that on the patches, but perhaps I can also add a conditional ( if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD) ) to the CMakeLists.txt of Mod/Robot, to include a add_definitions(-DKDL_USE_NEW_TREE_INTERFACE).
What do you think? If it's ok, I'll test it on my system and then I'll make another pull request.
Thanks!
Re: Porting to FreeBSD
Not sure which problem you want to solve but there was an issue with KDL for OSX. To fix this a build option has been added to link Robot to an external KDL version. Maybe that's an option for FreeBSD, too. You find it in the cmake panel.