blob: 934c9819383c912c1d7beeb1b1ee09803f7bdbc9 [file] [log] [blame]
Andrew Geisslerc87764f2020-06-27 00:16:32 -05001From e5340f816aa273cfda36998466739ca0748caafb 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>
Brad Bishop26bdd442019-08-16 17:08:17 -040027---
28 examples/Makefile | 6 ++++--
29 1 file changed, 4 insertions(+), 2 deletions(-)
30
31diff --git a/examples/Makefile b/examples/Makefile
Andrew Geisslerc87764f2020-06-27 00:16:32 -050032index e9f9635ae..b2fbe2de1 100644
Brad Bishop26bdd442019-08-16 17:08:17 -040033--- a/examples/Makefile
34+++ b/examples/Makefile
35@@ -2,6 +2,8 @@
36
37 .PHONY: all cpp java python clean
38
39+PROTOBUF := $(shell pkg-config --cflags --libs protobuf)
40+
41 all: cpp java python
42
43 cpp: add_person_cpp list_people_cpp
44@@ -41,11 +43,11 @@ protoc_middleman_dart: addressbook.proto
45
46 add_person_cpp: add_person.cc protoc_middleman
47 pkg-config --cflags protobuf # fails if protobuf is not installed
Andrew Geisslerc87764f2020-06-27 00:16:32 -050048- 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 -040049+ $(CXX) $(CXXFLAGS) $(LDFLAGS) ../src/google/protobuf/.libs/timestamp.pb.o $(PROTOBUF) add_person.cc addressbook.pb.cc -o add_person_cpp
50
51 list_people_cpp: list_people.cc protoc_middleman
52 pkg-config --cflags protobuf # fails if protobuf is not installed
Andrew Geisslerc87764f2020-06-27 00:16:32 -050053- 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 -040054+ $(CXX) $(CXXFLAGS) $(LDFLAGS) ../src/google/protobuf/.libs/timestamp.pb.o $(PROTOBUF) list_people.cc addressbook.pb.cc -o list_people_cpp
55
56 add_person_dart: add_person.dart protoc_middleman_dart
57
Andrew Geisslerc87764f2020-06-27 00:16:32 -050058--
592.17.1
60