未明确引用GLib

时间:2015-05-25 20:16:41

标签: c++ c linker glib

我知道,有很多类似于我的问题,但他们的答案并没有解决我的问题。

我正在尝试构建CHamsa项目: https://github.com/maxsnew/CHamsa/

开心,修补,修建,安装。构建了TokenEXAPI。一切都很棒。 当最终使用makefile制作CHamsa时,它给了我错误:

输入' make'

Makefile

g++ -o siggen tracesary.o utils.o tokenExtract.o conjpattern.o sig_gen.o siggen_main.o 
  -lm -pthread -L/usr/local/lib -lsary -lgthread-2.0 -lglib-2.0   -LTokenEXAPI -ltkex -lds_ssort -lbwtlcp

错误

/usr/local/lib/libsary.so: undefined reference to `g_free'
/usr/local/lib/libsary.so: undefined reference to `g_hash_table_destroy'
/usr/local/lib/libsary.so: undefined reference to `g_strdup'
/usr/local/lib/libsary.so: undefined reference to `g_hash_table_insert'
/usr/local/lib/libsary.so: undefined reference to `g_strconcat'
/usr/local/lib/libsary.so: undefined reference to `g_array_new'
/usr/local/lib/libsary.so: undefined reference to `g_array_free'
/usr/local/lib/libsary.so: undefined reference to `g_malloc'
/usr/local/lib/libsary.so: undefined reference to `g_assertion_message_expr'
/usr/local/lib/libsary.so: undefined reference to `g_hash_table_new'
/usr/local/lib/libsary.so: undefined reference to `g_hash_table_foreach'
/usr/local/lib/libsary.so: undefined reference to `g_hash_table_lookup'
/usr/local/lib/libsary.so: undefined reference to `g_strerror'
/usr/local/lib/libsary.so: undefined reference to `g_malloc_n'
/usr/local/lib/libsary.so: undefined reference to `g_array_append_vals'
/usr/local/lib/libsary.so: undefined reference to `g_log'

它看起来很糟糕,因为使用 glib 的文件有:

 #include <glib.h>

任何想法如何解决这个问题?我整天坐在这里谷歌搜索答案......

这个很糟糕:

 g++ -o siggen tracesary.o utils.o tokenExtract.o conjpattern.o sig_gen.o siggen_main.o 
   -lm -pthread  -lgthread-2.0 -lglib-2.0  -L/usr/local/lib -lsary -LTokenEXAPI -ltkex -lds_ssort -lbwtlcp

那个也是:

g++ -o siggen tracesary.o utils.o tokenExtract.o conjpattern.o sig_gen.o siggen_main.o 
   -lm -pthread  -lgthread-2.0 -lglib-2.0  -L/usr/local/lib -lsary -LTokenEXAPI -ltkex -lds_ssort -lbwtlcp
甚至那一个:

g++ -o siggen tracesary.o utils.o tokenExtract.o conjpattern.o sig_gen.o siggen_main.o 
  -lm -pthread -L/usr/local/lib -lsary -L/usr/lib  -lgthread-2.0 -lglib-2.0 -LTokenEXAPI -ltkex -lds_ssort -lbwtlcp

修改

Makefile看起来像这样:

    ###############################################################################
#
# File:         Makefile
# Description:  Guess
# Author:       Zhichun Li
#               Northwestern Systems Research Group
#               Department of Computer Science
#               Northwestern University
# Language:     Makefile
# Package:      N/A
# Status:       Experimental (Do Not Distribute)
#
# (C) Copyright 2006, Northwestern University, all rights reserved.
#
###############################################################################

CXX = g++
MV = mv
CP = cp
RM = rm
MKDIR = mkdir
TAR = tar cvf
COMPRESS = gzip

INC = $(shell pkg-config --cflags sary)
#CXXFLAGS = -Wall -ggdb -c ${INC}
CXXFLAGS = -Wall -O3 -c ${INC}
LIBS = -lm $(shell pkg-config --libs sary) -LTokenEXAPI -ltkex -lds_ssort -lbwtlcp


TARGET = test_tracesary 
TARGET = siggen
STATICLIBS = 
SOURCES = test_tracesary.cpp  tracesary.cpp  utils.cpp 
SOURCES = siggen_main.cpp  tracesary.cpp  utils.cpp tokenExtract.cpp conjpattern.cpp sig_gen.cpp
SOURCES = tracesary.cpp  utils.cpp tokenExtract.cpp conjpattern.cpp sig_gen.cpp
HEADER = utils.h tracesary.h bitvec.h globals.h

OBJS = ${SOURCES:.cpp=.o}

all: ${TARGET} siggen_nonoise

#utils.o: utils.cpp ${HEADER}
#   ${CXX} ${CXXFLAGS}  $<

#tracesary.o: tracesary.cpp ${HEADER}
#   ${CXX} ${CXXFLAGS}  $<

#test_tracesary.o: test_tracesary.cpp ${HEADER}
#   ${CXX} ${CXXFLAGS}  $<

#siggen.o: sigen.cpp ${HEADER}
#   ${CXX} ${CXXFLAGS}  $<

${TARGET}: siggen_main.o ${OBJS}
    ${CXX} -o $@ ${OBJS} siggen_main.o ${LIBS}

siggen_nonoise: siggen_nonoise.o ${OBJS}
    ${CXX} -o $@ ${OBJS} siggen_nonoise.o ${LIBS}

%.o: %.cpp *.h
    $(CXX) $(CXXFLAGS) -c $< -o $@
clean:
    ${RM} -f *.o *~ ${TARGET} siggen_nonoise

cleanAll: clean

我还尝试了

$(shell pkg-config --libs glib-2.0)

没有效果

0 个答案:

没有答案