zeroc-ice / ice

All-in-one solution for creating networked applications with RPC, pub/sub, server deployment, and more.
https://zeroc.com
GNU General Public License v2.0
2.05k stars 593 forks source link

How can I build 3.7.3 with C++11 ? #1300

Closed wubo2018 closed 3 years ago

wubo2018 commented 3 years ago

I can build cpp using gcc9.4.0 and build success,but when Link IceStrom.so occur error

like this : undefined reference to `sssp(std::__cxx11::basic_string<char, std::char_traits, std::allocator >, char)

so How Can I enable C++11 in Makefile

pepone commented 3 years ago

Hi,

It would be better to upgrade to 3.7.6 from this repo, then you can either use the C++11 mapping

CONFIGS=cpp11-shared make

See https://github.com/zeroc-ice/ice/tree/3.7/cpp#c11-mapping

And you need to link with the C++11 libraries

https://doc.zeroc.com/ice/3.7/release-notes/using-the-linux-binary-distributions#id-.UsingtheLinuxBinaryDistributionsv3.7-C++

This is preferred for new applications, if you want to use the C++98 mapping and build with C++11 mode, you can set CPPFLAGS as

make CPPFLAGS=--std=c++11 V=1 -j8 srcs

See also https://doc.zeroc.com/ice/3.7/language-mappings/c++11-mapping/selecting-the-c++11-mapping

wubo2018 commented 3 years ago

I use gcc -v 9.4.0 and cmd "make CPPFLAGS=--std=c++11 V=1 -j8 srcs" to compile ICE lib , this success; I write a plugin server with ice publish link the ice lib;

when I link the plugin go wrong error message :+1:

I know this is ABI progrom but I not kown how to resolve it

undefined reference to IceProxy::IceStorm::Topic::_iceI_begin_subscribeAndGetPublisher(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&, IceInternal::ProxyHandle<IceProxy::Ice::Object> const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&, IceUtil::Handle<IceInternal::CallbackBase> const&, IceInternal::Handle<Ice::LocalObject> const&, bool)' undefined reference toIce::Object::ice_id[abi:cxx11](Ice::Current const&) const' undefined reference to Ice::Object::ice_isA(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Ice::Current const&) const' undefined reference toIceProxy::IceStorm::TopicManager::_iceI_begin_create(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::map<std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::less<std::cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::pair<std::cxx11::basic_string<char, std::char_traits, std::allocator > const, std::cxx11::basic_string<char, std::char_traits, std::allocator > > > > const&, IceUtil::Handle const&, IceInternal::Handle const&, bool)' undefined reference to IceInternal::OutgoingAsyncBase::getOperation[abi:cxx11]() const' undefined reference toIce::Object::ice_operationAttributes(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&) const' undefined reference to IceProxy::IceStorm::Topic::_iceI_begin_unsubscribe(IceInternal::ProxyHandle<IceProxy::Ice::Object> const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&, IceUtil::Handle<IceInternal::CallbackBase> const&, IceInternal::Handle<Ice::LocalObject> const&, bool)' undefined reference toIce::noExplicitContext[abi:cxx11]' undefined reference to IceInternal::OutgoingAsync::invoke(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' undefined reference toIce::Object::ice_ids[abi:cxx11](Ice::Current const&) const' undefined reference to IceUtil::SyscallException::ice_id[abi:cxx11]() const' undefined reference toIceProxy::IceStorm::TopicManager::_iceI_begin_retrieve(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::map<std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::less<std::cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::pair<std::cxx11::basic_string<char, std::char_traits, std::allocator > const, std::__cxx11::basic_string<char, std::char_traits, std::allocator > > > > const&, IceUtil::Handle const&, IceInternal::Handle const&, bool)' undefined reference to IceProxy::IceStorm::Topic::_iceI_begin_getPublisher(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&, IceUtil::Handle<IceInternal::CallbackBase> const&, IceInternal::Handle<Ice::LocalObject> const&, bool)' undefined reference toIceProxy::Ice::Object::_iceI_begin_ice_isA(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::map<std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::less<std::cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::pair<std::cxx11::basic_string<char, std::char_traits, std::allocator > const, std::cxx11::basic_string<char, std::char_traits, std::allocator > > > > const&, IceUtil::Handle const&, IceInternal::Handle const&, bool)' undefined reference to Ice::OperationNotExistException::OperationNotExistException(char const*, int, Ice::Identity const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' undefined reference toIceInternal::OutgoingAsync::prepare(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, Ice::OperationMode, std::map<std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::less<std::cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::pair<std::cxx11::basic_string<char, std::char_traits, std::allocator > const, std::cxx11::basic_string<char, std::char_traits, std::allocator > > > > const&)' undefined reference to IceProxy::IceStorm::TopicManager::ice_staticId[abi:cxx11]()' undefined reference toIceProxy::Ice::Object::_end(IceInternal::Handle const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&) const' undefined reference to `IceInternal::Ex::throwUOE(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, IceInternal::Handle const&)' undefined reference to `Ice::InputStream::read(std::__cxx11::basic_string<char, std::char_traits, std::allocator >&, bool)' collect2: error: ld returned 1 exit status

pepone commented 3 years ago

can you show the compile and link commands that you use to build your program?

wubo2018 commented 3 years ago

CC =g++ -std=c++11 dirs:=$(shell find . -maxdepth 10 -type d) files:=$(foreach dir,$(dirs),$(wildcard $(dir)/.cpp)) sources :=$(wildcard .c) $(wildcard *.cpp) objects :=$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(files))) dependence :=$(object:.o=.d) object_dir = obj output_dir = bin CPPFLAGS=-g -shared -fPIC RM =rm -rf INCLUDE =-I /opt/Ice-3.7.5/include LIB_PATH=-L /opt/Ice-3.7.5/lib64 LIB =-lIce -lIceStorm -lGlacier2 -lpthread RPath :=-Wl,-rpath TARGET =libIceSub.so $(TARGET):$(objects) $(CC) $(CPPFLAGS) $^ -o $@ $(LIB_PATH) $(LIB) $(RPath) %.o:%.cpp $(CC) $(CPPFLAGS) -c $< -o $@ $(INCLUDE) clean: $(RM) $(objects) $(dependence) $(TARGET)

wubo2018 commented 3 years ago

CC =g++ -std=c++11 sources :=$(wildcard .c) $(wildcard .cpp) objects :=$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(sources))) dependence :=$(object:.o=.d) RM =rm -rf INCLUDE =-I /. LIB_PATH=-L /. LIB =-lIceSub RPath :=-Wl,-rpath TARGET =IceSub $(TARGET):$(objects) $(CC) $(CPPFLAGS) $^ -o $@ $(LIB_PATH) $(LIB) $(RPath) %.o:%.cpp $(CC) $(CPPFLAGS) -c $< -o $@ $(INCLUDE) clean: $(RM) $(objects) $(dependence)

pepone commented 3 years ago

Do you get the errors when building IceSub or libIceSub ? seems you are not linking IceSub with Ice libraries

wubo2018 commented 3 years ago

no error when I use CC =g++ -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 it can link

wubo2018 commented 3 years ago

![Uploading image.png…]()

pepone commented 3 years ago

It is not clear to me why you get this ABI issue after rebuilding Ice with -std=c++11

wubo2018 commented 3 years ago

I maybe resove it