yaml-cpp YAML :: LoadFile(std :: string const&)错误

时间:2014-07-25 15:49:49

标签: c++ yaml freebsd undefined-reference yaml-cpp

我是yaml-cpp的新手,我对此有一些疑问。

最近在我的freeebsd上我安装了yaml-cpp 0.5.0,我想在我的项目中使用它。

这是完整的编译日志:

gmake: Warning: File `Makefile' has modification time 6799 s in the future
compile config.cpp
In file included from config.cpp:22:
check_server.h: In static member function 'static bool CheckServer::CheckIp(const char*)':
check_server.h:24: warning: comparison between signed and unsigned integer expressions
config.cpp: In function 'void config_init(const std::string&)':
config.cpp:452: warning: NULL used in arithmetic
config.cpp:476: warning: NULL used in arithmetic
config.cpp:500: warning: NULL used in arithmetic
config.cpp:522: warning: unused variable 'line'
config.cpp:1206: warning: 'check_client_Version' may be used uninitialized in this function
Dimiourgia tou ../game_r54071....
../../OBJDIR/config.o: In function `config_init(std::string const&)':
/root/torino/Servers/game/src/config.cpp:338: undefined reference to `YAML::LoadFile(std::string const&)'
../../OBJDIR/config.o: In function `YAML::detail::node_ref::mark_defined()':
/usr/include/yaml-cpp/node/detail/node_ref.h:29: undefined reference to `YAML::detail::node_data::mark_defined()'
/usr/include/yaml-cpp/node/detail/node_ref.h:29: undefined reference to `YAML::detail::node_data::mark_defined()'
/usr/include/yaml-cpp/node/detail/node_ref.h:29: undefined reference to `YAML::detail::node_data::mark_defined()'
/usr/include/yaml-cpp/node/detail/node_ref.h:29: undefined reference to `YAML::detail::node_data::mark_defined()'
/usr/include/yaml-cpp/node/detail/node_ref.h:29: undefined reference to `YAML::detail::node_data::mark_defined()'
../../OBJDIR/config.o:/usr/include/yaml-cpp/node/detail/node_ref.h:29: more undefined references to `YAML::detail::node_data::mark_defined()' follow
../../OBJDIR/config.o: In function `YAML::detail::memory_holder::create_node()':
/usr/include/yaml-cpp/node/detail/memory.h:30: undefined reference to `YAML::detail::memory::create_node()'
../../OBJDIR/config.o: In function `YAML::detail::node_ref::set_null()':
/usr/include/yaml-cpp/node/detail/node_ref.h:34: undefined reference to `YAML::detail::node_data::set_null()'
../../OBJDIR/config.o: In function `YAML::detail::node_ref::mark_defined()':
/usr/include/yaml-cpp/node/detail/node_ref.h:29: undefined reference to `YAML::detail::node_data::mark_defined()'
../../OBJDIR/config.o: In function `YAML::detail::node& YAML::detail::node_data::get<std::string>(std::string const&, boost::shared_ptr<YAML::detail::memory_holder>)':
/usr/include/yaml-cpp/node/detail/impl.h:89: undefined reference to `YAML::detail::node_data::convert_to_map(boost::shared_ptr<YAML::detail::memory_holder>)'
../../OBJDIR/config.o: In function `YAML::detail::memory_holder::create_node()':
/usr/include/yaml-cpp/node/detail/memory.h:30: undefined reference to `YAML::detail::memory::create_node()'
../../OBJDIR/config.o: In function `YAML::detail::node_ref::set_scalar(std::string const&)':
/usr/include/yaml-cpp/node/detail/node_ref.h:35: undefined reference to `YAML::detail::node_data::set_scalar(std::string const&)'
../../OBJDIR/config.o: In function `convert_to_node<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >':
/usr/include/yaml-cpp/node/detail/impl.h:157: undefined reference to `YAML::detail::memory_holder::merge(YAML::detail::memory_holder&)'
../../OBJDIR/config.o: In function `YAML::detail::memory_holder::create_node()':
/usr/include/yaml-cpp/node/detail/memory.h:30: undefined reference to `YAML::detail::memory::create_node()'
../../OBJDIR/config.o: In function `YAML::detail::node& YAML::detail::node_data::get<std::string>(std::string const&, boost::shared_ptr<YAML::detail::memory_holder>)':
/usr/include/yaml-cpp/node/detail/impl.h:102: undefined reference to `YAML::detail::node_data::insert_map_pair(YAML::detail::node&, YAML::detail::node&)'
../../OBJDIR/config.o: In function `YAML::detail::node_ref::mark_defined()':
/usr/include/yaml-cpp/node/detail/node_ref.h:29: undefined reference to `YAML::detail::node_data::mark_defined()'
gmake: *** [../game_r54071] Error 1

