ubuntu netbeans compile ygopro client with google protobuf lib

environment:

ubuntu 16.04

netbeans 8.2

ygopro Fluorohydride with Irrlicht Game Engine

 

问题1: google protobuf 提示 string ambiguous, string 类型和 Irrlicht 引擎冲突。

尝试的方法:

1、修改protobuf源码 string -> ::std::string。(冲突项太多,放弃这个方法。)

2、调整编译顺序,将pb.h放到include顶部,优先编译。

 

问题2: google protobuf 提示 不允许-fno-rtti

解决方法: CFLAGS 移除 -fno-rtti

 

问题3: netbeans IDE 导入 ygopro cpp 项目 from makefile,编译单个文件 通过,编译项目 通过,链接protobuf失败,提示 “undefined reference to `tutorial::Person_PhoneNumber::Person_PhoneNumber()'”。

尝试的方法:

`pkg-config --cflags --libs protobuf`

CFLAGS/CXXFLAGS/CXXFLAGS/LIBS += -D_GLIBCXX_USE_CXX11_ABI=0 -lprotobuf

LDDEPS += /usr/local/lib/libprotobuf.a /usr/local/lib/libprotobuf.so

@echo $(LINKCMD) 查看g++链接命令

添加生成obj: addressbook.pb.o

# GNU Make project makefile autogenerated by Premake
ifndef config
  config=debug
endif

ifndef verbose
  SILENT = @
endif

ifndef CC
  CC = gcc
endif

ifndef CXX
  CXX = g++
endif

ifndef AR
  AR = ar
endif

ifeq ($(config),debug)
  OBJDIR     = ../obj/Debug/ygopro
  TARGETDIR  = ../bin/debug
  TARGET     = $(TARGETDIR)/ygopro
  DEFINES   += -DLUA_USE_LINUX -D_DEBUG
  INCLUDES  += -I../ocgcore -I/usr/include/lua -I/usr/include/lua5.2 -I/usr/include/lua/5.2 -I/usr/include/irrlicht -I/usr/include/freetype2
  CPPFLAGS  += -MMD -MP $(DEFINES) $(INCLUDES)
  CFLAGS    += $(CPPFLAGS) $(ARCH) -g -fno-strict-aliasing -Wno-multichar -std=gnu++0x
  CXXFLAGS  += $(CFLAGS)
  LDFLAGS   += -L../bin/debug
  LIBS      += -locgcore -lclzma -lIrrlicht -lfreetype -lsqlite3 -llua -levent -levent_pthreads -lGL -ldl -lpthread
  RESFLAGS  += $(DEFINES) $(INCLUDES) 
  LDDEPS    += ../bin/debug/libocgcore.a ../bin/debug/libclzma.a 
  LINKCMD    = $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS) /usr/local/lib/libprotobuf.a /usr/local/lib/libprotobuf.so
  define PREBUILDCMDS
  endef
  define PRELINKCMDS
  endef
  define POSTBUILDCMDS
  endef
endif

ifeq ($(config),release)
  OBJDIR     = ../obj/Release/ygopro
  TARGETDIR  = ../bin/release
  TARGET     = $(TARGETDIR)/ygopro
  DEFINES   += -DLUA_USE_LINUX -DNDEBUG
  INCLUDES  += -I../ocgcore -I/usr/include/lua -I/usr/include/lua5.2 -I/usr/include/lua/5.2 -I/usr/include/irrlicht -I/usr/include/freetype2
  CPPFLAGS  += -MMD -MP $(DEFINES) $(INCLUDES)
  CFLAGS    += $(CPPFLAGS) $(ARCH) -g -O3 -fno-strict-aliasing -Wno-multichar -march=native -std=gnu++0x -fno-rtti
  CXXFLAGS  += $(CFLAGS) 
  LDFLAGS   += -L../bin/release
  LIBS      += -locgcore -lclzma -lIrrlicht -lfreetype -lsqlite3 -llua -levent -levent_pthreads -lGL -ldl -lpthread -lprotobuf
  RESFLAGS  += $(DEFINES) $(INCLUDES) 
  LDDEPS    += ../bin/release/libocgcore.a ../bin/release/libclzma.a
  LINKCMD    = $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS)
  define PREBUILDCMDS
  endef
  define PRELINKCMDS
  endef
  define POSTBUILDCMDS
  endef
endif

OBJECTS := \
    $(OBJDIR)/duelclient.o \
    $(OBJDIR)/deck_con.o \
    $(OBJDIR)/client_field.o \
    $(OBJDIR)/single_duel.o \
    $(OBJDIR)/materials.o \
    $(OBJDIR)/netserver.o \
    $(OBJDIR)/replay_mode.o \
    $(OBJDIR)/CGUITTFont.o \
    $(OBJDIR)/single_mode.o \
    $(OBJDIR)/menu_handler.o \
    $(OBJDIR)/event_handler.o \
    $(OBJDIR)/gframe.o \
    $(OBJDIR)/data_manager.o \
    $(OBJDIR)/image_manager.o \
    $(OBJDIR)/deck_manager.o \
    $(OBJDIR)/replay.o \
    $(OBJDIR)/client_card.o \
    $(OBJDIR)/drawing.o \
    $(OBJDIR)/tag_duel.o \
    $(OBJDIR)/game.o \
    $(OBJDIR)/CGUIImageButton.o \
    $(OBJDIR)/addressbook.pb.o \

RESOURCES := \

SHELLTYPE := msdos
ifeq (,$(ComSpec)$(COMSPEC))
  SHELLTYPE := posix
endif
ifeq (/bin,$(findstring /bin,$(SHELL)))
  SHELLTYPE := posix
endif

.PHONY: clean prebuild prelink

all: $(TARGETDIR) $(OBJDIR) prebuild prelink $(TARGET)
    @:

$(TARGET): $(GCH) $(OBJECTS) $(LDDEPS) $(RESOURCES)
    @echo Linking ygopro
    @echo $(LINKCMD)
    $(SILENT) $(LINKCMD)
    $(POSTBUILDCMDS)

$(TARGETDIR):
    @echo Creating $(TARGETDIR)
ifeq (posix,$(SHELLTYPE))
    $(SILENT) mkdir -p $(TARGETDIR)
else
    $(SILENT) mkdir $(subst /,\\,$(TARGETDIR))
endif

$(OBJDIR):
    @echo Creating $(OBJDIR)
ifeq (posix,$(SHELLTYPE))
    $(SILENT) mkdir -p $(OBJDIR)
else
    $(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif

clean:
    @echo Cleaning ygopro
ifeq (posix,$(SHELLTYPE))
    $(SILENT) rm -f  $(TARGET)
    $(SILENT) rm -rf $(OBJDIR)
else
    $(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET))
    $(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR))
endif

prebuild:
    $(PREBUILDCMDS)

prelink:
    $(PRELINKCMDS)

ifneq (,$(PCH))
$(GCH): $(PCH)
    @echo $(notdir $<)
    -$(SILENT) cp $< $(OBJDIR)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
endif

$(OBJDIR)/duelclient.o: ../gframe/duelclient.cpp
    @echo $(notdir $<)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/deck_con.o: ../gframe/deck_con.cpp
    @echo $(notdir $<)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/client_field.o: ../gframe/client_field.cpp
    @echo $(notdir $<)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/single_duel.o: ../gframe/single_duel.cpp
    @echo $(notdir $<)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/materials.o: ../gframe/materials.cpp
    @echo $(notdir $<)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/netserver.o: ../gframe/netserver.cpp
    @echo $(notdir $<)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/replay_mode.o: ../gframe/replay_mode.cpp
    @echo $(notdir $<)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/CGUITTFont.o: ../gframe/CGUITTFont.cpp
    @echo $(notdir $<)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/single_mode.o: ../gframe/single_mode.cpp
    @echo $(notdir $<)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/menu_handler.o: ../gframe/menu_handler.cpp
    @echo $(notdir $<)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/event_handler.o: ../gframe/event_handler.cpp
    @echo $(notdir $<)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/gframe.o: ../gframe/gframe.cpp
    @echo $(notdir $<)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/data_manager.o: ../gframe/data_manager.cpp
    @echo $(notdir $<)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/image_manager.o: ../gframe/image_manager.cpp
    @echo $(notdir $<)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/deck_manager.o: ../gframe/deck_manager.cpp
    @echo $(notdir $<)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/replay.o: ../gframe/replay.cpp
    @echo $(notdir $<)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/client_card.o: ../gframe/client_card.cpp
    @echo $(notdir $<)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/drawing.o: ../gframe/drawing.cpp
    @echo $(notdir $<)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/tag_duel.o: ../gframe/tag_duel.cpp
    @echo $(notdir $<)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/game.o: ../gframe/game.cpp
    @echo $(notdir $<)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/CGUIImageButton.o: ../gframe/CGUIImageButton.cpp
    @echo $(notdir $<)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/addressbook.pb.o: ../gframe/addressbook.pb.cc
    @echo $(notdir $<)
    $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"

-include $(OBJECTS:%.o=%.d)

 

posted @ 2016-11-23 13:48 DancingFish 阅读(...) 评论(...) 编辑 收藏