Date: Wed, 21 Mar 2001 23:21:51 -0800 (PST) From: cbond@twistedcircus.org To: FreeBSD-gnats-submit@freebsd.org Subject: misc/25984: bsd.prog.mk doesn't link C++ programs properly Message-ID: <200103220721.f2M7Lp903660@muscle.twistedcircus.org>
next in thread | raw e-mail | index | archive | help
>Number: 25984
>Category: misc
>Synopsis: bsd.prog.mk doesn't link C++ programs properly
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Wed Mar 21 23:30:02 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Chris L. Bond
>Release: FreeBSD 4.3-BETA i386
>Organization:
None
>Environment:
>Description:
bsd.prog.mk from /usr/share/mk/ doesn't properly link programs with C++ source
files against -lstdc++ as it should. The majority of C++ programs hence fail to
build.
>How-To-Repeat:
Construct a Makefile in the standard bsd.prog.mk format and include C++ files in
the $SRCS variable (.cc, .C, .cxx, etc.). Be sure to use a piece of the
C++ standard library in your code (e.g., iostreams).
>Fix:
--- /usr/src/share/mk/bsd.prog.mk.orig Wed Mar 21 22:30:10 2001
+++ /usr/src/share/mk/bsd.prog.mk Wed Mar 21 23:18:52 2001
@@ -27,10 +27,14 @@
.if defined(PROG)
.if defined(SRCS)
-# If there are Objective C sources, link with Objective C libraries.
+# If there are Objective C or C++ sources, link with appropriate libraries.
.if ${SRCS:M*.m} != ""
OBJCLIBS?= -lobjc
LDADD+= ${OBJCLIBS}
+.endif
+.if ${SRCS:C/\.(cc\$|C\$|cxx\$|cpp\$)//} != ${SRCS}
+CXXLIBS?= -lstdc++
+LDADD+= ${CXXLIBS}
.endif
OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200103220721.f2M7Lp903660>
