Compiling trunk

Moderator: Telldus

Post Reply
jstrom
Posts: 36
Joined: Fri Mar 17, 2023 9:45 am

Compiling trunk

Post by jstrom »

Howdy!

Just fetched a fresh trunk, trying to compile on FreeBSD 8.2. Unfortunately it seems to have some problems. After 'cmake .&& make' it gets stuck on linking tdtool:
back-1 ~/telldus/telldus-core$ make VERBOSE=1
/usr/local/bin/cmake -H/home/johan/telldus/telldus-core -B/home/johan/telldus/telldus-core --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/bin/cmake -E cmake_progress_start /home/johan/telldus/telldus-core/CMakeFiles /home/johan/telldus/telldus-core/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make -f driver/libtelldus-core/CMakeFiles/telldus-core-lib.dir/build.make driver/libtelldus-core/CMakeFiles/telldus-core-lib.dir/depend
cd /home/johan/telldus/telldus-core && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /home/johan/telldus/telldus-core /home/johan/telldus/telldus-core/driver/libtelldus-core /home/johan/telldus/telldus-core /home/johan/telldus/telldus-core/driver/libtelldus-core /home/johan/telldus/telldus-core/driver/libtelldus-core/CMakeFiles/telldus-core-lib.dir/DependInfo.cmake --color=
make -f driver/libtelldus-core/CMakeFiles/telldus-core-lib.dir/build.make driver/libtelldus-core/CMakeFiles/telldus-core-lib.dir/build
/usr/local/bin/cmake -E cmake_progress_report /home/johan/telldus/telldus-core/CMakeFiles 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
[ 57%] Built target telldus-core-lib
make -f telldus-service/service/CMakeFiles/telldusd.dir/build.make telldus-service/service/CMakeFiles/telldusd.dir/depend
cd /home/johan/telldus/telldus-core && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /home/johan/telldus/telldus-core /home/johan/telldus/telldus-core/telldus-service/service /home/johan/telldus/telldus-core /home/johan/telldus/telldus-core/telldus-service/service /home/johan/telldus/telldus-core/telldus-service/service/CMakeFiles/telldusd.dir/DependInfo.cmake --color=
make -f telldus-service/service/CMakeFiles/telldusd.dir/build.make telldus-service/service/CMakeFiles/telldusd.dir/build
/usr/local/bin/cmake -E cmake_progress_report /home/johan/telldus/telldus-core/CMakeFiles 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
[ 97%] Built target telldusd
make -f tdtool/CMakeFiles/tdtool.dir/build.make tdtool/CMakeFiles/tdtool.dir/depend
cd /home/johan/telldus/telldus-core && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /home/johan/telldus/telldus-core /home/johan/telldus/telldus-core/tdtool /home/johan/telldus/telldus-core /home/johan/telldus/telldus-core/tdtool /home/johan/telldus/telldus-core/tdtool/CMakeFiles/tdtool.dir/DependInfo.cmake --color=
make -f tdtool/CMakeFiles/tdtool.dir/build.make tdtool/CMakeFiles/tdtool.dir/build
Linking CXX executable tdtool
cd /home/johan/telldus/telldus-core/tdtool && /usr/local/bin/cmake -E cmake_link_script CMakeFiles/tdtool.dir/link.txt --verbose=1
/usr/bin/c++ CMakeFiles/tdtool.dir/main.cpp.o -o tdtool -L/usr/local/lib -ltelldus-core -Wl,-rpath,/usr/local/lib:
/usr/bin/ld: cannot find -ltelldus-core
*** Error code 1
So.. Trying to link, with the telldus-core library, but no library path set pointing to the just built library? Or rather, there isn't even a .so file built, no .so-files whatsoever! The static lib is there though (driver/libtelldus-core/libtelldus-core-lib.a).

Looking closer at driver for a shared lib:
back-1 ~/telldus/telldus-core/driver$ make clean
back-1 ~/telldus/telldus-core/driver$ make
[ 4%] Building CXX object driver/libtelldus-core/CMakeFiles/telldus-core-lib.dir/Device.cpp.o
[ 9%] Building CXX object driver/libtelldus-core/CMakeFiles/telldus-core-lib.dir/DeviceBrateck.cpp.o
[ 13%] Building CXX object driver/libtelldus-core/CMakeFiles/telldus-core-lib.dir/DeviceEverflourish.cpp.o
...
[100%] Building CXX object driver/libtelldus-core/CMakeFiles/telldus-core-lib.dir/linux/Device.cpp.o
Linking CXX static library libtelldus-core-lib.a
[100%] Built target telldus-core-lib
Don't know if a shared lib is supposed to be built though.
So, should it use a shared or a static library, and what modifications is required to make it build?

Thanks!
micke.prag
Site Admin
Posts: 2243
Joined: Fri Mar 17, 2023 9:45 am
Location: Lund
Contact:

Re: Compiling trunk

Post by micke.prag »

Don't build from trunk. That is unstable code (and for the moment not working).

