Archive for 21 noviembre 2012

Remmina for Mac OS X build instructions

noviembre 21, 2012

Hi. I’ve managed to build and run Remmina on Mountain Lion Mac OS X.

Let’s see how it was done.

Remmina source code download

Just download suggested source code from github. In my case I downloaded Remmina-1.0.0.tar.gz .

Remmina requisites install

cmake

Cmake provides a mdg package for installing in Mac OS X.

Macports

Macports is not an actual Remmina dependency but I will use it for installing other Remmina dependencies from the terminal without too many problems.

Xcode and CLI tools for Xcode (Mac Ports requisite)

If you want to build mostly anything you’re recommended to install Xcode. You just download it from the Apple developer.

I’m not quite sure right now if you need to install it in order to build Remmina.

  • Install Xcode
    (When opening inside what seems to be a folder please move it to Applications).

    sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
  • Install CLI tools for Xcode
  • sudo xcodebuild -license

    Press q an then agree if you agree.

Macports installation

Macports provides a pckg package for installing in Mac OS X.

Other remmina dependencies

After so many tries here there are most of the packages that Remmina needs in a single command.
Open a terminal and run:

sudo port install pkgconfig libgcrypt libgcrypt \
gtk2 libssh vte xorg-libxkbfile libtelepathy \
libgnome-keyring avahi p5-locale-gettext \
libgcrypt

Freerdp

This is an special requisite that it’s needed by Remmina in order to allow it to make RDP connections.

Freerdp dependencies

These freerdp dependencies are supposed to be handled automatically by homebrew (see below). As I didn’t think that there was an specific brew I tried to handle the depencies manually. These are the commands that I issued:

sudo port install xorg-libXv

Freerdp – Download source code

We download FreeRDP tar.gz. I downloaded freerdp-1.0.1.tar.gz.

Freerdp – Source code hack for boolean issue

This one was a very difficult bug to catch. I still don’t know if it’s a bug or not. I probably think it’s a compiler bug, or maybe the linker… I think somebody more expert than I am should take a look at it.

We will edit file:

channels/rdpdr/printer/printer_cups.c

and add these three lines:

#ifndef __MY_OWN_TEST_H
#define __MY_OWN_TEST_H
typedef int boolean;
#endif /* __MY_OWN_TEST_H */

just before line:

#include

Freerdp build

As I have already said I didn’t know I could use homebrew so I tried to build it manually. However as I needed to edit printer_cups.c I finally had to build it manually.

This is not working for us:

cmake -D "CMAKE_OSX_ARCHITECTURES:STRING=i386;x86_64"

.
So we will do:

cmake -D "CMAKE_OSX_ARCHITECTURES:STRING=x86_64" .

Then we could do:

make

Freerdp – Homebrew

From a terminal we run:

ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"

Freerdp – Xquartz

Not sure why but according to my notes Xquartz is a dependency of Freerdp. Maybe trying to install freerdp from homebrew it tells you to install it manually.

Xquartz can be download and installed as a dmg.
Once installed you’ll need to logout and login.

Freerdp – Final install with Homebrew

brew install freerdp
brew link freerdp

Remmina build preparation

cmake

In order to prepare Remmina build we will issue:

cmake --build=build .

Libraries link hack for Mac OS X

You need to add

-lX11 -L/usr/X11/lib -I/usr/X11/include \
-L/opt/local/lib -lglib-2.0 -lgthread-2.0 \
-lgmodule-2.0

and the result of running:

pkg-config --cflags --libs gtk+-2.0

to the lines found at these files:

remmina/CMakeFiles/remmina.dir/link.txt
remmina-plugins/nx/CMakeFiles/remmina-plugin-nx.dir/link.txt
remmina-plugins/xdmcp/CMakeFiles/remmina-plugin-xdmcp.dir/link.txt
remmina-plugins/rdp/CMakeFiles/remmina-plugin-rdp.dir/link.txt
remmina-plugins/telepathy/CMakeFiles/remmina-plugin-telepathy.dir/link.txt
remmina-plugins/vnc/CMakeFiles/remmina-plugin-vnc.dir/link.txt
remmina-plugins-gnome/CMakeFiles/remmina-plugin-gnome.dir/link.txt

So what you have to add is:

