Solved New port for Plex Home Theater?

Hi,

I am interested in using Plex Home Theater on FreeBSD. Whilst it is not officially supported, it has been reported to work on Linux. The Arch Linux aur is available for reference here: https://aur.archlinux.org/packages/plex-home-theater/.

This program is a fork of XBMC, so multimedia/xbmc is a good place to start.

I have spent the better part of today trying to do this myself, but this is my first attempt at a port, and its not an easy one to start on! Not least of all is both XBMC and Plex Home Theater use cmake, but the existing xbmc port does not have USES= cmake.

Thoughts? Anyone else interested in this program running on FreeBSD?
 
Further attempts at this have still not been successful.

I have had a number of issues with the cmake build target being LINUX, and therefore TARGET_FREEBSD not been defined. I set it manually in the port Makefile to solve this one, and also patched a few TARGET_FREEBSD references to __FreeBSD__.

My port files are stored here: http://woodsb02.no-ip.org/plexhometheater/

My current problem is that if I build with internal ffmpeg cmake create multiple cascading subdirectories. I.e. the following folder exists in the working directory: lib/ffmpeg/ffmpeg/src/ffmpeg/ffmpeg/src/ffmpeg/ffmpeg/src/ffmpeg/ffmpeg/src/ffmpeg/ffmpeg/src/ffmpeg/ffmpeg/src

If I disable internal ffmpeg, I come up against other errors caused by differences in the ffmpeg build.

Anyone able to provide any assistance or recommendations?
 
would the linux compat layer help out at all to run the linux version?

its also XBMC based so cant be far off?
 
@rmr: your post inspired me to continue my porting efforts. There are two main differences to xbmc:
  1. The build process uses cmake rather than GNU autotools, meaning the xbmc configure scripts are not used. I have had to patch the cmake build scripts quite a bit to get it to compile as it did not have FreeBSD build targets. It does now with the patches in this port.
  2. There is a new section of code dedicated to the plex components. Whilst this is cross platform, I will need to re-write/patch their NetworkInterface::WatchForChanges() functions in plex/Client/PlexNetworkServiceBrowser.cpp as they use some Linux kernel specific networking stuff.

Other than that it is pretty close. I have updated the port files hosted on my home webserver here: http://woodsb02.no-ip.org/plexhometheater/.

The cmake build scripts finish without errors, but it is failing during linking because of the missing NetworkInterface::WatchForChanges() function. For reference, here are the linking errors:

Code:
[100%] Built target xbmc
Scanning dependencies of target PlexHomeTheater
Linking CXX executable plexhometheater
CMakeFiles/PlexMain.dir/Client/PlexNetworkServiceBrowser.cpp.o: In function `CPlexServiceListener::Process()':
/root/plexhometheater/work/plexinc-plex-home-theater-public-ba10a76/plex/Client/PlexNetworkServiceBrowser.cpp:112: undefined reference to `NetworkInterface::WatchForChanges()'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
*** [plex/plexhometheater] Error code 1
1 error
*** [plex/CMakeFiles/PlexHomeTheater.dir/all] Error code 2
1 error
*** [all] Error code 2
1 error
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** [do-build] Error code 1

Stop in /root/plexhometheater.
*** [build] Error code 1

Stop in /root/plexhometheater.
 
Last edited by a moderator:
I now have this port working and ready for more testing. I have submitted a bug report to have it added to the FreeBSD ports https://bugs.freebsd.org/191413.

Can anyone that has time to build this from source try downloading and testing the code from redports? https://redports.org/browser/woodsb02/multimedia/plexhometheater

There is one problem with the resulting executable which I have not yet tracked down: once installed you need to:
# sed -i.bak s/dll_fopen/fopen/g /usr/local/bin/system/ImageLib-x86_64.so

Before running the executable in X11, you first need to set the XBMC_HOME environment variable.
$ export XBMC_HOME=/usr/local/share/XBMC

After that it seems to work fine (tested on FreeBSD 10.0-RELEASE).
 
It fails here at the last moment, while installing net/samba-nmblookup:
Code:
===>>> multimedia/plexhometheater >> net/samba-nmblookup (9/9)

===>  Installing for samba36-nmblookup-3.6.24
===>  Checking if net/samba-nmblookup already installed
===>   Registering installation for samba36-nmblookup-3.6.24 as automatic
Installing samba36-nmblookup-3.6.24...pkg-static: samba36-nmblookup-3.6.24 conflicts with samba36-3.6.24 (installs files into the same place).  Problematic file: /usr/local/bin/nmblookup
*** Error code 70

Stop.
make: stopped in /usr/ports/net/samba-nmblookup
# pkg delete samba36 gives an error:
Code:
[1/1] Deleting samba36-3.6.24...pkg: /usr/local/bin/nmblookup fails original SHA256 checksum, not removing