Latest stable: http://download.telldus.se/TellStick/So ... 0.4.tar.gz
Latest (working) unstable: http://download.telldus.se/TellStick/So ... 103.tar.gz
Micke Prag
Software
Telldus Technologies
jstrom
Posts: 36
Joined: Fri Mar 17, 2023 9:45 am

Re: Compiling trunk

Post by jstrom »

No, taking trunk for granted is ofcourse not recommended. Just looked like an odd error to have been introduced by the last few commits I've looked at. Anyhow, neither of those you pointed to are working out of the box.

2.0.4 fails finding confuse.h
[ 4%] Building CXX object driver/libtelldus-core/CMakeFiles/telldus-core.dir/SettingsConfuse.cpp.o
/home/johan/telldus-core-2.0.4/driver/libtelldus-core/SettingsConfuse.cpp:13:21: error: confuse.h: No such file or directory
/home/johan/telldus-core-2.0.4/driver/libtelldus-core/SettingsConfuse.cpp:21: error: ISO C++ forbids declaration of 'cfg_t' with no
libconfuse-2.7 is installed:
~/telldus-core-2.0.4$ file /usr/local/include/confuse.h
/usr/local/include/confuse.h: ASCII C program text

2.0.103 fails on casting problems instead:
back-1 ~/telldus-core-2.0.103$ make
Scanning dependencies of target telldus-common
[ 2%] Building CXX object common/CMakeFiles/telldus-common.dir/Message.cpp.o
[ 5%] Building CXX object common/CMakeFiles/telldus-common.dir/Mutex.cpp.o
In file included from /home/johan/telldus-core-2.0.103/common/Mutex.cpp:14:
/home/johan/telldus-core-2.0.103/common/common.h: In function 'void debuglog(int, std::string)':
/home/johan/telldus-core-2.0.103/common/common.h:48: error: cast from 'pthread*' to 'int' loses precision
*** Error code 1

So no luck there either.. ;)
micke.prag
Site Admin
Posts: 2243
Joined: Fri Mar 17, 2023 9:45 am
Location: Lund
Contact:

Re: Compiling trunk

Post by micke.prag »

2.0.4:
Set enviroment variable CMAKE_INCLUDE_PATH to /usr/local/include might help cmake find libconfuse?

2.0.103:
Comment out the function body in debuglog() in common.h. Or even better, add an ifdef for FreeBSD.
Micke Prag
Software
Telldus Technologies
jstrom
Posts: 36
Joined: Fri Mar 17, 2023 9:45 am

Re: Compiling trunk

Post by jstrom »

Hm regarding 2.0.4, cannot really get it to use CMAKE_INCLUDE_PATH=/usr/local/include.. According to manual it is said to be an environment variable, although doesn't seem like is used. I've tried the following:
env CMAKE_INCLUDE_PATH=/usr/local/include cmake .
env CMAKE_INCLUDE_PATH=/usr/local/include make
cmake CMAKE_INCLUDE_PATH=/usr/local/include .
cmake -DCMAKE_INCLUDE_PATH=/usr/local/include .
make CMAKE_INCLUDE_PATH=/usr/local/include
without any success.. Any hints? Doesn't seem to use it all in any combination.

UPDATE:

OK, so I got 2.0.4 working by applying an old patch I've submitted earlier to you:
diff --git a/telldus-core/CMakeLists.txt b/telldus-core/CMakeLists.txt
index 0b09183..330263e 100644
--- a/telldus-core/CMakeLists.txt
+++ b/telldus-core/CMakeLists.txt
@@ -2,6 +2,11 @@ PROJECT( telldus-core )

CMAKE_MINIMUM_REQUIRED( VERSION 2.6.0 )

+IF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+ INCLUDE_DIRECTORIES(/usr/local/include)
+ LINK_DIRECTORIES(/usr/local/lib)
+ENDIF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+
cmake_policy(SET CMP0003 NEW)

SET(PACKAGE_VERSION 2.0.0)
Judging from that, that was against 2.0.0, did that get lost on the road? Anyhow, that makes the above compile. However it doesn't seem to find the tellstick, I'll look closer at that..
I'll look into getting the newer version to work aswell.
micke.prag
Site Admin
Posts: 2243
Joined: Fri Mar 17, 2023 9:45 am
Location: Lund
Contact:

Re: Compiling trunk

Post by micke.prag »

Yes, seems like it is lost. I will add it again.

Btw, 2.0.4 needs a serial device under /dev and 2.0.103 uses libftdi to access TellStick. I don't know which suits FreeBSD best?
Micke Prag
Software
Telldus Technologies
jstrom
Posts: 36
Joined: Fri Mar 17, 2023 9:45 am

Re: Compiling trunk

Post by jstrom »

Good evening!

OK, so now I got everything up and running. I tried to attached a patch containing the fixes, however failed to attach it.. Extension not allowed it claims, regardless of what extension I try.. Uploaded it here instead: http://stromnet.se/~johan/telldus-003-f ... ixes.patch
I've tested basic tdOn/tdOff with a regular Tellstick and it seems to work fine! Even succeeded some perl hackering sending cmds directly to the unix socket.. ;) Is that an "accepted" way of integrating with telldusd? Much easier than writing a perl/C-bridge, and also much easier (I'd guess?) to integrate into event-loops.

