Previous fails to build on F25 (Fedora)

Started by tingo, June 29, 2017, 06:45:48 am

Previous topic - Next topic

tingo

A week ago I learned about Previous. So I tried to build it on my laptop, which is running Fedora 25

[tingo@kg-elitebook ~]$ cat /etc/fedora-release
Fedora release 25 (Twenty Five)
[tingo@kg-elitebook ~]$ uname -a
Linux kg-elitebook.kg4.no 4.11.5-200.fc25.x86_64 #1 SMP Wed Jun 14 17:17:29 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

I checked out the latest version from the repository:

[tingo@kg-elitebook previous-code]$ svn info
Path: .
Working Copy Root Path: /zs/tingo/work/previous/previous-code
URL: svn://svn.code.sf.net/p/previous/code/branches/branch_realtime
Relative URL: ^/branches/branch_realtime
Repository Root: svn://svn.code.sf.net/p/previous/code
Repository UUID: 9ba66e4b-2233-44b8-a46a-7e93b2105c9e
Revision: 823
Node Kind: directory
Schedule: normal
Last Changed Author: andreas-g1
Last Changed Rev: 791
Last Changed Date: 2017-05-01 10:09:25 +0200 (Mon, 01 May 2017)

but when I try to build it, it fails:

[tingo@kg-elitebook previous-code]$ mkdir -p build
[tingo@kg-elitebook previous-code]$ cd build
[tingo@kg-elitebook build]$ cmake ..
[...]
-- Build files have been written to: /zs/tingo/work/previous/previous-code/build

[tingo@kg-elitebook build]$ make
Scanning dependencies of target Slirp
[  1%] Building C object src/slirp/CMakeFiles/Slirp.dir/bootp.c.o
In file included from /usr/include/string.h:630:0,
                from /usr/include/sys/un.h:37,
                from /zs/tingo/work/previous/previous-code/src/slirp/slirp.h:162,
                from /zs/tingo/work/previous/previous-code/src/slirp/bootp.c:24:
/zs/tingo/work/previous/previous-code/src/slirp/misc.h:27:7: error: expected identifier or '(' before '__extension__'
char *strdup(const char *);
      ^
src/slirp/CMakeFiles/Slirp.dir/build.make:62: recipe for target 'src/slirp/CMakeFiles/Slirp.dir/bootp.c.o' failed
make[2]: *** [src/slirp/CMakeFiles/Slirp.dir/bootp.c.o] Error 1
CMakeFiles/Makefile2:607: recipe for target 'src/slirp/CMakeFiles/Slirp.dir/all' failed
make[1]: *** [src/slirp/CMakeFiles/Slirp.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

Also, trying to build via ./configure doesn't help:

[tingo@kg-elitebook previous-code]$ ./configure
[...]
-- Build files have been written to: /zs/tingo/work/previous/previous-code

[tingo@kg-elitebook previous-code]$ make
Scanning dependencies of target Slirp
[  1%] Building C object src/slirp/CMakeFiles/Slirp.dir/bootp.c.o
In file included from /usr/include/string.h:630:0,
                from /usr/include/sys/un.h:37,
                from /zs/tingo/work/previous/previous-code/src/slirp/slirp.h:162,
                from /zs/tingo/work/previous/previous-code/src/slirp/bootp.c:24:
/zs/tingo/work/previous/previous-code/src/slirp/misc.h:27:7: error: expected identifier or '(' before '__extension__'
char *strdup(const char *);
      ^
src/slirp/CMakeFiles/Slirp.dir/build.make:62: recipe for target 'src/slirp/CMakeFiles/Slirp.dir/bootp.c.o' failed
make[2]: *** [src/slirp/CMakeFiles/Slirp.dir/bootp.c.o] Error 1
CMakeFiles/Makefile2:607: recipe for target 'src/slirp/CMakeFiles/Slirp.dir/all' failed
make[1]: *** [src/slirp/CMakeFiles/Slirp.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

I wasn't expecting it too, just trying all options.
Any idea on how to fix this?

tingo

FWIW, it fails in the same place on Debian 9:

bitraf@desktop-41nl8sd:~/work/previous/previous-code/build$ cat /etc/debian_version
9.0
bitraf@desktop-41nl8sd:~/work/previous/previous-code/build$ uname -a
Linux desktop-41nl8sd 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u1 (2017-06-18) x86_64 GNU/Linux

andreas_g

Hello tingo!

As a quick fix try to comment the affected line:

// char *strdup(const char *);

I hope this solves it. There might be some more problems of this kind in the SLiRP code.

tingo

Yep, that fixed it, now it builds.
It seems like the HAVE_STRDUP define isn't defined on Fedora and Debian, for some reason.
Commented out in misc.h

#ifndef HAVE_STRDUP
// char *strdup(const char *);
#endif


and misc.c

#ifndef HAVE_STRDUP
/* char *strdup(const char *str)
{
char *bptr;

bptr = (char *)malloc(strlen(str)+1);
strcpy(bptr, str);

return bptr;
}
*/
#endif

Thanks!
--
Torfinn

andreas_g

I'm glad it worked! But we should find a proper patch for that. It seems there is something missing for CMake. Please try adding this line to CMakeLists.txt (the one in the lowest directory under topic "Check for optional functions") using a fresh copy of the sources and check if it compiles without further modifications:

check_function_exists(strdup HAVE_STRDUP)

tingo

I patched CMakeLists.txt as suggested

[tingo@kg-elitebook previous-code]$ grep STRDUP CMakeLists.txt
check_function_exists(strdup HAVE_STRDUP)

and Prevoius now builds (and works). Thanks!

andreas_g

Thank you for testing! This will be added to the next release of Previous (coming soon!).