I cannot install both packages together, so I forget about Samba for the moment to proceed with the test, but the install fails:
Code:
===>  Installing for plexhometheater-1.1.1
===>  Checking if multimedia/plexhometheater already installed
===>   Registering installation for plexhometheater-1.1.1
pkg-static: lstat(/usr/ports/multimedia/plexhometheater/work/stage/usr/local/bin/system/ImageLib-x86_64.so): No such file or directory
pkg-static: lstat(/usr/ports/multimedia/plexhometheater/work/stage/usr/local/bin/system/libcpluff-x86_64.so): No such file or directory
pkg-static: lstat(/usr/ports/multimedia/plexhometheater/work/stage/usr/local/bin/system/players/dvdplayer/avcodec-53-x86_64.so): No such file or directory
pkg-static: lstat(/usr/ports/multimedia/plexhometheater/work/stage/usr/local/bin/system/players/dvdplayer/avfilter-2-x86_64.so): No such file or directory
pkg-static: lstat(/usr/ports/multimedia/plexhometheater/work/stage/usr/local/bin/system/players/dvdplayer/avformat-53-x86_64.so): No such file or directory
pkg-static: lstat(/usr/ports/multimedia/plexhometheater/work/stage/usr/local/bin/system/players/dvdplayer/avutil-51-x86_64.so): No such file or directory
pkg-static: lstat(/usr/ports/multimedia/plexhometheater/work/stage/usr/local/bin/system/players/dvdplayer/postproc-52-x86_64.so): No such file or directory
pkg-static: lstat(/usr/ports/multimedia/plexhometheater/work/stage/usr/local/bin/system/players/dvdplayer/swresample-0-x86_64.so): No such file or directory
pkg-static: lstat(/usr/ports/multimedia/plexhometheater/work/stage/usr/local/bin/system/players/dvdplayer/swscale-2-x86_64.so): No such file or directory
pkg-static: duplicate file listing: /usr/local/share/applications/plexhometheater.desktop, ignoring
*** Error code 74

Stop.
make[1]: stopped in /usr/ports/multimedia/plexhometheater
*** Error code 1

Stop.
make: stopped in /usr/ports/multimedia/plexhometheater

===>>> Installation of plexhometheater-1.1.1 (multimedia/plexhometheater) failed
===>>> Aborting update
Any suggestions?
 
Hi Juanitou,

Your initial samba issues look like there is a clash between your samba36 package and the samba36-nmblookup package. I have experienced this once before when I had samba41 installed (only 1 can be installed at a time as they clash).

As for the failed install, it looks like a problem with the port plist, although I did not experience this problem. I have not yet included in the plist file which files vary when different options are used. I will try some changes tonight and get back to you.
 
foo_daemon said:
Congratulations and good work.. I'm going to test it this weekend :beergrin

Make sure you use the latest port (plexhometheater v1.2.2 updated on 13th September) for your testing as it fixed a number of issues. No packages available yet, but should be in the next couple of days.
 
seradares said:
I found I had to run the sed command similar to above due to a "undefined symbol dll_fopen" error:
# sed -i.bak s/dll_fopen/fopen/g /usr/local/lib/plexhometheater/system/ImageLib-x86_64-freebsd.so

Bug report for this issue, and a patch which fixes it can be found here: PR 194237

@seradares: do you think you would be able to build this from the ports tree with this patch, and provide feedback if it resolves the issue for you too?
 
Last edited by a moderator:
I just finished building the port, and when it looks like that patch fixes the problem with dll_fopen.

However, as always, you fix one problem, you find another! Now instead of ImageLib failing with an error about dll_fopen, I get the following:
Code:
$ /usr/local/bin/plexhometheater.sh
/usr/local/lib/plexhometheater/system/ImageLib-x86_64-freebsd.so: Undefined symbol "_ZN11XbmcThreads8pthreads14RecursiveMutex16getRecursiveAttrEv"
 
I have finally found the problem, and worked out how to fix it.

In summary, ImageLib is loaded as a shared library when it is required. The ImageLib code includes a few calls to functions in the main XBMC codebase. Shared libraries do not have access to the functions in the main program, unless the linker of the main program is called with --export-dynamic argument (which can be achieved by adding the -rdynamic argument to the compiler flags).

This can be achieved in CMAKE by adding the following line to the plex/CMakeLists.txt (I added it at line 154 after the set correct binary name lines):
Code:
#### Allow shared libraries to call plexhometheater functions
set_target_properties(${PLEX_TARGET_NAME} PROPERTIES ENABLE_EXPORTS 1)

This is the only change required to fix this problem (per my testing on FreeBSD 10). My previous suggestion of altering the add_library(wrapper STATIC wrapper.c) line is not necessary. I still am baffled as to why this isn't an issue on Linux? Does Linux default these linker arguments? The answer to this will determine what the patch should look like (i.e. only is TARGET_FREEBSD, or for all UNIX builds).

For reference, here is an excerpt from the ld(1) manpage that explains this behaviour:
Code:
       --export-dynamic
           When creating a dynamically linked executable, add all symbols to
           the dynamic symbol table.  The dynamic symbol table is the set of
           symbols which are visible from dynamic objects at run time.

           If you do not use this option, the dynamic symbol table will
           normally contain only those symbols which are referenced by some
           dynamic object mentioned in the link.

           If you use "dlopen" to load a dynamic object which needs to refer
           back to the symbols defined by the program, rather than some other
           dynamic object, then you will probably need to use this option when
           linking the program itself.

           You can also use the dynamic list to control what symbols should be
           added to the dynamic symbol table if the output format supports it.
           See the description of --dynamic-list.
 
This issue with ImageLib crashing with dll_fopen errors is now fixed in the FreeBSD ports tree as of SVN revision 370791 (port version 1.2.2_3).
 
Back
Top