wburgers / Open-Zwave-Socket-Server

Open-Zwave Socket Server
http://willemburgers.nl/zwave/open-zwave-socket-server
9 stars 8 forks source link

Update build instructions #3

Closed syphernl closed 9 years ago

syphernl commented 9 years ago

Following your build instructions (on Ubuntu 14.04 AMD64) results in:

g++ -c -Wall -Wno-format -g -DDEBUG -I ../../src -I ../../src/command_classes/ -I ../../src/value_classes/ -I ../../src/platform/ -I ../../h/platform/unix -I ../../tinyxml/ -I ../../hidapi/hidapi/ -o Main.o Main.cpp
Main.cpp:61:27: fatal error: libwebsockets.h: No such file or directory
 #include <libwebsockets.h>
                           ^
compilation terminated.
make: *** [Main.o] Error 1

Symlinking the libwebsockets files into the src/cpp folder of open-zwave results in:

g++ -c -Wall -Wno-format -g -DDEBUG -I ../../src -I ../../src/command_classes/ -I ../../src/value_classes/ -I ../../src/platform/ -I ../../h/platform/unix -I ../../tinyxml/ -I ../../hidapi/hidapi/ -o Main.o Main.cpp
Main.cpp: In function ‘int main(int, char**)’:
Main.cpp:1058:62: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
      if(pthread_create(&thread , NULL ,  run_socket ,(void*) thread_sock2) < 0) {
                                                              ^
Main.cpp: In function ‘void* run_socket(void*)’:
Main.cpp:1229:27: error: cast from ‘void*’ to ‘int’ loses precision [-fpermissive]
  thread_sock.SetSock((int)arg);
                           ^
make: *** [Main.o] Error 1

I have also tried the distro's package (libwebsockets-dev + libwebsockets3) but this results in the same error as above.

(p.s. I am very interested in seeing what you have built with this as backend ;))

wburgers commented 9 years ago

Hi Frank,

Did you "(sudo) make install" the libwebsockets lib? If so it is pretty weird that the headers can't be found. Then symlinking into src/cpp would indeed solve this. I don't know how to reproduce this first error. Maybe it is a problem with libwebsockets?

The second error is a bit weird as well. I'll try to reproduce the error and get back to you as soon as possible.

syphernl commented 9 years ago

Hi Willem!

Did you "(sudo) make install" the libwebsockets lib? If so it is pretty weird that the headers can't be found. Then symlinking into src/cpp would indeed solve this. I don't know how to reproduce this first error. Maybe it is a problem with libwebsockets?

Ah, no. That was my fault. I assumed this was being done due to the odd mount required for actual compiling. But since the error still occurs with the pre-compiled packages (libwebsockets-dev 1.2.2-1 + libwebsockets3) it could be an an issue there.

The second error is a bit weird as well. I'll try to reproduce the error and get back to you as soon as possible. Thanks!

wburgers commented 9 years ago

Hi Frank,

Sorry that the build instructions were unclear. I want to keep the libraries as separate as possible. This makes it easier to maintain. Unfortunately, if I symlink my server into the open-zwave folder, make will not understand. (cd .. will go to the wrong folder when make is running). That is why there is a mount -bind. Libwebsockets can be completely separated from my server. I only need the header file in the right place. Hope this clears things up a bit ;-).

For the second error. I get it now, you run a 64 bit machine. The size of an int is different from a void * on 64 bit machines. Can you please test the latest committed version in the Test branch? (or click on the commit in this thread).

I hope this fixes things. If not, let me know. Then I'll make a struct to pass the value to the thread instead of giving just the pointer. There may be other problems with 64 bit. I'll create a VM to test for 64 bit as well :-).

Best regards, Willem

syphernl commented 9 years ago

Sorry that the build instructions were unclear. I want to keep the libraries as separate as possible. This makes it easier to maintain. Unfortunately, if I symlink my server into the open-zwave folder, make will not understand. (cd .. will go to the wrong folder when make is running). That is why there is a mount -bind. Libwebsockets can be completely separated from my server. I only need the header file in the right place. Hope this clears things up a bit ;-).