我使用yaml的部分是:

YAML::Node config_test = YAML::LoadFile("config.yml");
if(config_test["test"].as<unsigned int>() > 1)
{
    cout << "the value is > 1" << endl;
}
else
{
    cout << "the value is < 1" << endl;
}

这是Makefile:

MAKE = gmake
CC = gcc

INCDIR =
LIBDIR =
BINDIR = ..
OBJDIR = ../../OBJDIR

GCC_VERSION = $(shell $(CC) --version 2>&1 | grep "(GCC)" | cut -d' ' -f3  | cut -d'.' -f1)
BSD_VERSION = $(shell uname -v 2>&1 | cut -d' ' -f2 | cut -d'.' -f1)
P4_VERSION = 54071
$(shell if [ ! -d $(OBJDIR) ]; then mkdir $(OBJDIR); fi)


LIBS = -pthread -lm -lmd

CFLAGS = -g -Wall -O2 -m32 -pipe -fexceptions -D_THREAD_SAFE -DNDEBUG # -D_USE_SERVER_KEY_

ifeq ($(GCC_VERSION), 4)
CFLAGS += -mtune=i686 -fstack-protector-all
else
CFLAGS += -mtune=i686
endif

# boost
INCDIR += -I../boost

# DevIL
INCDIR += -I../../../Libraries/libdevil
LIBDIR += -L../../../Libraries/libdevil
LIBS += -lIL -lpng -ltiff -lmng -llcms -ljpeg

# MySQL
ifeq ($(BSD_VERSION), 7)
INCDIR += -I../../../Libraries/libmysql/7.x-5.1.35
LIBDIR += -L../../../Libraries/libmysql/7.x-5.1.35
else
INCDIR += -I../../../Libraries/libmysql/5.x-5.1.35
LIBDIR += -L../../../Libraries/libmysql/5.x-5.1.35
endif

LIBDIR += -L/usr/local/lib/mysql 
LIBDIR += -L/usr/lib/
INCDIR += -I/usr/local/lib/
LIBS += -lmysqlclient -lz
LIBS += -lcryptopp -lgtest


INCDIR += -I../../../Libraries/libhackshield/include
LIBDIR += -L../../../Libraries/libhackshield/lib
LIBS += -lanticpxsvr


INCDIR += -I../../../Libraries/libxtrap/include

# Project Library
INCDIR += -I../../../Libraries/liblua/include
INCDIR += -I/usr/local/include
INCDIR += -I../../../Libraries/libserverkey
LIBDIR += -L../../../Libraries/libthecore/lib -L../../../Libraries/libpoly -L../../../Libraries/libsql -L../../../Libraries/libgame/lib -L../../../Libraries/liblua/lib -L../../../Libraries/libserverkey
LIBDIR += -L/usr/local/lib/
LIBS += -lthecore -lpoly -llua -llualib -lsql -lgame -lserverkey
USE_STACKTRACE = 0
ifeq ($(USE_STACKTRACE), 1)
LIBS += /usr/local/lib/libexecinfo.a
endif

TARGET  = $(BINDIR)/game_r$(P4_VERSION)

CFILE   = minilzo.c

