Menu

#566 Linking issue in libfreeorioncommon.so with -Wl,--as-needed

Recent Test Release
closed
nobody
None
5
2014-10-13
2014-09-11
No

Hi,

I'm packaging FreeOrion for Mageia and I've been trying to update to version 0.4.4 using Mageia's default optimization and linking flags. It seems the -Wl,--as-needed ldflag spawns an error because libfreeorioncommon does not explicitly link libfreeorionparse:

Linking CXX shared library libfreeorioncommon.so
/usr/bin/cmake -E cmake_link_script CMakeFiles/freeorioncommon.dir/link.txt --verbose=1
/usr/bin/c++ -fPIC -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fPIC -Wno-deprecated -Wall -Wno-parentheses -O3 -DNDEBUG -Wl,--as-needed -Wl,--no-undefined -Wl,-z,relro -Wl,-O1 -Wl,--build-id -Wl,--enable-new-dtags -shared -Wl,-soname,libfreeorioncommon.so -o libfreeorioncommon.so CMakeFiles/freeorioncommon.dir/combat/AsteroidBeltObstacle.cpp.o CMakeFiles/freeorioncommon.dir/combat/CombatEvent.cpp.o CMakeFiles/freeorioncommon.dir/combat/CombatEvents.cpp.o CMakeFiles/freeorioncommon.dir/combat/CombatFighter.cpp.o CMakeFiles/freeorioncommon.dir/combat/CombatLogManager.cpp.o CMakeFiles/freeorioncommon.dir/combat/CombatObject.cpp.o CMakeFiles/freeorioncommon.dir/combat/CombatOrder.cpp.o CMakeFiles/freeorioncommon.dir/combat/CombatShip.cpp.o CMakeFiles/freeorioncommon.dir/combat/Missile.cpp.o CMakeFiles/freeorioncommon.dir/combat/PathingEngine.cpp.o CMakeFiles/freeorioncommon.dir/Empire/Diplomacy.cpp.o CMakeFiles/freeorioncommon.dir/Empire/Empire.cpp.o CMakeFiles/freeorioncommon.dir/Empire/EmpireManager.cpp.o CMakeFiles/freeorioncommon.dir/Empire/ResourcePool.cpp.o CMakeFiles/freeorioncommon.dir/network/Message.cpp.o CMakeFiles/freeorioncommon.dir/network/MessageQueue.cpp.o CMakeFiles/freeorioncommon.dir/network/Networking.cpp.o CMakeFiles/freeorioncommon.dir/OpenSteer/src/Obstacle.cpp.o CMakeFiles/freeorioncommon.dir/OpenSteer/src/SimpleVehicle.cpp.o CMakeFiles/freeorioncommon.dir/OpenSteer/src/Vec3.cpp.o CMakeFiles/freeorioncommon.dir/OpenSteer/src/Vec3Utilities.cpp.o CMakeFiles/freeorioncommon.dir/universe/Building.cpp.o CMakeFiles/freeorioncommon.dir/universe/Condition.cpp.o CMakeFiles/freeorioncommon.dir/universe/EffectAccounting.cpp.o CMakeFiles/freeorioncommon.dir/universe/Effect.cpp.o CMakeFiles/freeorioncommon.dir/universe/Enums.cpp.o CMakeFiles/freeorioncommon.dir/universe/Field.cpp.o CMakeFiles/freeorioncommon.dir/universe/Fleet.cpp.o CMakeFiles/freeorioncommon.dir/universe/Meter.cpp.o CMakeFiles/freeorioncommon.dir/universe/ObjectMap.cpp.o CMakeFiles/freeorioncommon.dir/universe/Planet.cpp.o CMakeFiles/freeorioncommon.dir/universe/PopCenter.cpp.o CMakeFiles/freeorioncommon.dir/universe/Predicates.cpp.o CMakeFiles/freeorioncommon.dir/universe/ResourceCenter.cpp.o CMakeFiles/freeorioncommon.dir/universe/Ship.cpp.o CMakeFiles/freeorioncommon.dir/universe/ShipDesign.cpp.o CMakeFiles/freeorioncommon.dir/universe/Special.cpp.o CMakeFiles/freeorioncommon.dir/universe/Species.cpp.o CMakeFiles/freeorioncommon.dir/universe/System.cpp.o CMakeFiles/freeorioncommon.dir/universe/Tech.cpp.o CMakeFiles/freeorioncommon.dir/universe/Universe.cpp.o CMakeFiles/freeorioncommon.dir/universe/UniverseObject.cpp.o CMakeFiles/freeorioncommon.dir/universe/ValueRef.cpp.o CMakeFiles/freeorioncommon.dir/util/AppInterface.cpp.o CMakeFiles/freeorioncommon.dir/util/DataTable.cpp.o CMakeFiles/freeorioncommon.dir/util/Directories.cpp.o CMakeFiles/freeorioncommon.dir/util/EnumText.cpp.o CMakeFiles/freeorioncommon.dir/util/i18n.cpp.o CMakeFiles/freeorioncommon.dir/util/Logger.cpp.o CMakeFiles/freeorioncommon.dir/util/Math.cpp.o CMakeFiles/freeorioncommon.dir/util/ModeratorAction.cpp.o CMakeFiles/freeorioncommon.dir/util/MultiplayerCommon.cpp.o CMakeFiles/freeorioncommon.dir/util/OptionsDB.cpp.o CMakeFiles/freeorioncommon.dir/util/Order.cpp.o CMakeFiles/freeorioncommon.dir/util/OrderSet.cpp.o CMakeFiles/freeorioncommon.dir/util/Process.cpp.o CMakeFiles/freeorioncommon.dir/util/Random.cpp.o CMakeFiles/freeorioncommon.dir/util/SaveGamePreviewUtils.cpp.o CMakeFiles/freeorioncommon.dir/util/ScopedTimer.cpp.o CMakeFiles/freeorioncommon.dir/util/SerializeEmpire.cpp.o CMakeFiles/freeorioncommon.dir/util/SerializeModeratorAction.cpp.o CMakeFiles/freeorioncommon.dir/util/SerializeMultiplayerCommon.cpp.o CMakeFiles/freeorioncommon.dir/util/SerializeOrderSet.cpp.o CMakeFiles/freeorioncommon.dir/util/SerializePathingEngine.cpp.o CMakeFiles/freeorioncommon.dir/util/SerializeUniverse.cpp.o CMakeFiles/freeorioncommon.dir/util/SitRepEntry.cpp.o CMakeFiles/freeorioncommon.dir/util/StringTable.cpp.o CMakeFiles/freeorioncommon.dir/util/VarText.cpp.o CMakeFiles/freeorioncommon.dir/util/XMLDoc.cpp.o CMakeFiles/freeorioncommon.dir/util/Version.cpp.o CMakeFiles/freeorioncommon.dir/util/binreloc.c.o -lboost_chrono -lboost_date_time -lboost_filesystem -lboost_regex -lboost_serialization -lboost_signals -lboost_system -lboost_thread -lz -llog4cpp -Wl,-rpath,::::::::::::::::::::::::::::::::
CMakeFiles/freeorioncommon.dir/Empire/Empire.cpp.o: In function AlignmentManager': /home/akien/Mageia/Checkout/freeorion/BUILD/freeorion-0.4.4/FreeOrion/Empire/Empire.cpp:1133: undefined reference toparse::alignments(boost::filesystem::path const&, std::vector<alignment, std::allocator\<alignment=""> >&, std::vector<boost::shared_ptr\<effect::effectsgroup const="">, std::allocator\<boost::shared_ptr\<effect::effectsgroup const=""> > >&)'
CMakeFiles/freeorioncommon.dir/universe/Building.cpp.o: In function BuildingTypeManager::BuildingTypeManager()': /home/akien/Mageia/Checkout/freeorion/BUILD/freeorion-0.4.4/FreeOrion/universe/Building.cpp:333: undefined reference toparse::buildings(boost::filesystem::path const&, std::map<std::string, buildingtype*,="" std::less\<std::string="">, std::allocator\<std::pair\<std::string const,="" buildingtype*=""> > >&)'
CMakeFiles/freeorioncommon.dir/universe/Field.cpp.o: In function FieldTypeManager::FieldTypeManager()': /home/akien/Mageia/Checkout/freeorion/BUILD/freeorion-0.4.4/FreeOrion/universe/Field.cpp:227: undefined reference toparse::fields(boost::filesystem::path const&, std::map<std::string, fieldtype*,="" std::less\<std::string="">, std::allocator\<std::pair\<std::string const,="" fieldtype*=""> > >&)'
CMakeFiles/freeorioncommon.dir/universe/ShipDesign.cpp.o: In function HullTypeManager::HullTypeManager()': /home/akien/Mageia/Checkout/freeorion/BUILD/freeorion-0.4.4/FreeOrion/universe/ShipDesign.cpp:576: undefined reference toparse::ship_hulls(boost::filesystem::path const&, std::map<std::string, hulltype*,="" std::less\<std::string="">, std::allocator\<std::pair\<std::string const,="" hulltype*=""> > >&)'
CMakeFiles/freeorioncommon.dir/universe/ShipDesign.cpp.o: In function PredefinedShipDesignManager::PredefinedShipDesignManager()': /home/akien/Mageia/Checkout/freeorion/BUILD/freeorion-0.4.4/FreeOrion/universe/ShipDesign.cpp:1147: undefined reference toparse::ship_designs(boost::filesystem::path const&, std::map<std::string, shipdesign*,="" std::less\<std::string="">, std::allocator\<std::pair\<std::string const,="" shipdesign*=""> > >&)'
/home/akien/Mageia/Checkout/freeorion/BUILD/freeorion-0.4.4/FreeOrion/universe/ShipDesign.cpp:1149: undefined reference to parse::ship_designs(boost::filesystem::path const&, std::map<std::string, ShipDesign*, std::less<std::string>, std::allocator<std::pair<std::string const, ShipDesign*> > >&)' CMakeFiles/freeorioncommon.dir/universe/ShipDesign.cpp.o: In functionPartTypeManager::PartTypeManager()':
/home/akien/Mageia/Checkout/freeorion/BUILD/freeorion-0.4.4/FreeOrion/universe/ShipDesign.cpp:135: undefined reference to parse::ship_parts(boost::filesystem::path const&, std::map<std::string, PartType*, std::less<std::string>, std::allocator<std::pair<std::string const, PartType*> > >&)' CMakeFiles/freeorioncommon.dir/universe/Special.cpp.o: In functionSpecialManager':
/home/akien/Mageia/Checkout/freeorion/BUILD/freeorion-0.4.4/FreeOrion/universe/Special.cpp:16: undefined reference to parse::specials(boost::filesystem::path const&, std::map<std::string, Special*, std::less<std::string>, std::allocator<std::pair<std::string const, Special*> > >&)' CMakeFiles/freeorioncommon.dir/universe/Species.cpp.o: In functionSpeciesManager::SpeciesManager()':
/home/akien/Mageia/Checkout/freeorion/BUILD/freeorion-0.4.4/FreeOrion/universe/Species.cpp:267: undefined reference to parse::species(boost::filesystem::path const&, std::map<std::string, Species*, std::less<std::string>, std::allocator<std::pair<std::string const, Species*> > >&)' CMakeFiles/freeorioncommon.dir/universe/Tech.cpp.o: In functionTechManager::TechManager()':
/home/akien/Mageia/Checkout/freeorion/BUILD/freeorion-0.4.4/FreeOrion/universe/Tech.cpp:320: undefined reference to parse::techs(boost::filesystem::path const&, boost::multi_index::multi_index_container<Tech const*, boost::multi_index::indexed_by<boost::multi_index::ordered_non_unique<boost::multi_index::tag<TechManager::CategoryIndex, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::multi_index::const_mem_fun<Tech, std::string const&, &(Tech::Category() const)>, mpl_::na>, boost::multi_index::ordered_unique<boost::multi_index::tag<TechManager::NameIndex, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::multi_index::const_mem_fun<Tech, std::string const&, &(Tech::Name() const)>, mpl_::na>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, std::allocator<Tech const*> >&, std::map<std::string, TechCategory*, std::less<std::string>, std::allocator<std::pair<std::string const, TechCategory*> > >&, std::set<std::string, std::less<std::string>, std::allocator<std::string> >&)' CMakeFiles/freeorioncommon.dir/universe/Universe.cpp.o: In functionEmpireStatistics::GetEmpireStats()':
/home/akien/Mageia/Checkout/freeorion/BUILD/freeorion-0.4.4/FreeOrion/universe/Universe.cpp:421: undefined reference to `parse::statistics(boost::filesystem::path const&, std::map<std::string, valueref::valuerefbase\<double=""> const*, std::less\<std::string>, std::allocator\<std::pair\<std::string const,="" valueref::valuerefbase\<double=""> const*> > >&)'
collect2: error: ld returned 1 exit status
CMakeFiles/freeorioncommon.dir/build.make:1848: recipe for target 'libfreeorioncommon.so' failed
make[2]: *** [libfreeorioncommon.so] Error 1
make[2]: Leaving directory '/home/akien/Mageia/Checkout/freeorion/BUILD/freeorion-0.4.4/FreeOrion'
CMakeFiles/Makefile2:63: recipe for target 'CMakeFiles/freeorioncommon.dir/all' failed
make[1]: *** [CMakeFiles/freeorioncommon.dir/all] Error 2
make[1]: Leaving directory '/home/akien/Mageia/Checkout/freeorion/BUILD/freeorion-0.4.4/FreeOrion'
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2</std::pair\<std::string></std::string></std::string,></std::pair\<std::string></std::string,></std::pair\<std::string></std::string,></std::pair\<std::string></std::string,></std::pair\<std::string></std::string,></boost::shared_ptr\<effect::effectsgroup></boost::shared_ptr\<effect::effectsgroup></alignment,>

Discussion

  • Rémi Verschelde

    Actually this might be more than an underlinking issue with -Wl,--as-needed, in the end I had to also remove the -Wl,--no-undefined flag to be able to built FreeOrion.

    This is with a development snapshot of gcc 4.9.2 btw.

     

    Last edit: Rémi Verschelde 2014-09-12
  • Dilvish

    Dilvish - 2014-09-30

    Looks like you already figured this out; we'd agree that it's actually Mageia's default flag -Wl,--no-undefined that is most likely triggering this error rather than -Wl,--as-needed. Instead of totally dropping -Wl,--no-undefined, a lesser-change solution might be to try adding
    -Wl,--allow-shlib-undefined
    for freeorioncommon. Our forum discussion of this can be found at http://www.freeorion.org/forum/viewtopic.php?f=9&t=9098 in case you want to add anything there.

     
  • Geoff Topping

    Geoff Topping - 2014-10-13
    • status: open --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB