我收到的错误可以在下面看到,错误来自我创建的静态库(libredis.a):
/root/projects/lib/libredis.a(redisHandler.o): In function redisHandler.cpp:(.text+0x1394): undefined reference to `std::ctype<char>::_M_widen_init() const'
collect2: ld returned 1 exit status
我100%肯定这个静态lib和我的项目是用相同的g ++版本构建的(g ++ 46) 我在makefile中使用了-std = c ++ 0x -static-libstdc ++ -static-libgcc选项。
以下是来自项目的问题的gcc输出,对不起详细信息:
g++46 common/config.o common/hash.o sighandler.o globals.o itap.o itapworker.o itapdb.o itapmsgs.o itapflow.o itapintercept.o itapstore.o itapipdr.o itaputil.o itapprotoutil.o itapmail.o itapdns.o itapdhcp.o itapradius.o itapdhcpv6.o itapsyslog.o itaprbli.o itapl2tp.o itapsip.o itapisup.o itaprudp.o itapmgcp.o itapmegaco.o itapm3ua.o itapq850codes.o itaph323.o itaprtp.o itapsdp.o itaprtpstatictypes.o itapmsn.o itapymsg.o itapftp.o itapsmtp.o itapimap.o itappop3.o itapsmpp.o itaphttp.o itaphttpproto.o itaphotmail.o itapyahoomail.o itapgmail.o itapfacebook.o itaplinkedin.o itaptwitter.o itaptac.o -o inseptrad -L/root/projects/lib -L/usr/local/lib -L/usr/lib -lecrypt -lipcutil -lsurlicense -lsysctl -ltcpip -ldpi -lconf -ltimerq -lsqlite -lasn -lmiscutil -lredis -lpcap -lssl -lcrypto -lglib-2.0 -lxml2 -lopal -lm -lrt -lsqlite3 -lpthread -licc -lpgm-5-1-117-pic -lwiro -lwireshark -lwsutil -lpt_r -lboost_system -lhiredis `pkg-config --libs glib-2.0` -O3 -Wall -Wno-unused-function -std=c++0x -DFREEBSD -DINTEL -D__USE_BSD=1 -D__FAVOR_BSD=1 -D__USE_GNU -static-libstdc++ -static-libgcc -I./include -I./common/include -I/root/projects/include -I/root/projects/include/wiro -I/usr/local/include/libxml2 -I/usr/include/libxml2 -I/usr/local/include/pgm-5.1 -I/usr/include/pgm-5.1 -I/usr/local/include/opal -I/usr/include/opal/ -I/usr/local/lib/gcc46/include/ -I/usr/include/hiredis -I/usr/local/include -I/usr/include `pkg-config --cflags glib-2.0`
/root/projects/lib/libredis.a(redisHandler.o): In function `redisHandler::alarmCreater(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::any>, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::any> > >*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
redisHandler.cpp:(.text+0x1394): undefined reference to `std::ctype<char>::_M_widen_init() const'
collect2: ld returned 1 exit status
gmake: *** [inseptrad] Error 1
当我构建静态库
时还有gcc输出[root@ ~/projects/test]# gmake clean all install
mkdir -p /root/projects/lib && cd /root/projects/lib; rm -f libredis.a; cd -
mkdir -p /root/projects/include && cd /root/projects/include; rm -f redisHandler.hpp; cd -
rm -f libredis.a *.o *~ *core*
g++46 -O3 -pipe -fno-strict-aliasing -Winline -Wall -Wno-unused-function -std=c++0x -DFREEBSD -DINTEL -D__USE_GNU -D__USE_BSD=1 -D__FAVOR_BSD=1 -static-libstdc++ -static-libgcc -I/usr/local/include/glib-2.0 -I/usr/local/include -I/usr/include/hiredis -I/usr/local/lib/gcc46/include/ -I./include/ -I. -I/root/projects/include -I/usr/local/include -I/usr/include `pkg-config --cflags glib-2.0` -c -o redisHandler.o redisHandler.cpp
ar scru libredis.a redisHandler.o
mkdir -p /root/projects/lib && cp -pf libredis.a /root/projects/lib
mkdir -p /root/projects/include && cp -pf include/redisHandler.hpp /root/projects/include
我找不到任何可能发生此错误的原因,如果你们有一些想法我会非常感激。
Ps:请大家不要关闭其他主题对此问题没有帮助的问题。
答案 0 :(得分:0)
即使我很小心静态库和项目正在使用不同的库,因为评论者建议我。至少我可以说明我是如何解决它的:
[root@ ~/projects/INSEPTRA_RELENG_12_8_chunk]# find / -name "libstdc++.a"
/usr/lib/libstdc++.a
/usr/local/lib/gcc46/libstdc++.a
/usr/local/lib/gcc47/libstdc++.a
/usr/lib32/libstdc++.a
/root/projects/lib/libstdc++.a
[root@ ~/projects/INSEPTRA_RELENG_12_8_chunk]# cp /usr/lib/libstdc++.a /usr/lib/libstdc++.a_bak
[root@ ~/projects/INSEPTRA_RELENG_12_8_chunk]# cp /usr/local/lib/gcc46/libstdc++.a /usr/lib/libstdc++.a
[root@ ~/projects/INSEPTRA_RELENG_12_8_chunk]# cp /usr/local/lib/gcc46/libstdc++.a /usr/lib32/libstdc++.a
[root@ ~/projects/INSEPTRA_RELENG_12_8_chunk]# cp /usr/local/lib/gcc46/libstdc++.a /root/projects/lib/libstdc++.a
[root@ ~/projects/INSEPTRA_RELENG_12_8_chunk]# gmake