CPPFILE = BattleArena.cpp FSM.cpp MarkConvert.cpp MarkImage.cpp MarkManager.cpp OXEvent.cpp TrafficProfiler.cpp ani.cpp\
          arena.cpp banword.cpp battle.cpp blend_item.cpp block_country.cpp buffer_manager.cpp building.cpp castle.cpp\
          char.cpp char_affect.cpp char_battle.cpp char_change_empire.cpp char_horse.cpp char_item.cpp char_manager.cpp\
          char_quickslot.cpp char_resist.cpp char_skill.cpp char_state.cpp PetSystem.cpp cmd.cpp cmd_emotion.cpp cmd_general.cpp\
          cmd_gm.cpp cmd_oxevent.cpp config.cpp constants.cpp crc32.cpp cube.cpp db.cpp desc.cpp\
          desc_client.cpp desc_manager.cpp desc_p2p.cpp dev_log.cpp dungeon.cpp empire_text_convert.cpp entity.cpp\
          entity_view.cpp event.cpp event_queue.cpp exchange.cpp file_loader.cpp fishing.cpp gm.cpp guild.cpp\
          guild_manager.cpp guild_war.cpp horse_rider.cpp horsename_manager.cpp input.cpp input_auth.cpp input_db.cpp\
          input_login.cpp input_main.cpp input_p2p.cpp input_teen.cpp input_udp.cpp ip_ban.cpp\
          item.cpp item_addon.cpp item_attribute.cpp item_manager.cpp item_manager_idrange.cpp locale.cpp\
          locale_service.cpp log.cpp login_data.cpp lzo_manager.cpp marriage.cpp matrix_card.cpp\
          messenger_manager.cpp mining.cpp mob_manager.cpp monarch.cpp motion.cpp over9refine.cpp p2p.cpp packet_info.cpp\
          party.cpp passpod.cpp pcbang.cpp polymorph.cpp priv_manager.cpp pvp.cpp\
          questevent.cpp questlua.cpp questlua_affect.cpp questlua_arena.cpp questlua_ba.cpp questlua_building.cpp\
          questlua_danceevent.cpp questlua_dungeon.cpp questlua_forked.cpp questlua_game.cpp questlua_global.cpp\
          questlua_guild.cpp questlua_horse.cpp questlua_pet.cpp questlua_item.cpp questlua_marriage.cpp questlua_mgmt.cpp\
          questlua_monarch.cpp questlua_npc.cpp questlua_oxevent.cpp questlua_party.cpp questlua_pc.cpp\
          questlua_quest.cpp questlua_target.cpp questmanager.cpp questnpc.cpp questpc.cpp\
          refine.cpp regen.cpp safebox.cpp sectree.cpp sectree_manager.cpp sequence.cpp shop.cpp\
          skill.cpp start_position.cpp target.cpp text_file_loader.cpp trigger.cpp utils.cpp vector.cpp war_map.cpp\
          wedding.cpp xmas_event.cpp version.cpp panama.cpp threeway_war.cpp map_location.cpp auth_brazil.cpp\
          BlueDragon.cpp BlueDragon_Binder.cpp DragonLair.cpp questlua_dragonlair.cpp\
          HackShield.cpp HackShield_Impl.cpp char_hackshield.cpp skill_power.cpp affect.cpp\
          SpeedServer.cpp questlua_speedserver.cpp XTrapManager.cpp\
          auction_manager.cpp FileMonitor_FreeBSD.cpp ClientPackageCryptInfo.cpp cipher.cpp\
          buff_on_attributes.cpp check_server.cpp dragon_soul_table.cpp DragonSoul.cpp\
          group_text_parse_tree.cpp char_dragonsoul.cpp questlua_dragonsoul.cpp\
          shop_manager.cpp shopEx.cpp item_manager_read_tables.cpp spamblock.cpp questlua_lom2.cpp


COBJS   = $(CFILE:%.c=$(OBJDIR)/%.o)
CPPOBJS = $(CPPFILE:%.cpp=$(OBJDIR)/%.o)

MAINOBJ = $(OBJDIR)/main.o
MAINCPP = main.cpp

default: $(TARGET)

$(OBJDIR)/minilzo.o: minilzo.c
    @$(CC) $(CFLAGS) $(INCDIR) -c $< -o $@
    @echo compile $<

$(OBJDIR)/version.o: version.cpp
    @$(CC) $(CFLAGS) -D__USER__=\"$(USER)\" -D__HOSTNAME__=\"$(HOSTNAME)\" -D__PWD__=\"$(PWD)\" -D__P4_VERSION__=\"$(P4_VERSION)\" -c $< -o $@
    @echo compile $<

$(OBJDIR)/%.o: %.cpp
    @echo compile $<
    @$(CC) $(CFLAGS) $(INCDIR) -c $< -o $@

$(TARGET): $(CPPOBJS) $(COBJS) $(MAINOBJ)
    @echo Building $(TARGET)....
    @$(CC) $(CFLAGS) $(LIBDIR) $(COBJS) $(CPPOBJS) $(MAINOBJ) -I/usr/local/include  -L/usr/local/lib -lyaml-cpp $(LIBS) -o $(TARGET)

clean:
    @rm -f $(COBJS) $(CPPOBJS)
    @rm -f $(BINDIR)/game_r* $(BINDIR)/conv

tag:
    ctags *.cpp *.h *.c

dep:
    makedepend -f Depend $(INCDIR) -I/usr/include/c++/3.3 -I/usr/include/c++/4.2 -p$(OBJDIR)/ $(CPPFILE) $(CFILE) $(MAINCPP) $(TESTCPP) 2> /dev/null > Depend

sinclude Depend

任何帮助?

0 个答案:

没有答案