-lX11 -L/usr/X11/lib -I/usr/X11/include \
-L/opt/local/lib -lglib-2.0 -lgthread-2.0 \
-lgmodule-2.0 -D_REENTRANT \
-I/opt/local/include/gtk-2.0 \
-I/opt/local/lib/gtk-2.0/include \
-I/opt/local/include/atk-1.0 \
-I/opt/local/include/cairo \
-I/opt/local/include/gdk-pixbuf-2.0 \
-I/opt/local/include/pango-1.0 \
-I/opt/local/include/gio-unix-2.0/ \
-I/opt/local/include \
-I/opt/local/include/glib-2.0 \
-I/opt/local/lib/glib-2.0/include \
-I/opt/local/include/pixman-1 \
-I/opt/local/include/freetype2 \
-I/opt/local/include/libpng15 \
-L/opt/local/lib -lgtk-x11-2.0 \
-lgdk-x11-2.0 -latk-1.0 \
-lpangocairo-1.0 -lXrender \
-lXinerama -lXi -lXrandr \
-lXcursor -lXcomposite \
-lXdamage -lgdk_pixbuf-2.0 \
-lpangoft2-1.0 -lgio-2.0 \
-lXfixes -lcairo -lX11 -lXext \
-lpango-1.0 -lm -lfreetype \
-lfontconfig -lgobject-2.0 \
-lglib-2.0 -lintl

Path modification so that system sources are found

Add this string (initial space included)

 -I/opt/local/include

to the C_FLAGS variable found on all of these files:

remmina-plugins/xdmcp/CMakeFiles\
/remmina-plugin-xdmcp.dir/flags.make

remmina-plugins/rdp/CMakeFiles\
/remmina-plugin-rdp.dir/flags.make

remmina-plugins/telepathy/CMakeFiles\
/remmina-plugin-telepathy.dir/flags.make

remmina-plugins/vnc/CMakeFiles\
/remmina-plugin-vnc.dir/flags.make

remmina-plugins/vnc/libvncserver\
/CMakeFiles/vncclient.dir/flags.make

so that you add to the C_FLAGS variable:

Telepathy hacks

Actually I didn’t build Telepathy because I found out problems. I write the instructions because if I tried it again I would try the suggested hack. You can skip these steps if you’re interested in Telepathy plugin.

Telepathy build make hack

We will edit also:

remmina-plugins/telepathy/CMakeFiles\
/remmina-plugin-telepathy.dir/build.make

to add these lines:

remmina-plugins/telepathy/CMakeFiles\
/remmina-plugin-telepathy.dir\
/telepathy_handler.c.o: remmina-plugins\
/telepathy/CMakeFiles\
/remmina-plugin-telepathy.dir/flags.make

remmina-plugins/telepathy/CMakeFiles\
/remmina-plugin-telepathy.dir\
/telepathy_handler.c.o: \
remmina-plugins/telepathy/telepathy_handler.c

$(CMAKE_COMMAND) -E cmake_progress_report \
/Users/adrian/remminadev\
/FreeRDP-Remmina-356c033/CMakeFiles \
$(CMAKE_PROGRESS_1)

@$(CMAKE_COMMAND) -E cmake_echo_color \
--switch=$(COLOR) --green "Building \
C object remmina-plugins/telepathy\
/CMakeFiles/remmina-plugin-telepathy.dir\
/telepathy_handler.c.o"

cd /Users/adrian/remminadev\
/FreeRDP-Remmina-356c033/remmina-plugins\
/telepathy && /usr/bin/cc \
-I/opt/local/include/dbus-1.0 \
$(C_DEFINES) $(C_FLAGS) -o \
CMakeFiles/remmina-plugin-telepathy.dir\
/telepathy_handler.c.o -c /Users/adrian\
/remminadev/FreeRDP-Remmina-356c033\
/remmina-plugins/telepathy/telepathy_handler.c

just before the first line that begins with:

remmina-plugins/telepathy/CMakeFiles\
/remmina-plugin-telepathy.dir/telepathy_plugin.c.o

In the same file add this line:

remmina-plugins/telepathy\
/remmina-plugin-telepathy.dylib: \
remmina-plugins/telepathy/CMakeFiles\
/remmina-plugin-telepathy.dir/telepathy_handler.c.o

just before the first line that begins with:

remmina-plugins/telepathy/remmina-plugin-telepathy.dylib:

Telepathy link hack

We also have to install to edit:

remmina-plugins/telepathy/CMakeFiles\
/remmina-plugin-telepathy.dir/link.txt

file so that:

CMakeFiles/remmina-plugin-telepathy.dir\
/telepathy_plugin.c.o

becomes:

