Bug 214475 - audio/cmus: fails to build with ncurses from ports
Summary: audio/cmus: fails to build with ncurses from ports
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Tobias Kortkamp
Keywords: easy, needs-qa, patch
Depends on: 216325
  Show dependency treegraph
Reported: 2016-11-13 14:05 UTC by Oleh Hushchenkov
Modified: 2017-04-10 13:28 UTC (History)
3 users (show)

See Also:
tobik: maintainer-feedback+
koobs: merge-quarterly?

build log (9.70 KB, text/x-log)
2016-11-13 14:05 UTC, Oleh Hushchenkov
no flags Details
cmus.diff (1.69 KB, patch)
2016-11-13 14:33 UTC, Tobias Kortkamp
tobik: maintainer-approval-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Oleh Hushchenkov 2016-11-13 14:05:18 UTC
Created attachment 176954 [details]
build log

If ncurses from ports installed, cmus trying to linked against them but compile failed.

1. Configure script detect that strndup function is supported by system.

2. Ncurses cflags:

-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -I/usr/local/include/ncurses/ncurses

passed to cmus build flags.

3. Redefine _POSIX_C_SOURCE as 200112 hiding strndup function in string.h

102 #if __POSIX_VISIBLE >= 200809
103 char    *strndup(const char *, size_t) __malloc_like;
104 size_t   strnlen(const char *, size_t) __pure;
105 #endif

4. Compile failed

error: implicitly declaring library function 'strndup' with type 'char *(const char *, unsigned long)'
Comment 1 Tobias Kortkamp freebsd_committer 2016-11-13 14:33:01 UTC
Created attachment 176956 [details]

Interesting, thank you for the detailed report.  The attached patch should allow you to build cmus.  Though I'm not sure how to fix this in a proper way.

I also found that cmus tries to use git during the build when it's installed... The patch should prevent this too.
Comment 2 Oleh Hushchenkov 2016-11-13 14:41:29 UTC

I build cmus by commenting line 515 in configure script

#check_string_function "strndup" && HAVE_STRNDUP=y

then cmus using own replacement of strndup function.
Comment 3 Oleh Hushchenkov 2016-11-13 14:51:04 UTC
Anyway, I think this must be fixed in ncurses port by removing



Or, maybe, replace them by


Interesting, in revision prior 265878


define __BSD_VISIBLE in cflags working fine.
Comment 4 Tobias Kortkamp freebsd_committer 2016-11-13 15:02:45 UTC
(In reply to Oleg Gushchenkov from comment #3)
Yes, I think you're right. I've asked on the ports mailing list.
Comment 5 Tobias Kortkamp freebsd_committer 2017-01-20 17:12:18 UTC
Comment on attachment 176956 [details]

The update to cmus 2.8.0-rc0 in bug #216325 should fix this problem.
Comment 6 commit-hook freebsd_committer 2017-04-10 13:26:24 UTC
A commit references this bug:

Author: tobik
Date: Mon Apr 10 13:25:24 UTC 2017
New revision: 438165
URL: https://svnweb.freebsd.org/changeset/ports/438165

  Update to 2.8.0-rc0

  - Fix build with devel/ncurses installed [1], which erroneously
    redefines _POSIX_C_SOURCE as 200112L globally via its pkg-config
    file and hides strndup from cmus.  A workaround for this was applied
    to cmus in DPorts commit d2907fe but it never made it back to

  Changes:	https://github.com/cmus/cmus/releases/tag/v2.8.0-rc0

  PR:		216325, 214475 [1]
  Reported by:	Oleg Gushchenkov <gor@clogic.com.ua> [1]
  Approved by:	mat (mentor)
  Differential Revision:	https://reviews.freebsd.org/D10242