About porting MEGASync

Hi Community,

I want to try porting the latest version of MEGASync to FreeBSD (I know kqueue is needed).
So I start from compiling the source code but stucked in some steps.
My question is, may I know if anyone had successfully compiled the latest version of MEGASync?
1617782780956.png
 
I want to try porting the latest version of MEGASync to FreeBSD
But the shell prompt suggests you are using GhostBSD.

 
But the shell prompt suggests you are using GhostBSD.

From what I know, their base is the same (e.g. GhostBSD is adopting the Kernel from FreeBSD). GhostBSD tries to make FreeBSD to be easy to use. Could you provide some advise based on FreeBSD?
 
Maybe creating a port for that will be better? Since you can deal with patches, path and all the stuff directly into the port Makefile instead of modifying megasync source tree.
 
autoreconf will just attempt to re-generate the configure script from configure.ac, assuming this code indeed uses GNU autotools.

But I agree, it's probably easier to start with creating a port right away. There's a helpful USES=autoreconf to handle that kind of breakage automatically.
 
Here´s a Makefile that I´ve started, but I had too many chimichangas that i´ve stopped worked on it. At last you have the deps and everything else. It´ll need more things to be done (in the case of megasync, you´ll need the Makefile.freebsd) Change it to suit your needs.

Makefile:
# $FreeBSD$

PORTNAME=    megasync
DISTVERSION=    v4.4.0.0
DISTVERSIONSUFFIX=    _Linux
CATEGORIES=    net

MAINTAINER=    menelkir@itroll.org
COMMENT=    MEGA Cloud Drive client

LICENSE=    MEGA
LICENSE_NAME=   MEGA
LICENSE_FILE=    ${WRKSRC}/LICENCE.md
LICENSE_PERMS=  no-dist-sell

LIB_DEPENDS=    libcares.so:dns/c-ares \
        libcryptopp.so:security/cryptopp \
        libsodium.so:security/libsodium \
        libuv.so:devel/libuv \
        libQt5Svg.so:graphics/qt5-svg \
        libQt5X11Extras.so:x11/qt5-x11extras \
        libmediainfo.so:multimedia/libmediainfo \
        libraw.so:graphics/libraw \
        libpcre.so:devel/pcre

USES=        libtool sqlite:3 readline shebangfix ssl qmake qt:5

NO_CDROM=       Commercial users must seek permission from copyright holders.

USE_GITHUB=    yes
GH_ACCOUNT=    meganz
GH_PROJECT=    MEGAsync sdk:sdk
GH_SUBDIR=    sdk:sdk
GH_TAGNAME=    v3.7.3c:sdk

USE_LDCONFIG=    yes

MAKEFILE=    Makefile.freebsd

INSTALL_TARGET=    install-strip

SHEBANG_FILES=    src/configure

CXXFLAGS+=    `pkgconf --cflags-only-other libcryptopp`

.include <bsd.port.mk>
 
Unless you want some specific functionality with MEGAsync, remember rclone can mount and sync MEGA folders as well ;)
Doesn´t work as expected for mega, it works at some point but there´s many other issues like timeout, lag, etc. Being there, done that.
Actually the best choices for sync with mega is:
net/megatools : Works fine, but have some issues like lag and you don´t have a proper daemon for that (you can use a cron and a script, of course).
net/megacmd : It´s the official mega solution, works exactly the same but without a fancy GUI like megasync. There´s a daemon that runs in background. Have is own issues like lag in different scenarios, etc.
 
Last edited by a moderator:
Any update on this? Maybe I can help if you're stuck in something.
Was in some projects and only have time to check the code. But currently still find nothing that would cause the "configure" error on line 18231 (the configure files seems to be auto created by autoconf from the configure.ac file). My target is to get the source code to be complied, then should be able to make it in to ports.
 
Stuck at this step during make -f Makefile, they are in some header files in /usr/local/include. But I am not sure how to continue.
Bash:
ld: error: undefined symbol: av_log_set_level(int)
>>> referenced by freeimage.cpp:183 (mega/src/gfx/freeimage.cpp:183)
>>>               freeimage.o:(mega::GfxProcFreeImage::readbitmapFfmpeg(mega::FileAccess*, mega::LocalPath const&, int))

