blob: 36c3c597ac6d39f36d754916ff0f1a108a8214bf [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001From e3fa241637ab5a7fa78c0d474802134cff75f91e Mon Sep 17 00:00:00 2001
Brad Bishop26bdd442019-08-16 17:08:17 -04002From: Martin Jansa <Martin.Jansa@gmail.com>
3Date: Fri, 28 Jun 2019 13:50:52 +0000
4Subject: [PATCH] examples/Makefile: respect CXX,LDFLAGS variables, fix build
5 with gold
6
7* move pkg-config call to separate variable, so that the final version
8 of the whole command so it's shown in log.do_compile_ptest_base
9* add ../src/google/protobuf/.libs/timestamp.pb.o when linking
10 add_person_cpp otherwise it fails to link with gold:
11 i686-oe-linux-g++ -m32 -march=core2 -mtune=core2 -msse3 -mfpmath=sse --sysroot=core2-32-oe-linux/protobuf/3.8.0-r0/recipe-sysroot -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf`
12 /tmp/cccjSJQs.o:addressbook.pb.cc:scc_info_Person_addressbook_2eproto: error: undefined reference to 'scc_info_Timestamp_google_2fprotobuf_2ftimestamp_2eproto'
13 /tmp/cccjSJQs.o:addressbook.pb.cc:descriptor_table_addressbook_2eproto_deps: error: undefined reference to 'descriptor_table_google_2fprotobuf_2ftimestamp_2eproto'
14 collect2: error: ld returned 1 exit status
15 Makefile:43: recipe for target 'add_person_cpp' failed
16
17* and the same with list_people_cpp this time with pkg-config already through the variable:
18 i686-oe-linux-g++ -m32 -march=core2 -mtune=core2 -msse3 -mfpmath=sse --sysroot=core2-32-oe-linux/protobuf/3.8.0-r0/recipe-sysroot -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -pthread -Icore2-32-oe-linux/protobuf/3.8.0-r0/git/src -Lcore2-32-oe-linux/protobuf/3.8.0-r0/git/src/.libs -Lcore2-32-oe-linux/protobuf/3.8.0-r0/recipe-sysroot/usr/lib -lprotobuf list_people.cc addressbook.pb.cc -o list_people_cpp
19 /tmp/ccpaI5Su.o:addressbook.pb.cc:scc_info_Person_addressbook_2eproto: error: undefined reference to 'scc_info_Timestamp_google_2fprotobuf_2ftimestamp_2eproto'
20 /tmp/ccpaI5Su.o:addressbook.pb.cc:descriptor_table_addressbook_2eproto_deps: error: undefined reference to 'descriptor_table_google_2fprotobuf_2ftimestamp_2eproto'
21 collect2: error: ld returned 1 exit status
22 Makefile:49: recipe for target 'list_people_cpp' failed
23
24Upstream-Status: Pending
25Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Andrew Geisslerc87764f2020-06-27 00:16:32 -050026Signed-off-by: Leon Anavi <leon.anavi@konsulko.com>
Patrick Williams92b42cb2022-09-03 06:53:57 -050027
Brad Bishop26bdd442019-08-16 17:08:17 -040028---
29 examples/Makefile | 6 ++++--
30 1 file changed, 4 insertions(+), 2 deletions(-)
31
32diff --git a/examples/Makefile b/examples/Makefile
Patrick Williams92b42cb2022-09-03 06:53:57 -050033index 1c7ec8d63..85f591231 100644
Brad Bishop26bdd442019-08-16 17:08:17 -040034--- a/examples/Makefile
35+++ b/examples/Makefile
36@@ -2,6 +2,8 @@
37
38 .PHONY: all cpp java python clean
39
40+PROTOBUF := $(shell pkg-config --cflags --libs protobuf)
41+
42 all: cpp java python
43
44 cpp: add_person_cpp list_people_cpp
Patrick Williams92b42cb2022-09-03 06:53:57 -050045@@ -40,11 +42,11 @@ protoc_middleman_dart: addressbook.proto
Brad Bishop26bdd442019-08-16 17:08:17 -040046
47 add_person_cpp: add_person.cc protoc_middleman
48 pkg-config --cflags protobuf # fails if protobuf is not installed
Andrew Geisslerc87764f2020-06-27 00:16:32 -050049- c++ -std=c++11 add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf`
Brad Bishop26bdd442019-08-16 17:08:17 -040050+ $(CXX) $(CXXFLAGS) $(LDFLAGS) ../src/google/protobuf/.libs/timestamp.pb.o $(PROTOBUF) add_person.cc addressbook.pb.cc -o add_person_cpp
51
52 list_people_cpp: list_people.cc protoc_middleman
53 pkg-config --cflags protobuf # fails if protobuf is not installed
Andrew Geisslerc87764f2020-06-27 00:16:32 -050054- c++ -std=c++11 list_people.cc addressbook.pb.cc -o list_people_cpp `pkg-config --cflags --libs protobuf`
Brad Bishop26bdd442019-08-16 17:08:17 -040055+ $(CXX) $(CXXFLAGS) $(LDFLAGS) ../src/google/protobuf/.libs/timestamp.pb.o $(PROTOBUF) list_people.cc addressbook.pb.cc -o list_people_cpp
56
57 add_person_dart: add_person.dart protoc_middleman_dart
58