ubuntu netbeans compile ygopro client with google protobuf lib

environment:sql

ubuntu 16.04ubuntu

netbeans 8.2ide

ygopro Fluorohydride with Irrlicht Game Engineui

 

問題1: google protobuf 提示 string ambiguous, string 類型和 Irrlicht 引擎衝突。google

嘗試的方法:lua

一、修改protobuf源碼 string -> ::std::string。(衝突項太多,放棄這個方法。)spa

二、調整編譯順序,將pb.h放到include頂部,優先編譯。debug

 

問題2: google protobuf 提示 不容許-fno-rtticode

解決方法: CFLAGS 移除 -fno-rttiserver

 

問題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)
相關文章
相關標籤/搜索