Some comments on the patched files:

CMakeLists.txt - The include paths updated
tdadmin/CMakeLists.txt - added argp as a library; on FreeBSD argp is not included in base libc, so user explicitly have to install devel/argp-standalone. Don't know if this can be written better so cmake tests for existance etc?
tdadmin/main.cpp - error.h wasn't found, but errno.h seems to do fine. Does errno.h work equally fine on Linux?
common/common.h - pthread_t is defined as an opaque type. For FreeBSD it is a struct, so casting to int fails.
service/main_unix.cpp - If we failed to open pid-file (ie runnig as non-root), we didnt abort and instead crashed when trying to fwritef() on the dead FD. errno.h added for 'errno' variable. Also changed LOG_INFO to LOG_NOTICE, on FreeBSD LOG_INFO is not written to /var/log/messages, so generally one never saw the messages => harder to debug.

If you want me to test out trunk in FreeBSD, let me know what could be done to continue!

Regarding the device, I'm not really sure, but libftdi works fine. There is a ugen device (dmesg: ugen0.2: <Telldus> at usbus0), but how it can be used I have no idea. Let me know if you'd like me to test something out!
micke.prag
Site Admin
Posts: 2243
Joined: Fri Mar 17, 2023 9:45 am
Location: Lund
Contact:

Re: Compiling trunk

Post by micke.prag »

Thank you very much. I will integrate this into trunk. It will not make it into 2.0.104 (already tagged) but I can export a fresh package from trunk if you are interested?
Micke Prag
Software
Telldus Technologies
jstrom
Posts: 36
Joined: Fri Mar 17, 2023 9:45 am

Re: Compiling trunk

Post by jstrom »

You're welcome! Sure, export a new package and I'll verify that it works as well. But if it is from the current trunk then I guess it will have the same problems as plain trunk I had originally, ie not finding the library (no shared lib built).
Although I skimmed through trunk vs 2.0.103 yesterday, and it looked like there where major differences (something which would warrant a larger version change than patch-rev 103->104), am I looking at the 'wrong trunk' somehow? Cannot see the tagged 2.0.104 either, do you have an internal svn or something? The one I'm using is the same as trac shows, ie http://developer.telldus.se/browser.
Let me know how to move on and I'll be happy to give it a shot!
micke.prag
Site Admin
Posts: 2243
Joined: Fri Mar 17, 2023 9:45 am
Location: Lund
Contact:

Re: Compiling trunk

Post by micke.prag »

Yes, you are right. After we released 2.0.102 we decided start over from scratch. 2.0.103 is a complete rewrite and the code is in our private repository for now. It will be public again when we release 2.1.

Btw, we will treat 2.0.104 as a release candidate. So 2.1 is close...
Micke Prag
Software
Telldus Technologies
jstrom
Posts: 36
Joined: Fri Mar 17, 2023 9:45 am

Re: Compiling trunk

Post by jstrom »

Okay, as I suspected then :) I got to say the new stuff looks better, so good work!

Let me know where I can find 2.0.104 and I'll test it out!
micke.prag
Site Admin
Posts: 2243
Joined: Fri Mar 17, 2023 9:45 am
Location: Lund
Contact:

Re: Compiling trunk

Post by micke.prag »

I have now integrated you patch and also fixed some other issues on FreeBSD (installed it on a VirtualBox). I have only verified it builds without errors and warnings. Not tested that it actually works...

Some general considerations when porting the software to a new platform:
  • We are now using libftdi instead of relying on a kernel driver. This makes is a lot easier to port to a new platform since no kernel driver is needed and libftdi only depends on libusb
  • 2.0 only contained a library. In 2.1 we now have a daemon running as well called telldusd on unix platforms
  • The deamon don't want to run as root. Make sure it have the proper permissions to access the usb-device. It defaults to run as user "nobody" and group "plugdev" but this can be changed in /etc/tellstick.conf. If telldusd don't have proper permissions you will get a "TellStick not found" error.
  • telldusd needs to beware when a new TellStick is plugged in. Windows and Mac OS X detects this automatically. But under Unix we use the tool tdadmin to tell the deamon about a new device. Our default implementation (Linux) uses an udev rule for this. Udev is not always available so some other system might need to be integrated. Examples: hotplug, hald and devd
Micke Prag
Software
Telldus Technologies
jstrom
Posts: 36
Joined: Fri Mar 17, 2023 9:45 am

Re: Compiling trunk

Post by jstrom »

Builds fine, no warnings and no errors! And seems to work fine aswell. Didn't have a /dev/tellstick at first, so I was a bit confused, telldusd itself never said anything in the logs about finding anything or not (so that might be worth lookin into, for *nix-ers /var/log/messages is the natural place to look for such info). Although found out later that tdtool told me so.. :) Anyway, creating symlink from ugen0.2 to tellstick, restarting and it worked like a charm. I think you can use devd somehow, will look closer at that when I get some more time (probably not in a week).
Post Reply