CMakeFiles/remmina-plugin-telepathy.dir\
/telepathy_plugin.c.o CMakeFiles\
/remmina-plugin-telepathy.dir/telepathy_handler.c.o

Telepathy link additional hack

We need to edit:

remmina-plugins/telepathy/CMakeFiles\
/remmina-plugin-telepathy.dir/link.txt

again so that we add:

-I/opt/local/lib/

.

Telepathy final build error

Unfortunately I was unable to build and the error message was:

"_dbus_g_connection_register_G_OBJECT"\
, referenced from:_remmina_tp_handler_new \
in telepathy_handler.c.o
while inside:
/opt/local/lib/libdbus-glib-1.2.dylib
the reference is:
_dbus_g_connection_register_g_object

Telepathy possible hack

Now after all the builds I’ve made I think that probably the fix is to replace:

dbus_g_connection_register_G_OBJECT

to:

dbus_g_connection_register_g_object

in

remmina-plugins/telepathy/telepathy_handler.c

file but I have not tested it.

Disabling Telepathy

Note: Probably editing a CMake definition files you can disable Telepathy plugin alltoghether but as I decided not to fix problems thanks to CMake but to Makefiles you will see that it’s a bit dirty hack.

If you want to test telepathy later I recommend you to backup the files we are going to modify right now.

We just edit:

Makefile

and remove any lines that contains telepathy.

We will also edit:

remmina-plugins/CMakeLists.txt

to remove telepathy references.

Vnc hacks

We will edit:

remmina-plugins/vnc/CMakeFiles\
/remmina-plugin-vnc.dir/link.txt

again to replace:

/opt/local/lib/libjpeg.dylib

so that it reads:

/opt/local/lib/libjpeg.dylib \
/opt/local/lib/libgcrypt.dylib

We will edit:

remmina/src/remmina_plugin_manager.

and replace

if (g_strcmp0(ptr,G_MODULE_SUFFIX) != 0)

to

if (g_strcmp0(ptr, "dylib") != 0)

RDP hacks

We need to do edit:

remmina-plugins/rdp/CMakeFiles\
/remmina-plugin-rdp.dir/link.txt

again to add the line:

/usr/local/lib/libfreerdp-utils.dylib \
/usr/local/lib/libfreerdp-cache.dylib

Remmina final build

From the terminal run:

make

.

Remmina installation

From the terminal run:

sudo make install

.

Remmina. How to run

If you wish to run it from the CLI you can:

/usr/local/bin/remmina

or even with:

remmina

Build instructions and upstream

Here there are some considerations that might be interesting to know if we want this build to be official, that’s it, to be in upstream.

  • My hacks around the code are based on the code after running cmake. Actually what should be done is modify Cmake definition files so that link.txt, build.make and other files are generated from cmake.
  • Conditional MAC. There’s a variable that can be used to determine if we’re build in a mac, or if we want a MAC build. All my hacks didn’t use that variable. Final code should use this variable in conditional sentences so that same code builds in every platform.
  • Although most of the hacks are Remmina hacks I did also hacked FreeRDP hack and thus it should be considered to be submitted FreeRDP upstream too.
  • I have only tried in freshly installed Mountain Lion Mac OS X. So not sure if it would work in older versions with my instructions.
  • My development is based on FreeRDP 1.0.1 and Remmina 1.0.0. I think that I took a look at FreeRDP and a lot of its source is in process of complete rewritement. So… maybe my tests are not suitable for next stable release of FreeRDP.

Future of Remmina for Mac OS X build

Remmina integration with Mac OS X

There’s something I haven’t mentioned yet. Whenever Remmina is run X server is also run and it’s not integrated in the dock. According to GTK OS Integration you can edit a few lines and get a proper Mac OS X integration.

I’m not sure I would be able to hack Remmina to do that. One thing is having to infer build and link dependencies and another thing is learning how gtk applications are developed. And I’m not personally too much interested.

Packaging

Remmina should be also be packaged so that it can be easily installed. Either in its binary form or maybe in its source code form and automatically compiled as port program I think does.

Why?

  • A friend of mine wanted a better RDP client on his Mac OS X. I didn’t find a Mac OS X build of Remmina.
  • I found some time in a weekend
  • I was just curious about how easy or difficult was to build application in Mac OS X

Won’t you make more tests?

Probably not. I usually use Debian Gnu/Linux on my mac and my Mac OS X partition is only for tests. More than this I couldn’t bear the application-oriented GUI that Mac OS X has.

However if you want me to build or test your hacks, or maybe upstream tests I will do it in the weekends.