Andrew Geissler | c87764f | 2020-06-27 00:16:32 -0500 | [diff] [blame] | 1 | From e5340f816aa273cfda36998466739ca0748caafb Mon Sep 17 00:00:00 2001 |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 2 | From: Martin Jansa <Martin.Jansa@gmail.com> |
| 3 | Date: Fri, 28 Jun 2019 13:50:52 +0000 |
| 4 | Subject: [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 | |
| 24 | Upstream-Status: Pending |
| 25 | Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> |
Andrew Geissler | c87764f | 2020-06-27 00:16:32 -0500 | [diff] [blame] | 26 | Signed-off-by: Leon Anavi <leon.anavi@konsulko.com> |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 27 | --- |
| 28 | examples/Makefile | 6 ++++-- |
| 29 | 1 file changed, 4 insertions(+), 2 deletions(-) |
| 30 | |
| 31 | diff --git a/examples/Makefile b/examples/Makefile |
Andrew Geissler | c87764f | 2020-06-27 00:16:32 -0500 | [diff] [blame] | 32 | index e9f9635ae..b2fbe2de1 100644 |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 33 | --- 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 Geissler | c87764f | 2020-06-27 00:16:32 -0500 | [diff] [blame] | 48 | - c++ -std=c++11 add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf` |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 49 | + $(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 Geissler | c87764f | 2020-06-27 00:16:32 -0500 | [diff] [blame] | 53 | - c++ -std=c++11 list_people.cc addressbook.pb.cc -o list_people_cpp `pkg-config --cflags --libs protobuf` |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 54 | + $(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 Geissler | c87764f | 2020-06-27 00:16:32 -0500 | [diff] [blame] | 58 | -- |
| 59 | 2.17.1 |
| 60 | |