Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 1 | From e3fa241637ab5a7fa78c0d474802134cff75f91e 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> |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 27 | |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 28 | --- |
| 29 | examples/Makefile | 6 ++++-- |
| 30 | 1 file changed, 4 insertions(+), 2 deletions(-) |
| 31 | |
| 32 | diff --git a/examples/Makefile b/examples/Makefile |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 33 | index 1c7ec8d63..85f591231 100644 |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 34 | --- 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 Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 45 | @@ -40,11 +42,11 @@ protoc_middleman_dart: addressbook.proto |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 46 | |
| 47 | add_person_cpp: add_person.cc protoc_middleman |
| 48 | pkg-config --cflags protobuf # fails if protobuf is not installed |
Andrew Geissler | c87764f | 2020-06-27 00:16:32 -0500 | [diff] [blame] | 49 | - 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] | 50 | + $(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 Geissler | c87764f | 2020-06-27 00:16:32 -0500 | [diff] [blame] | 54 | - 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] | 55 | + $(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 | |