ld: error: undefined symbol: avformat_open_input
>>> referenced by freeimage.cpp:188 (mega/src/gfx/freeimage.cpp:188)
>>>               freeimage.o:(mega::GfxProcFreeImage::readbitmapFfmpeg(mega::FileAccess*, mega::LocalPath const&, int))

ld: error: undefined symbol: avformat_find_stream_info
>>> referenced by freeimage.cpp:197 (mega/src/gfx/freeimage.cpp:197)
>>>               freeimage.o:(mega::GfxProcFreeImage::readbitmapFfmpeg(mega::FileAccess*, mega::LocalPath const&, int))

ld: error: undefined symbol: avcodec_find_decoder
>>> referenced by freeimage.cpp:241 (mega/src/gfx/freeimage.cpp:241)
>>>               freeimage.o:(mega::GfxProcFreeImage::readbitmapFfmpeg(mega::FileAccess*, mega::LocalPath const&, int))

ld: error: undefined symbol: avcodec_alloc_context3
>>> referenced by freeimage.cpp:248 (mega/src/gfx/freeimage.cpp:248)
>>>               freeimage.o:(mega::GfxProcFreeImage::readbitmapFfmpeg(mega::FileAccess*, mega::LocalPath const&, int))

ld: error: undefined symbol: avcodec_parameters_to_context
>>> referenced by freeimage.cpp:250 (mega/src/gfx/freeimage.cpp:250)
>>>               freeimage.o:(mega::GfxProcFreeImage::readbitmapFfmpeg(mega::FileAccess*, mega::LocalPath const&, int))

ld: error: undefined symbol: sws_getContext
>>> referenced by freeimage.cpp:265 (mega/src/gfx/freeimage.cpp:265)
>>>               freeimage.o:(mega::GfxProcFreeImage::readbitmapFfmpeg(mega::FileAccess*, mega::LocalPath const&, int))

ld: error: undefined symbol: avcodec_open2
>>> referenced by freeimage.cpp:276 (mega/src/gfx/freeimage.cpp:276)
>>>               freeimage.o:(mega::GfxProcFreeImage::readbitmapFfmpeg(mega::FileAccess*, mega::LocalPath const&, int))

ld: error: undefined symbol: av_frame_alloc
>>> referenced by freeimage.cpp:283 (mega/src/gfx/freeimage.cpp:283)
>>>               freeimage.o:(mega::GfxProcFreeImage::readbitmapFfmpeg(mega::FileAccess*, mega::LocalPath const&, int))
>>> referenced by freeimage.cpp:286 (mega/src/gfx/freeimage.cpp:286)
>>>               freeimage.o:(mega::GfxProcFreeImage::readbitmapFfmpeg(mega::FileAccess*, mega::LocalPath const&, int))

ld: error: undefined symbol: av_image_alloc
>>> referenced by freeimage.cpp:298 (mega/src/gfx/freeimage.cpp:298)
>>>               freeimage.o:(mega::GfxProcFreeImage::readbitmapFfmpeg(mega::FileAccess*, mega::LocalPath const&, int))

ld: error: undefined symbol: av_get_time_base_q()
>>> referenced by freeimage.cpp:317 (mega/src/gfx/freeimage.cpp:317)
>>>               freeimage.o:(mega::GfxProcFreeImage::readbitmapFfmpeg(mega::FileAccess*, mega::LocalPath const&, int))

ld: error: undefined symbol: av_rescale_q(long, AVRational, AVRational)
>>> referenced by freeimage.cpp:317 (mega/src/gfx/freeimage.cpp:317)
>>>               freeimage.o:(mega::GfxProcFreeImage::readbitmapFfmpeg(mega::FileAccess*, mega::LocalPath const&, int))

ld: error: undefined symbol: avformat_close_input
>>> referenced by freeimage.cpp:171 (mega/src/gfx/freeimage.cpp:171)
>>>               freeimage.o:(mega::GfxProcFreeImage::readbitmapFfmpeg(mega::FileAccess*, mega::LocalPath const&, int))
>>> referenced by freeimage.cpp:171 (mega/src/gfx/freeimage.cpp:171)
>>>               freeimage.o:(mega::GfxProcFreeImage::readbitmapFfmpeg(mega::FileAccess*, mega::LocalPath const&, int))