Check, I did notice that. Speaking of the instructions, the rbind parameter needs two dashes. At least on Ubuntu, otherwise you'll get an error. Won't hurt to advise build-essential either ;)

For the second error. I get it now, you run a 64 bit machine.

Force of habit. For now this runs in a Vagrant box but eventually it should run on a NUC/ODroid. Nevertheless not a bad idea to support 64 bit ;-)

The size of an int is different from a void * on 64 bit machines. Can you please test the latest committed version in the Test branch? (or click on the commit in this > thread).

Sure, will do!

syphernl commented 9 years ago

With the default Ubuntu package for libwebsocket I am now getting:

Main.cpp: In function ‘int open_zwaveCallback(libwebsocket_context*, libwebsocket*, libwebsocket_callback_reasons, void*, void*, size_t)’:
Main.cpp:911:42: error: ‘libwebsocket_rx_flow_allow_all_protocol’ was not declared in this scope
           libwebsockets_get_protocol(wsi));
                                          ^
make: *** [Main.o] Error 1

I'm trying the latest libwebsocket from source. It is compiled but OZSS can't find the headers.

wburgers commented 9 years ago

Hi Frank,

The Ubuntu package for libwebsockets is indeed older and does not have that function defined. I tried to install OZSS on my 64 bit VM. Everything went well. Can you rebuild libwebsockets and give the output of the make install here? That should determine where the headers are put on your system.

Here is my output:

[ 43%] Built target websockets
[ 45%] Built target test-client
[ 47%] Built target test-echo
[ 50%] Built target test-fraggle
[ 52%] Built target test-ping
[ 54%] Built target test-server
[ 56%] Built target test-server-extpoll
[100%] Built target websockets_shared
Install the project...
-- Install configuration: ""
-- Up-to-date: /usr/local/lib/pkgconfig/libwebsockets.pc
-- Up-to-date: /usr/local/lib/libwebsockets.a
-- Up-to-date: /usr/local/include/libwebsockets.h
-- Up-to-date: /usr/local/include/lws_config.h
-- Up-to-date: /usr/local/lib/libwebsockets.so.5.0.0
-- Up-to-date: /usr/local/lib/libwebsockets.so
-- Up-to-date: /usr/local/include/libwebsockets.h
-- Up-to-date: /usr/local/include/lws_config.h
-- Up-to-date: /usr/local/bin/libwebsockets-test-client
-- Up-to-date: /usr/local/bin/libwebsockets-test-server
-- Up-to-date: /usr/local/bin/libwebsockets-test-server-extpoll
-- Up-to-date: /usr/local/bin/libwebsockets-test-client
-- Up-to-date: /usr/local/bin/libwebsockets-test-fraggle
-- Up-to-date: /usr/local/bin/libwebsockets-test-ping
-- Up-to-date: /usr/local/bin/libwebsockets-test-echo
-- Up-to-date: /usr/local/share/libwebsockets-test-server/favicon.ico
-- Up-to-date: /usr/local/share/libwebsockets-test-server/leaf.jpg
-- Up-to-date: /usr/local/share/libwebsockets-test-server/libwebsockets.org-logo.png
-- Up-to-date: /usr/local/share/libwebsockets-test-server/test.html
-- Up-to-date: /usr/local/share/libwebsockets-test-server/libwebsockets-test-server.key.pem
-- Up-to-date: /usr/local/share/libwebsockets-test-server/libwebsockets-test-server.pem
-- Up-to-date: /usr/local/lib/cmake/libwebsockets/LibwebsocketsTargets.cmake
-- Up-to-date: /usr/local/lib/cmake/libwebsockets/LibwebsocketsTargets-noconfig.cmake
syphernl commented 9 years ago

Compiling both libwebsockets and OZSS (in branch test) went just fine now.

Some dependencies required to compile the whole libwebsockets:

And for OZSS:

Running ./test (after creating the config folder + copying the example in there) works.

wburgers commented 9 years ago

That is good news! libudev-dev is a dependency of open-zwave, not OZSS, but I will update the docs. with all dependencies. Thanks for the list ;-).

I mostly run my server in the root of open-zwave, so I copy the binary instead of the config folder, but either is fine.

As said, I'll update the documentation.

I'm looking forward to getting more feedback!

Best, Willem