sourcey / libsourcey

C++14 evented IO libraries for high performance networking and media based applications
https://sourcey.com/libsourcey
GNU Lesser General Public License v2.1
1.31k stars 347 forks source link

Compiling on ArchLinux #23

Closed jpigree closed 9 years ago

jpigree commented 9 years ago

I wanted to test Pacm command tool. So I tried to compile LibSourcey on my ArchLinux. However, I keep getting compilation errors after compilation errors. I cloned the repo and followed the instructions of the "README.md" (using cmake).

I get this :

libsourcey-master/deps/libuv/src/unix/kqueue.c:31:23: erreur fatale: sys/event.h : Aucun fichier ou dossier de ce type

Basically, it says that "sys/event.h" does not exist. I think, it is because "kqueue.c" should not be compiled on linux. "sys/event.h" is present only on BSDs unix. Moreover, when I compile the libuv "0.11.25" from their site on the same machine, it works smoothly. Finally, in their project file "uv.gyp" the following lines are quite clear to me:

[ 'OS in "mac freebsd dragonflybsd openbsd netbsd".split()', {
    'sources': [ 'src/unix/kqueue.c'],
}],

I deleted the line in the "CMakeLists.txt" and it (seems to) work(s).

The next one is a syntax error:

/home/jpi/Dev/libsourcey-master/src/net/include/scy/net/socket.h:236:13: erreur: stray ‘#’ in program namespace { #include "unix/internal.h" } // uv__stream_fd

My g++ (version: g++ (GCC) 4.9.1 20140903) does not accept that. We need the "#include" at the start of the line. I cut this line in 3 and it works.

I have other errors but I think it will be too long to list them. Can I easily compile LibSourcey on a distro like ArchLinux ?

If it is pertinent, I can continue to chase those bugs and then submit a pull request. Or just switch to a distro supported or a Windows.

auscaster commented 9 years ago

@jpigree sorry for the delay I have been on holiday. Were you able to compile on ArchLinux? I would be interested in those fixes if they are available. Thanks :)

jpigree commented 9 years ago

Hey. No worries. I was not sure if my work had any relevance at all so I stopped there. I can pursue but it don't know how many more errors will I deter. If I have time to spare I will do it. Did you try to compile a recent version of libsourcey and pacm on a Linux distro ? If yes, please tell me the distro version you used so I can compare the difference between my libs/tools version and yours. Thanks.

auscaster commented 9 years ago

Thanks for your quick response! I would like for libsourcey to build on all major distros and compilers so your patch would be very very welcome. I use Ubuntu 14.04 with gcc 4.8.2 without any issues.

auscaster commented 9 years ago

I just pushed a couple of fixes which may enable you to build on ArchLinux.

Also, if you just want to use Pacm, then please try a minimal build like so:

cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DWITH_FFMPEG=OFF -DWITH_OPENCV=OFF -DWITH_WEBRTC=OFF -DWITH_WXWIDGETS=OFF -DWITH_RTAUDIO=OFF
jpigree commented 9 years ago

Okay. Thanks. I pulled your fixes and compiled with the flags you said and it worked great. So very excited, I tried to compile pacm straight away but it didn't.

I made several attempts to compile it alone but when looking at the root CMakeLists.txt, it is clearly meant to be compiled from within LibSourcey. So, I just added it into libsourcey/src into LibSourcey source code and it nearly worked.

I got this error :

 from libsourcey/src/pacm/src/packagemanager.cpp:19:
 libsourcey/src/pacm/include/scy/pacm/config.h:42:2: erreur: #error "Unknown platform"

It is because LINUX is not defined. If I correct this, I got errors like these :

/libsourcey/src/pacm/src/package.cpp:267:21: erreur: ambiguous overload for ‘operator[]’ (operand types are ‘scy::json::Value {aka Json::Value}’ and ‘size_t {aka long unsigned int}’)
  return Asset(assets[index]);

I stopped there for today. If I can clear all these errors I will submit a pull request.

auscaster commented 9 years ago

LINUX is defined at base.h:53 ... doesn't ArchLinux define __linux__?

I just upgraded GCC and got the same errors. It's just a simple casting fix, but if you don't have time today I will look at it this evening sometime.

auscaster commented 9 years ago

I have fixed those pacm errors and preprocessor definitions so it should compile properly now. Please try again :)

If you get any undefined reference errors when compiling the pacmconsole binary then please compile libsourcey without applications enabled:

cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DWITH_FFMPEG=OFF -DWITH_OPENCV=OFF -DWITH_WEBRTC=OFF -DWITH_WXWIDGETS=OFF -DWITH_RTAUDIO=OFF -DBUILD_APPLICATIONS=OFF

Then once libraries have compiled enable applications again ie:

cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DWITH_FFMPEG=OFF -DWITH_OPENCV=OFF -DWITH_WEBRTC=OFF -DWITH_WXWIDGETS=OFF -DWITH_RTAUDIO=OFF -DBUILD_APPLICATIONS=ON
jpigree commented 9 years ago

Great. I followed your instructions. I have a pacm executable now. :)

I just tried the -help command right on the spot but pacm just crashed right away.

./pacm -help
terminate called after throwing an instance of 'std::runtime_error'
  what():  Filesystem error: mkdir failed: permission denied
[1]    21842 abort (core dumped)  ./pacm -help

So I tried it with elevated privileges and still it crashes :

 sudo ./pacm -help                                                                                                     
terminate called after throwing an instance of 'std::runtime_error'
  what():  Failed to open log file: /home/jpi/logs/Pacm_1420639466.log

It is just the "logs" directory it needs to be created before being called.

The "-help" finally works.

Great. I can play with it right now. Thanks for your help.