ld: error: undefined symbol: av_seek_frame
>>> referenced by freeimage.cpp:323 (mega/src/gfx/freeimage.cpp:323)
>>>               freeimage.o:(mega::GfxProcFreeImage::readbitmapFfmpeg(mega::FileAccess*, mega::LocalPath const&, int))

ld: error: undefined symbol: av_init_packet
>>> referenced by freeimage.cpp:330 (mega/src/gfx/freeimage.cpp:330)
>>>               freeimage.o:(mega::GfxProcFreeImage::readbitmapFfmpeg(mega::FileAccess*, mega::LocalPath const&, int))

ld: error: undefined symbol: av_read_frame
>>> referenced by freeimage.cpp:339 (mega/src/gfx/freeimage.cpp:339)
>>>               freeimage.o:(mega::GfxProcFreeImage::readbitmapFfmpeg(mega::FileAccess*, mega::LocalPath const&, int))

ld: error: undefined symbol: avcodec_send_packet
>>> referenced by freeimage.cpp:343 (mega/src/gfx/freeimage.cpp:343)
>>>               freeimage.o:(mega::GfxProcFreeImage::readbitmapFfmpeg(mega::FileAccess*, mega::LocalPath const&, int))

ld: error: undefined symbol: avcodec_receive_frame
>>> referenced by freeimage.cpp:349 (mega/src/gfx/freeimage.cpp:349)
>>>               freeimage.o:(mega::GfxProcFreeImage::readbitmapFfmpeg(mega::FileAccess*, mega::LocalPath const&, int))

ld: error: undefined symbol: sws_scale
>>> referenced by freeimage.cpp:357 (mega/src/gfx/freeimage.cpp:357)
>>>               freeimage.o:(mega::GfxProcFreeImage::readbitmapFfmpeg(mega::FileAccess*, mega::LocalPath const&, int))

ld: error: undefined symbol: av_image_get_buffer_size
>>> referenced by freeimage.cpp:363 (mega/src/gfx/freeimage.cpp:363)
>>>               freeimage.o:(mega::GfxProcFreeImage::readbitmapFfmpeg(mega::FileAccess*, mega::LocalPath const&, int))

ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error code 1
 
The problem is here. If I removed #include <libavutil/imgutils.h> or #include <libswscale/swscale.h>, a complaint of undeclared identifier related to these 2 headers will be displayed. But if I add them back, ld: error: undefined symbol appears despite the headers are already included. Any idea?

C++:
extern "C" {
#ifdef _WIN32
#pragma warning(disable:4996)
#pragma warning(push)
#pragma warning(disable:4242)
#pragma warning(disable:4244)
#endif
#include <libavutil/imgutils.h>
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libswscale/swscale.h>
#include <libavutil/avutil.h>
#include <libavutil/mathematics.h>
#include <libavutil/display.h>
#ifdef _WIN32
#pragma warning(pop)
#endif
}
 
Thanks. Get it complied but with segmentation fault.
Will need to check the code again when I am available.
 
From the log, its most likely caused by the required library files are not in the path that the complied megasync needs. But despite this, the complied megasync is still strange since its size is 176MB.
 

Attachments

  • test.txt
    419.5 KB · Views: 113
From the log, its most likely caused by the required library files are not in the path that the complied megasync needs. But despite this, the complied megasync is still strange since its size is 176MB.
As far I've see the log, there's lots of dependencies missing such as multimedia/libmediainfo, devel/libuv, multimedia/libzen, and the list goes on. Are you sure all deps are there? Maybe the Arch Linux's AUR can help with that (configure options and dependencies). AUR also have a version without pdfium, which is probably the best option.
 
Unless you want some specific functionality with MEGAsync, remember rclone can mount and sync MEGA folders as well ;)

Doesn´t work as expected for mega, it works at some point but there´s many other issues like timeout, lag, etc. Being there, done that.
Actually the best choices for sync with mega is:
net/megatools : Works fine, but have some issues like lag and you don´t have a proper daemon for that (you can use a cron and a script, of course).
net/megacmd : It´s the official mega solution, works exactly the same but without a fancy GUI like megasync. There´s a daemon that runs in background. Have is own issues like lag in different scenarios, etc.

Another problem with using rclone with the MEGA backend is that it fails to login if your MEGA password contains special characters.
 
Back
Top