lief-project / LIEF

LIEF - Library to Instrument Executable Formats (C++, Python, Rust)
https://lief.re
Apache License 2.0
4.5k stars 624 forks source link

[examples] Compilation failed: undefined reference to `LIEF::ELF::Parser::parse #251

Closed blshkv closed 5 years ago

blshkv commented 5 years ago

Hi Romain,

I'm trying to compile the latest commit 8d7ec26a93800b0729c2c05be8c55c8318ba3b20 and facing the following issue:

[604/625] : && /usr/bin/x86_64-pc-linux-gnu-g++ -fPIC -march=native -O2 -pipe -frecord-gcc-switches  -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 -shared -Wl,-soname,libLIEF.so -o libLIEF.so CMakeFiles/LIB_LIEF.dir/lief_easyloggingpp-prefix/src/lief_easyloggingpp/src/easylogging++.cc.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/aes.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/aesni.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/arc4.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/asn1parse.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/asn1write.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/base64.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/bignum.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/blowfish.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/camellia.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/ccm.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/cipher.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/cipher_wrap.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/cmac.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/ctr_drbg.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/des.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/dhm.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/ecdh.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/ecdsa.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/ecjpake.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/ecp.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/ecp_curves.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/entropy.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/entropy_poll.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/error.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/gcm.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/havege.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/hmac_drbg.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/md.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/md2.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/md4.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/md5.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/md_wrap.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/memory_buffer_alloc.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/oid.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/padlock.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/pem.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/pk.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/pk_wrap.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/pkcs12.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/pkcs5.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/pkparse.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/pkwrite.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/platform.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/ripemd160.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/rsa.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/sha1.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/sha256.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/sha512.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/threading.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/timing.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/version.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/version_features.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/xtea.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/certs.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/pkcs11.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/x509.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/x509_create.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/x509_crl.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/x509_crt.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/x509_csr.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/x509write_crt.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/x509write_csr.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/debug.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/net_sockets.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/ssl_cache.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/ssl_ciphersuites.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/ssl_cli.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/ssl_cookie.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/ssl_srv.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/ssl_ticket.c.o CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/ssl_tls.c.o CMakeFiles/LIB_LIEF.dir/src/logging.cpp.o CMakeFiles/LIB_LIEF.dir/src/exception.cpp.o CMakeFiles/LIB_LIEF.dir/src/iostream.cpp.o CMakeFiles/LIB_LIEF.dir/src/utils.cpp.o CMakeFiles/LIB_LIEF.dir/src/Object.cpp.o CMakeFiles/LIB_LIEF.dir/src/Visitor.cpp.o CMakeFiles/LIB_LIEF.dir/src/BinaryStream/BinaryStream.cpp.o CMakeFiles/LIB_LIEF.dir/src/BinaryStream/VectorStream.cpp.o CMakeFiles/LIB_LIEF.dir/src/BinaryStream/Convert.cpp.o CMakeFiles/LIB_LIEF.dir/src/visitors/hash.cpp.o CMakeFiles/LIB_LIEF.dir/src/visitors/json.cpp.o CMakeFiles/LIB_LIEF.dir/src/Abstract/Binary.cpp.o CMakeFiles/LIB_LIEF.dir/src/Abstract/Symbol.cpp.o CMakeFiles/LIB_LIEF.dir/src/Abstract/EnumToString.cpp.o CMakeFiles/LIB_LIEF.dir/src/Abstract/Header.cpp.o CMakeFiles/LIB_LIEF.dir/src/Abstract/Section.cpp.o CMakeFiles/LIB_LIEF.dir/src/Abstract/Parser.cpp.o CMakeFiles/LIB_LIEF.dir/src/Abstract/Relocation.cpp.o CMakeFiles/LIB_LIEF.dir/src/Abstract/Function.cpp.o CMakeFiles/LIB_LIEF.dir/src/Abstract/hash.cpp.o CMakeFiles/LIB_LIEF.dir/src/Abstract/json.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/Convert.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/DynamicEntryArray.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/utils.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/SymbolVersionRequirement.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/SymbolVersionAuxRequirement.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/Binary.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/Symbol.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/EnumToString.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/Header.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/DynamicSharedObject.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/Segment.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/Section.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/SymbolVersionAux.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/GnuHash.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/SysvHash.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/SymbolVersion.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/Builder.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/DynamicEntryLibrary.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/DataHandler/Node.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/DataHandler/Handler.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/Parser.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/Relocation.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/DynamicEntryRunPath.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/SymbolVersionDefinition.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/DynamicEntry.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/DynamicEntryRpath.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/DynamicEntryFlags.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/hash.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/Note.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/AndroidNote.cpp.o CMakeFiles/LIB_LIEF.dir/src/ELF/json.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/utils.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/ExportEntry.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/Binary.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/Symbol.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/EnumToString.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/Header.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/DosHeader.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/RichHeader.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/RichEntry.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/ResourceDirectory.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/Import.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/ResourceNode.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/Export.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/Section.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/OptionalHeader.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/Builder.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/Parser.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/ResourcesManager.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/Relocation.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/TLS.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/Debug.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/CodeView.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/CodeViewPDB.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/Pogo.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/PogoEntry.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/ImportEntry.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/ResourceData.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/RelocationEntry.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/DataDirectory.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/CodeIntegrity.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/signature/AuthenticatedAttributes.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/signature/ContentInfo.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/signature/Signature.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/signature/SignerInfo.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/signature/x509.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/signature/OIDToString.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/signature/SignatureParser.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/resources/ResourceVersion.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/resources/ResourceDialog.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/resources/ResourceDialogItem.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/resources/ResourceFixedFileInfo.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/resources/ResourceVarFileInfo.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/resources/ResourceStringFileInfo.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/resources/LangCodeItem.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/resources/ResourceIcon.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/json.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/hash.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/LoadConfigurations/LoadConfiguration.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/LoadConfigurations/LoadConfigurationV0.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/LoadConfigurations/LoadConfigurationV1.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/LoadConfigurations/LoadConfigurationV2.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/LoadConfigurations/LoadConfigurationV3.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/LoadConfigurations/LoadConfigurationV4.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/LoadConfigurations/LoadConfigurationV5.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/LoadConfigurations/LoadConfigurationV6.cpp.o CMakeFiles/LIB_LIEF.dir/src/PE/LoadConfigurations/LoadConfigurationV7.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/utils.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/Binary.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/UUIDCommand.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/Symbol.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/FatBinary.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/EnumToString.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/Header.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/DynamicSymbolCommand.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/Section.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/LoadCommand.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/BinaryParser.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/Builder.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/SegmentCommand.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/Parser.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/SymbolCommand.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/MainCommand.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/DylibCommand.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/DylinkerCommand.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/DyldInfo.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/FunctionStarts.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/SourceVersion.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/VersionMin.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/Relocation.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/RelocationObject.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/RelocationDyld.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/BindingInfo.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/ExportInfo.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/ThreadCommand.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/RPathCommand.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/ParserConfig.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/hash.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/CodeSignature.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/SegmentSplitInfo.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/DataInCode.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/DataCodeEntry.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/SubFramework.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/DyldEnvironment.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/EncryptionInfo.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/TrieNode.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/BuildVersion.cpp.o CMakeFiles/LIB_LIEF.dir/src/MachO/json.cpp.o CMakeFiles/LIB_LIEF.dir/src/OAT/Parser.cpp.o CMakeFiles/LIB_LIEF.dir/src/OAT/Binary.cpp.o CMakeFiles/LIB_LIEF.dir/src/OAT/Header.cpp.o CMakeFiles/LIB_LIEF.dir/src/OAT/DexFile.cpp.o CMakeFiles/LIB_LIEF.dir/src/OAT/Class.cpp.o CMakeFiles/LIB_LIEF.dir/src/OAT/Method.cpp.o CMakeFiles/LIB_LIEF.dir/src/OAT/EnumToString.cpp.o CMakeFiles/LIB_LIEF.dir/src/OAT/utils.cpp.o CMakeFiles/LIB_LIEF.dir/src/OAT/hash.cpp.o CMakeFiles/LIB_LIEF.dir/src/OAT/json.cpp.o CMakeFiles/LIB_LIEF.dir/src/DEX/Parser.cpp.o CMakeFiles/LIB_LIEF.dir/src/DEX/File.cpp.o CMakeFiles/LIB_LIEF.dir/src/DEX/EnumToString.cpp.o CMakeFiles/LIB_LIEF.dir/src/DEX/Header.cpp.o CMakeFiles/LIB_LIEF.dir/src/DEX/Class.cpp.o CMakeFiles/LIB_LIEF.dir/src/DEX/Method.cpp.o CMakeFiles/LIB_LIEF.dir/src/DEX/instructions.cpp.o CMakeFiles/LIB_LIEF.dir/src/DEX/CodeInfo.cpp.o CMakeFiles/LIB_LIEF.dir/src/DEX/Type.cpp.o CMakeFiles/LIB_LIEF.dir/src/DEX/Prototype.cpp.o CMakeFiles/LIB_LIEF.dir/src/DEX/MapList.cpp.o CMakeFiles/LIB_LIEF.dir/src/DEX/MapItem.cpp.o CMakeFiles/LIB_LIEF.dir/src/DEX/utils.cpp.o CMakeFiles/LIB_LIEF.dir/src/DEX/hash.cpp.o CMakeFiles/LIB_LIEF.dir/src/DEX/json.cpp.o CMakeFiles/LIB_LIEF.dir/src/VDEX/Parser.cpp.o CMakeFiles/LIB_LIEF.dir/src/VDEX/File.cpp.o CMakeFiles/LIB_LIEF.dir/src/VDEX/EnumToString.cpp.o CMakeFiles/LIB_LIEF.dir/src/VDEX/Header.cpp.o CMakeFiles/LIB_LIEF.dir/src/VDEX/utils.cpp.o CMakeFiles/LIB_LIEF.dir/src/VDEX/hash.cpp.o CMakeFiles/LIB_LIEF.dir/src/VDEX/json.cpp.o CMakeFiles/LIB_LIEF.dir/src/ART/Parser.cpp.o CMakeFiles/LIB_LIEF.dir/src/ART/File.cpp.o CMakeFiles/LIB_LIEF.dir/src/ART/EnumToString.cpp.o CMakeFiles/LIB_LIEF.dir/src/ART/Header.cpp.o CMakeFiles/LIB_LIEF.dir/src/ART/utils.cpp.o CMakeFiles/LIB_LIEF.dir/src/ART/Structures.cpp.o CMakeFiles/LIB_LIEF.dir/src/ART/hash.cpp.o CMakeFiles/LIB_LIEF.dir/src/ART/json.cpp.o CMakeFiles/LIB_LIEF.dir/src/platforms/android/version.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/ELF/Symbol.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/ELF/Section.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/ELF/Segment.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/ELF/DynamicEntry.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/ELF/Header.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/ELF/Binary.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/ELF/EnumToString.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/ELF/utils.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/PE/Binary.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/PE/DosHeader.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/PE/Header.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/PE/OptionalHeader.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/PE/Section.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/PE/DataDirectory.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/PE/EnumToString.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/PE/Import.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/PE/ImportEntry.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/MachO/EnumToString.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/MachO/Parser.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/MachO/LoadCommand.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/MachO/Segment.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/MachO/Symbol.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/MachO/Section.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/MachO/Header.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/MachO/Binary.cpp.o CMakeFiles/LIB_LIEF.dir/api/c/logging.cpp.o   && :
[605/625] : && /usr/bin/x86_64-pc-linux-gnu-g++  -march=native -O2 -pipe -frecord-gcc-switches  -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 examples/cpp/CMakeFiles/elf_builder.dir/elf_builder.cpp.o  -o examples/cpp/elf_builder  -Wl,-rpath,/var/tmp/portage/dev-util/lief-0.9.0_p20181231/work/lief-0.9.0_p20181231_build libLIEF.so && :
FAILED: examples/cpp/elf_builder 
: && /usr/bin/x86_64-pc-linux-gnu-g++  -march=native -O2 -pipe -frecord-gcc-switches  -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 examples/cpp/CMakeFiles/elf_builder.dir/elf_builder.cpp.o  -o examples/cpp/elf_builder  -Wl,-rpath,/var/tmp/portage/dev-util/lief-0.9.0_p20181231/work/lief-0.9.0_p20181231_build libLIEF.so && :
examples/cpp/CMakeFiles/elf_builder.dir/elf_builder.cpp.o: In function `main':
elf_builder.cpp:(.text.startup+0x68): undefined reference to `LIEF::ELF::Parser::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, LIEF::ELF::DYNSYM_COUNT_METHODS)'
collect2: error: ld returned 1 exit status
[606/625] : && /usr/bin/x86_64-pc-linux-gnu-g++  -march=native -O2 -pipe -frecord-gcc-switches  -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 examples/cpp/CMakeFiles/dex_reader.dir/dex_reader.cpp.o  -o examples/cpp/dex_reader  -Wl,-rpath,/var/tmp/portage/dev-util/lief-0.9.0_p20181231/work/lief-0.9.0_p20181231_build libLIEF.so && :
FAILED: examples/cpp/dex_reader 
: && /usr/bin/x86_64-pc-linux-gnu-g++  -march=native -O2 -pipe -frecord-gcc-switches  -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 examples/cpp/CMakeFiles/dex_reader.dir/dex_reader.cpp.o  -o examples/cpp/dex_reader  -Wl,-rpath,/var/tmp/portage/dev-util/lief-0.9.0_p20181231/work/lief-0.9.0_p20181231_build libLIEF.so && :
examples/cpp/CMakeFiles/dex_reader.dir/dex_reader.cpp.o: In function `main':
dex_reader.cpp:(.text.startup+0x23): undefined reference to `LIEF::Logger::set_level(LIEF::LOGGING_LEVEL)'
dex_reader.cpp:(.text.startup+0xf8): undefined reference to `LIEF::DEX::Parser::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
examples/cpp/CMakeFiles/dex_reader.dir/dex_reader.cpp.o:(.data.DW.ref._ZTIN4LIEF9exceptionE[DW.ref._ZTIN4LIEF9exceptionE]+0x0): undefined reference to `typeinfo for LIEF::exception'
collect2: error: ld returned 1 exit status
[607/625] : && /usr/bin/x86_64-pc-linux-gnu-g++  -march=native -O2 -pipe -frecord-gcc-switches  -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 examples/cpp/CMakeFiles/elf_reader.dir/elf_reader.cpp.o  -o examples/cpp/elf_reader  -Wl,-rpath,/var/tmp/portage/dev-util/lief-0.9.0_p20181231/work/lief-0.9.0_p20181231_build libLIEF.so && :
FAILED: examples/cpp/elf_reader 
: && /usr/bin/x86_64-pc-linux-gnu-g++  -march=native -O2 -pipe -frecord-gcc-switches  -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 examples/cpp/CMakeFiles/elf_reader.dir/elf_reader.cpp.o  -o examples/cpp/elf_reader  -Wl,-rpath,/var/tmp/portage/dev-util/lief-0.9.0_p20181231/work/lief-0.9.0_p20181231_build libLIEF.so && :
examples/cpp/CMakeFiles/elf_reader.dir/elf_reader.cpp.o: In function `main':
elf_reader.cpp:(.text.startup+0x23): undefined reference to `LIEF::Logger::set_level(LIEF::LOGGING_LEVEL)'
elf_reader.cpp:(.text.startup+0x101): undefined reference to `LIEF::ELF::Parser::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, LIEF::ELF::DYNSYM_COUNT_METHODS)'
elf_reader.cpp:(.text.startup+0x126): undefined reference to `LIEF::ELF::Binary::functions() const'
examples/cpp/CMakeFiles/elf_reader.dir/elf_reader.cpp.o:(.data.DW.ref._ZTIN4LIEF9exceptionE[DW.ref._ZTIN4LIEF9exceptionE]+0x0): undefined reference to `typeinfo for LIEF::exception'
collect2: error: ld returned 1 exit status

Disclamer: I'm NOT using docker, my environment specs are the following:

emerge --info
Portage 2.3.51 (python 3.6.5-final-0, default/linux/amd64/17.0/hardened, gcc-7.3.0, glibc-2.27-r6, 4.19.1-pentoo x86_64)
=================================================================
System uname: Linux-4.19.1-pentoo-x86_64-Intel-R-_Core-TM-_i5-3320M_CPU_@_2.60GHz-with-gentoo-2.6
KiB Mem:     7970736 total,   3606968 free
KiB Swap:    4194300 total,   3623576 free
Timestamp of repository gentoo: Thu, 03 Jan 2019 01:15:01 +0000
Head commit of repository gentoo: 06b89f118b035c337cd85661d337cb62b83014e3
Head commit of repository pentoo: 024fe3f06c8a699446c6310f22b92a2288b192c8

sh bash 4.4_p12
ld GNU ld (Gentoo 2.30 p5) 2.30.0
app-shells/bash:          4.4_p12::gentoo
dev-java/java-config:     2.2.0-r4::gentoo
dev-lang/perl:            5.24.3-r1::gentoo
dev-lang/python:          2.7.15::gentoo, 3.6.5::gentoo
dev-util/cmake:           3.9.6::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.6-r1::gentoo
sys-apps/openrc:          0.38.3-r1::gentoo
sys-apps/sandbox:         2.13::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r4::gentoo
sys-devel/automake:       1.11.6-r3::gentoo, 1.13.4-r2::gentoo, 1.16.1-r1::gentoo
sys-devel/binutils:       2.30-r4::gentoo
sys-devel/gcc:            7.3.0-r3::gentoo
sys-devel/gcc-config:     2.0::gentoo
sys-devel/libtool:        2.4.6-r3::gentoo
sys-devel/make:           4.2.1-r4::gentoo
sys-kernel/linux-headers: 4.14-r1::gentoo (virtual/os-headers)
sys-libs/glibc:           2.27-r6::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.asia.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-verify-jobs: 1
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-metamanifest: yes
    sync-rsync-extra-opts: 

local-overlay
    location: /usr/local/portage
    masters: gentoo
    priority: 0

pentoo
    location: /var/db/overlays/pentoo-overlay
    sync-type: git
    sync-uri: https://github.com/pentoo/pentoo-overlay
    masters: gentoo

steam-overlay
    location: /var/db/overlays/steam-overlay
    masters: gentoo
    priority: 50

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA OPERA-12 NVIDIA-CUDA PUEL AdobeFlash-11.x Google-TOS dlj-1.1 google-chrome Oracle-BCLA-JavaSE Intel-SDP skype-4.0.0.7-copyright baudline"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe -frecord-gcc-switches"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /etc/stunnel/stunnel.conf /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/easy-rsa /usr/share/gnupg/qualified.txt /usr/share/themes/oxygen-gtk/gtk-2.0"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php7.2/ext-active/ /etc/php/cgi-php7.2/ext-active/ /etc/php/cli-php7.2/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=native -O2 -pipe -frecord-gcc-switches"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--load-average=3.6 --quiet-build"
ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-O2 -pipe -frecord-gcc-switches -frecord-gcc-switches"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync multilib-strict news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe -frecord-gcc-switches -frecord-gcc-switches"
GENTOO_MIRRORS="http://gentoo.aditsu.net:8000/"
INSTALL_MASK="*.la"
LANG="en_SG.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0"
LINGUAS="en ru"
MAKEOPTS="-j4"
PKGDIR="/usr/portage/packages"
PORTAGE_BINHOST="https://mirror.astr.al/pentoo/Packages/amd64-hardened/"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_EXTRA_OPTS="--omit-dir-times"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="X a52 aac acl acpi activities alsa amd64 branding bzip2 cairo cdda consolekit crypt cups cxx dbus declarative dri dri3 dts dvdr emboss encode exif ffmpeg flac gif glamor gtk hackrf hardened iconv ipv6 jpeg kde kipi kwallet lcms libnotify libtirpc mad minipentoo mng modemmanager mp3 mp4 mpeg multilib ncurses networkmanager nls nptl ogg opengl openmp pam pango pax_kernel pcre pdf phonon pie plasma png policykit ppds qml qt5 readline samba sdl seccomp semantic-desktop spell ssl ssp startup-notification svg tiff truetype udev udisks unicode upower usb vaapi vlc vorbis widgets wxwidgets x264 xattr xcb xcomposite xinerama xml xtpax xv xvid zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon plan sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" L10N="en ru" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6 php7-1" POSTGRES_TARGETS="postgres9_5 postgres10" PYTHON_SINGLE_TARGET="python3_6" PYTHON_TARGETS="python2_7 python3_6" RUBY_TARGETS="ruby24" UNICORN_TARGETS="x86" USERLAND="GNU" VIDEO_CARDS="vesa intel i965" XFCE_PLUGINS="brightness menu logout trash" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS
blshkv commented 5 years ago

The full log is 1M, uploaded in two parts here: https://gist.github.com/blshkv/7f986646214fdeb8ca6c0f98309ce5d6 https://gist.github.com/blshkv/034704924e21cd09420f46e7b560dfe5

blshkv commented 5 years ago

https://gcc.gnu.org/wiki/Cxx11AbiCompatibility https://stackoverflow.com/questions/33394934/converting-std-cxx11string-to-stdstring

So what would be a workaround / solution?

romainthomas commented 5 years ago

Do you use cmake to compile LIEF ?

blshkv commented 5 years ago

Yes

blshkv commented 5 years ago

from the provided logs: https://gist.github.com/blshkv/7f986646214fdeb8ca6c0f98309ce5d6#file-build-log-L19

The issue is much deeper and related to gcc ABI compatibility.

romainthomas commented 5 years ago

Actually LIEF requires C++11 and compilation is ok on:

If you manage to understand why it fails, I would be glad to integrate your fix

blshkv commented 5 years ago

Ok, this is messy. CMakeLists.txt has the following initial setting: set_property(TARGET LIB_LIEF PROPERTY CXX_STANDARD 11) but later it changes to:

if (LIEF_SUPPORT_CXX14) 
target_compile_features(LIB_LIEF PRIVATE cxx_std_14)

api/python is also choose cxx_std_14 if it's available

However, everything else is getting compiled with CXX_STANDARD 11

ScottEgerton commented 5 years ago

Hi, I'm also getting undefined reference to LIEF::ELF::Parser::parse as well as undefined reference to LIEF::ELF::Binary::get_section.

I downloaded version 0.9.0 for Linux from here and I'm using the recommended CMake find_package integration from here.

My project is using C++17.

Is there anything I'm doing wrong or any way I can get this working?

romainthomas commented 5 years ago

Did you link against the static library or the shared one ?

ScottEgerton commented 5 years ago

I've tried both with the same result.

I'm trying to build my project as a shared library.

romainthomas commented 5 years ago

Could you share minimal project to reproduce it ?

ScottEgerton commented 5 years ago

I had a look into this and it seems that when I build my project as a library there are no issues. It is only when I try to link against my library.

I've tried to create a minimal project: LIEF-minimal-example.zip

I've assumed that LIEF will be in a folder in the same directory called 'LIEF-0.9.0-Linux' but this can be changed using the -DLIEF_ROOT flag as shown in the CMake example

romainthomas commented 5 years ago

OK I can reproduce the problem. It weird because clang 8 seems to correctly export the symbol but GCC don't. This commit https://github.com/lief-project/LIEF/commit/35805fb598a0a737135eeae8ed60dd019f0b05af should fix it

blshkv commented 5 years ago

still unable to compile examples, it fails similarly:

[621/641] : && /usr/bin/x86_64-pc-linux-gnu-g++  -march=native -O2 -pipe -frecord-gcc-switches  -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 examples/cpp/CMakeFiles/elf_builder.dir/elf_builder.cpp.o  -o examples/cpp/elf_builder  -Wl,-rpath,/var/tmp/portage/dev-util/lief-0.9.0_p20190504/work/lief-0.9.0_p20190504_build libLIEF.so && :
FAILED: examples/cpp/elf_builder 
: && /usr/bin/x86_64-pc-linux-gnu-g++  -march=native -O2 -pipe -frecord-gcc-switches  -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 examples/cpp/CMakeFiles/elf_builder.dir/elf_builder.cpp.o  -o examples/cpp/elf_builder  -Wl,-rpath,/var/tmp/portage/dev-util/lief-0.9.0_p20190504/work/lief-0.9.0_p20190504_build libLIEF.so && :
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: examples/cpp/CMakeFiles/elf_builder.dir/elf_builder.cpp.o: in function `main':
elf_builder.cpp:(.text.startup+0x68): undefined reference to `LIEF::ELF::Parser::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, LIEF::ELF::DYNSYM_COUNT_METHODS)'
collect2: error: ld returned 1 exit status
[622/641] : && /usr/bin/x86_64-pc-linux-gnu-g++  -march=native -O2 -pipe -frecord-gcc-switches  -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 examples/cpp/CMakeFiles/elf_reader.dir/elf_reader.cpp.o  -o examples/cpp/elf_reader  -Wl,-rpath,/var/tmp/portage/dev-util/lief-0.9.0_p20190504/work/lief-0.9.0_p20190504_build libLIEF.so && :
FAILED: examples/cpp/elf_reader 
: && /usr/bin/x86_64-pc-linux-gnu-g++  -march=native -O2 -pipe -frecord-gcc-switches  -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 examples/cpp/CMakeFiles/elf_reader.dir/elf_reader.cpp.o  -o examples/cpp/elf_reader  -Wl,-rpath,/var/tmp/portage/dev-util/lief-0.9.0_p20190504/work/lief-0.9.0_p20190504_build libLIEF.so && :
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: examples/cpp/CMakeFiles/elf_reader.dir/elf_reader.cpp.o: in function `main':
elf_reader.cpp:(.text.startup+0x23): undefined reference to `LIEF::Logger::set_level(LIEF::LOGGING_LEVEL)'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: elf_reader.cpp:(.text.startup+0x101): undefined reference to `LIEF::ELF::Parser::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, LIEF::ELF::DYNSYM_COUNT_METHODS)'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: elf_reader.cpp:(.text.startup+0x126): undefined reference to `LIEF::ELF::Binary::functions() const'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: examples/cpp/CMakeFiles/elf_reader.dir/elf_reader.cpp.o:(.data.rel.local.DW.ref._ZTIN4LIEF9exceptionE[DW.ref._ZTIN4LIEF9exceptionE]+0x0): undefined reference to `typeinfo for LIEF::exception'
collect2: error: ld returned 1 exit status
[623/641] : && /usr/bin/x86_64-pc-linux-gnu-g++  -march=native -O2 -pipe -frecord-gcc-switches  -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 examples/cpp/CMakeFiles/dex_reader.dir/dex_reader.cpp.o  -o examples/cpp/dex_reader  -Wl,-rpath,/var/tmp/portage/dev-util/lief-0.9.0_p20190504/work/lief-0.9.0_p20190504_build libLIEF.so && :
FAILED: examples/cpp/dex_reader 
: && /usr/bin/x86_64-pc-linux-gnu-g++  -march=native -O2 -pipe -frecord-gcc-switches  -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 examples/cpp/CMakeFiles/dex_reader.dir/dex_reader.cpp.o  -o examples/cpp/dex_reader  -Wl,-rpath,/var/tmp/portage/dev-util/lief-0.9.0_p20190504/work/lief-0.9.0_p20190504_build libLIEF.so && :
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: examples/cpp/CMakeFiles/dex_reader.dir/dex_reader.cpp.o: in function `main':
dex_reader.cpp:(.text.startup+0x23): undefined reference to `LIEF::Logger::set_level(LIEF::LOGGING_LEVEL)'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: dex_reader.cpp:(.text.startup+0xf5): undefined reference to `LIEF::DEX::Parser::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: examples/cpp/CMakeFiles/dex_reader.dir/dex_reader.cpp.o:(.data.rel.local.DW.ref._ZTIN4LIEF9exceptionE[DW.ref._ZTIN4LIEF9exceptionE]+0x0): undefined reference to `typeinfo for LIEF::exception'
collect2: error: ld returned 1 exit status
romainthomas commented 5 years ago

After further investigation the root cause seems to be GLIBCXX_USE_CXX11_ABI that is set to 0 on CI. It produces std::string symbols instead of std::__cxx11::basic_string<...>

romainthomas commented 5 years ago

@ScottEgerton I checked with the nightly package: https://lief-project.github.io/packages/sdk/ and it works. @blshkv Could you also check we new packages ?

blshkv commented 5 years ago

nop, did not help

ScottEgerton commented 5 years ago

Thanks for looking into this. I just tried the nightly package and it links successfully for me now.

blshkv commented 5 years ago

can you give me a hint how to apply the same fix for the latest git? The current fix (https://github.com/lief-project/LIEF/commit/27a03a6fd3169f427fb950293f0863dcd50ac710) did not work for me

blshkv commented 5 years ago

btw, out of curiosity, I have changed the line https://github.com/lief-project/LIEF/blob/master/CMakeLists.txt#L158 to cxx_std_11 to make sure that everything is compiled with one API and got a new error. Perhaps, everything should be compiled with CXX14 then?

The error is:

>>> Working in BUILD_DIR: "/var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/lief-0.9.0_p20190505_build"
ninja -v -j4 -l0
[1/230] /usr/bin/x86_64-pc-linux-gnu-g++ -DELPP_DISABLE_DEFAULT_CRASH_HANDLING -DELPP_HANDLE_SIGABRT=0 -DELPP_NO_DEFAULT_LOG_FILE -DLIB_LIEF_EXPORTS -DLIEF_STATIC -DVDEBUG=9 -D_GLIBCXX_USE_CXX11_ABI=1 -Ilief_libjson-prefix/src/lief_libjson -I/var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/LIEF-27a03a6fd3169f427fb950293f0863dcd50ac710/include -I/var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/LIEF-27a03a6fd3169f427fb950293f0863dcd50ac710/api/c/include -Iinclude -Ilief_frozen-prefix/src/lief_frozen/include -Ilief_rang_cpp_color-prefix/src/lief_rang_cpp_color/include -I/var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/LIEF-27a03a6fd3169f427fb950293f0863dcd50ac710/src -I. -Ilief_easyloggingpp-prefix/src/lief_easyloggingpp/src -Imbed_tls/src/lief_mbed_tls/include -I/var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/LIEF-27a03a6fd3169f427fb950293f0863dcd50ac710/include/LIEF  -march=native -O2 -pipe -frecord-gcc-switches -fPIC -fvisibility=hidden   -Wall -Wextra -Wpedantic -fno-stack-protector -fomit-frame-pointer -fno-strict-aliasing -fexceptions -fvisibility=hidden -Wno-expansion-to-defined -fdiagnostics-color=always -std=gnu++11 -MD -MT CMakeFiles/LIB_LIEF.dir/src/Abstract/EnumToString.cpp.o -MF CMakeFiles/LIB_LIEF.dir/src/Abstract/EnumToString.cpp.o.d -o CMakeFiles/LIB_LIEF.dir/src/Abstract/EnumToString.cpp.o -c /var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/LIEF-27a03a6fd3169f427fb950293f0863dcd50ac710/src/Abstract/EnumToString.cpp
FAILED: CMakeFiles/LIB_LIEF.dir/src/Abstract/EnumToString.cpp.o 
/usr/bin/x86_64-pc-linux-gnu-g++ -DELPP_DISABLE_DEFAULT_CRASH_HANDLING -DELPP_HANDLE_SIGABRT=0 -DELPP_NO_DEFAULT_LOG_FILE -DLIB_LIEF_EXPORTS -DLIEF_STATIC -DVDEBUG=9 -D_GLIBCXX_USE_CXX11_ABI=1 -Ilief_libjson-prefix/src/lief_libjson -I/var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/LIEF-27a03a6fd3169f427fb950293f0863dcd50ac710/include -I/var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/LIEF-27a03a6fd3169f427fb950293f0863dcd50ac710/api/c/include -Iinclude -Ilief_frozen-prefix/src/lief_frozen/include -Ilief_rang_cpp_color-prefix/src/lief_rang_cpp_color/include -I/var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/LIEF-27a03a6fd3169f427fb950293f0863dcd50ac710/src -I. -Ilief_easyloggingpp-prefix/src/lief_easyloggingpp/src -Imbed_tls/src/lief_mbed_tls/include -I/var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/LIEF-27a03a6fd3169f427fb950293f0863dcd50ac710/include/LIEF  -march=native -O2 -pipe -frecord-gcc-switches -fPIC -fvisibility=hidden   -Wall -Wextra -Wpedantic -fno-stack-protector -fomit-frame-pointer -fno-strict-aliasing -fexceptions -fvisibility=hidden -Wno-expansion-to-defined -fdiagnostics-color=always -std=gnu++11 -MD -MT CMakeFiles/LIB_LIEF.dir/src/Abstract/EnumToString.cpp.o -MF CMakeFiles/LIB_LIEF.dir/src/Abstract/EnumToString.cpp.o.d -o CMakeFiles/LIB_LIEF.dir/src/Abstract/EnumToString.cpp.o -c /var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/LIEF-27a03a6fd3169f427fb950293f0863dcd50ac710/src/Abstract/EnumToString.cpp
In file included from lief_frozen-prefix/src/lief_frozen/include/frozen/bits/algorithms.h:26,
                 from lief_frozen-prefix/src/lief_frozen/include/frozen/map.h:28,
                 from /var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/LIEF-27a03a6fd3169f427fb950293f0863dcd50ac710/src/frozen.hpp:22,
                 from /var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/LIEF-27a03a6fd3169f427fb950293f0863dcd50ac710/src/Abstract/EnumToString.cpp:17:
lief_frozen-prefix/src/lief_frozen/include/frozen/bits/basic_types.h:69:29: error: ‘constexpr const value_type& frozen::bits::cvector<T, N>::operator[](std::size_t) const’ cannot be overloaded with ‘constexpr frozen::bits::cvector<T, N>::value_type& frozen::bits::cvector<T, N>::operator[](std::size_t) const’
   constexpr const_reference operator[](std::size_t index) const { return data[index]; }
                             ^~~~~~~~
lief_frozen-prefix/src/lief_frozen/include/frozen/bits/basic_types.h:68:29: note: previous declaration ‘constexpr frozen::bits::cvector<T, N>::value_type& frozen::bits::cvector<T, N>::operator[](std::size_t) const’
   constexpr       reference operator[](std::size_t index) { return data[index]; }
                             ^~~~~~~~
lief_frozen-prefix/src/lief_frozen/include/frozen/bits/basic_types.h:72:29: error: ‘constexpr const value_type& frozen::bits::cvector<T, N>::back() const’ cannot be overloaded with ‘constexpr frozen::bits::cvector<T, N>::value_type& frozen::bits::cvector<T, N>::back() const’
   constexpr const_reference back() const { return data[dsize - 1]; }
                             ^~~~
lief_frozen-prefix/src/lief_frozen/include/frozen/bits/basic_types.h:71:29: note: previous declaration ‘constexpr frozen::bits::cvector<T, N>::value_type& frozen::bits::cvector<T, N>::back() const’
   constexpr       reference back() { return data[dsize - 1]; }
                             ^~~~
lief_frozen-prefix/src/lief_frozen/include/frozen/bits/basic_types.h: In constructor ‘frozen::bits::cvector<T, N>::cvector(frozen::bits::cvector<T, N>::size_type, const T&)’:
lief_frozen-prefix/src/lief_frozen/include/frozen/bits/basic_types.h:58:3: error: ‘constexpr’ constructor does not have empty body
   }
   ^
lief_frozen-prefix/src/lief_frozen/include/frozen/bits/basic_types.h: In member function ‘constexpr void frozen::bits::cvector<T, N>::push_back(const T&) const’:
lief_frozen-prefix/src/lief_frozen/include/frozen/bits/basic_types.h:75:53: error: increment of read-only location ‘((const frozen::bits::cvector<T, N>*)this)->frozen::bits::cvector<T, N>::dsize’
   constexpr void push_back(const T & a) { data[dsize++] = a; }
                                                     ^~
lief_frozen-prefix/src/lief_frozen/include/frozen/bits/basic_types.h: In member function ‘constexpr void frozen::bits::cvector<T, N>::push_back(T&&) const’:
lief_frozen-prefix/src/lief_frozen/include/frozen/bits/basic_types.h:76:48: error: increment of read-only location ‘((const frozen::bits::cvector<T, N>*)this)->frozen::bits::cvector<T, N>::dsize’
   constexpr void push_back(T && a) { data[dsize++] = std::move(a); }
                                                ^~
lief_frozen-prefix/src/lief_frozen/include/frozen/bits/basic_types.h: In member function ‘constexpr void frozen::bits::cvector<T, N>::pop_back() const’:
lief_frozen-prefix/src/lief_frozen/include/frozen/bits/basic_types.h:77:33: error: decrement of read-only location ‘((const frozen::bits::cvector<T, N>*)this)->frozen::bits::cvector<T, N>::dsize’
   constexpr void pop_back() { --dsize; }
                                 ^~~~~
lief_frozen-prefix/src/lief_frozen/include/frozen/bits/basic_types.h: At global scope:
lief_frozen-prefix/src/lief_frozen/include/frozen/bits/basic_types.h:87:45: error: ‘std::index_sequence’ has not been declared
   constexpr carray(T const (&init)[M], std::index_sequence<I...>)
                                             ^~~~~~~~~~~~~~
lief_frozen-prefix/src/lief_frozen/include/frozen/bits/basic_types.h:87:59: error: expected ‘,’ or ‘...’ before ‘<’ token
   constexpr carray(T const (&init)[M], std::index_sequence<I...>)
                                                           ^
lief_frozen-prefix/src/lief_frozen/include/frozen/bits/basic_types.h:90:36: error: ‘std::index_sequence’ has not been declared
   constexpr carray(Iter iter, std::index_sequence<I...>)
                                    ^~~~~~~~~~~~~~
lief_frozen-prefix/src/lief_frozen/include/frozen/bits/basic_types.h:90:50: error: expected ‘,’ or ‘...’ before ‘<’ token
   constexpr carray(Iter iter, std::index_sequence<I...>)

<skip>
romainthomas commented 5 years ago

can you give me a hint how to apply the same fix for the latest git? The current fix (27a03a6) did not work for me

I think you have issue with your own build system

btw, out of curiosity, I have changed the line https://github.com/lief-project/LIEF/blob/master/CMakeLists.txt#L158 to cxx_std_11 to make sure that everything is compiled with one API and got a new error. Perhaps, everything should be compiled with CXX14 then?

Nop, If the compiler supports C++14 then LIEF uses some features of C++14 otherwise it uses C++11. But the public API (i.e: include/LIEF/*.hpp) is compatible with C++11 standard

blshkv commented 5 years ago

My build system is fine, and just upgraded the compiler to sys-devel/gcc-8.3.0-r1. I can also build the provided SDK: share/LIEF/examples/cmake/external_project/build perfectly fine as well.

However, I'm unable to build from the latest git. Perhaps, you can try to run the same commands?

Please re-open the issue as it is not fixed completely.

romainthomas commented 5 years ago

I can also build the provided SDK: share/LIEF/examples/cmake/external_project/build perfectly fine as well. ... However, I'm unable to build from the latest git. Perhaps, you can try to run the same commands?

Don't really understand the problem. What's the issue ? (C++14 ? / Undef symbol ? )

blshkv commented 5 years ago

here is the updated log (the error is similar):

[453/641] /usr/bin/x86_64-pc-linux-gnu-g++ -DELPP_DISABLE_DEFAULT_CRASH_HANDLING -DELPP_HANDLE_SIGABRT=0 -DELPP_NO_DEFAULT_LOG_FILE -DVDEBUG=9 -D_GLIBCXX_USE_CXX11_ABI=1 -Ilief_libjson-prefix/src/lief_libjson -I/var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/LIEF-27a03a6fd3169f427fb950293f0863dcd50ac710/include -I/var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/LIEF-27a03a6fd3169f427fb950293f0863dcd50ac710/api/c/include -Iinclude  -march=native -O2 -pipe -frecord-gcc-switches   -std=gnu++11 -MD -MT examples/cpp/CMakeFiles/dex_reader.dir/dex_reader.cpp.o -MF examples/cpp/CMakeFiles/dex_reader.dir/dex_reader.cpp.o.d -o examples/cpp/CMakeFiles/dex_reader.dir/dex_reader.cpp.o -c /var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/LIEF-27a03a6fd3169f427fb950293f0863dcd50ac710/examples/cpp/dex_reader.cpp

...
[462/641] /usr/bin/x86_64-pc-linux-gnu-g++ -DELPP_DISABLE_DEFAULT_CRASH_HANDLING -DELPP_HANDLE_SIGABRT=0 -DELPP_NO_DEFAULT_LOG_FILE -DVDEBUG=9 -D_GLIBCXX_USE_CXX11_ABI=1 -Ilief_libjson-prefix/src/lief_libjson -I/var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/LIEF-27a03a6fd3169f427fb950293f0863dcd50ac710/include -I/var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/LIEF-27a03a6fd3169f427fb950293f0863dcd50ac710/api/c/include -Iinclude  -march=native -O2 -pipe -frecord-gcc-switches   -std=gnu++11 -MD -MT examples/cpp/CMakeFiles/vdex_reader.dir/vdex_reader.cpp.o -MF examples/cpp/CMakeFiles/vdex_reader.dir/vdex_reader.cpp.o.d -o examples/cpp/CMakeFiles/vdex_reader.dir/vdex_reader.cpp.o -c /var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/LIEF-27a03a6fd3169f427fb950293f0863dcd50ac710/examples/cpp/vdex_reader.cpp
...

[621/641] : && /usr/bin/x86_64-pc-linux-gnu-g++  -march=native -O2 -pipe -frecord-gcc-switches  -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 examples/cpp/CMakeFiles/dex_reader.dir/dex_reader.cpp.o  -o examples/cpp/dex_reader  -Wl,-rpath,/var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/lief-0.9.0_p20190505_build libLIEF.so && :
FAILED: examples/cpp/dex_reader 
: && /usr/bin/x86_64-pc-linux-gnu-g++  -march=native -O2 -pipe -frecord-gcc-switches  -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 examples/cpp/CMakeFiles/dex_reader.dir/dex_reader.cpp.o  -o examples/cpp/dex_reader  -Wl,-rpath,/var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/lief-0.9.0_p20190505_build libLIEF.so && :
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: examples/cpp/CMakeFiles/dex_reader.dir/dex_reader.cpp.o: in function `main':
dex_reader.cpp:(.text.startup+0x23): undefined reference to `LIEF::Logger::set_level(LIEF::LOGGING_LEVEL)'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: dex_reader.cpp:(.text.startup+0xf5): undefined reference to `LIEF::DEX::Parser::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: examples/cpp/CMakeFiles/dex_reader.dir/dex_reader.cpp.o:(.data.rel.local.DW.ref._ZTIN4LIEF9exceptionE[DW.ref._ZTIN4LIEF9exceptionE]+0x0): undefined reference to `typeinfo for LIEF::exception'
collect2: error: ld returned 1 exit status
[622/641] : && /usr/bin/x86_64-pc-linux-gnu-g++  -march=native -O2 -pipe -frecord-gcc-switches  -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 examples/cpp/CMakeFiles/elf_reader.dir/elf_reader.cpp.o  -o examples/cpp/elf_reader  -Wl,-rpath,/var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/lief-0.9.0_p20190505_build libLIEF.so && :
FAILED: examples/cpp/elf_reader 
: && /usr/bin/x86_64-pc-linux-gnu-g++  -march=native -O2 -pipe -frecord-gcc-switches  -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 examples/cpp/CMakeFiles/elf_reader.dir/elf_reader.cpp.o  -o examples/cpp/elf_reader  -Wl,-rpath,/var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/lief-0.9.0_p20190505_build libLIEF.so && :
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: examples/cpp/CMakeFiles/elf_reader.dir/elf_reader.cpp.o: in function `main':
elf_reader.cpp:(.text.startup+0x23): undefined reference to `LIEF::Logger::set_level(LIEF::LOGGING_LEVEL)'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: elf_reader.cpp:(.text.startup+0x101): undefined reference to `LIEF::ELF::Parser::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, LIEF::ELF::DYNSYM_COUNT_METHODS)'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: elf_reader.cpp:(.text.startup+0x126): undefined reference to `LIEF::ELF::Binary::functions() const'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: examples/cpp/CMakeFiles/elf_reader.dir/elf_reader.cpp.o:(.data.rel.local.DW.ref._ZTIN4LIEF9exceptionE[DW.ref._ZTIN4LIEF9exceptionE]+0x0): undefined reference to `typeinfo for LIEF::exception'
collect2: error: ld returned 1 exit status
[623/641] : && /usr/bin/x86_64-pc-linux-gnu-g++  -march=native -O2 -pipe -frecord-gcc-switches  -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 examples/cpp/CMakeFiles/elf_builder.dir/elf_builder.cpp.o  -o examples/cpp/elf_builder  -Wl,-rpath,/var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/lief-0.9.0_p20190505_build libLIEF.so && :
FAILED: examples/cpp/elf_builder 
: && /usr/bin/x86_64-pc-linux-gnu-g++  -march=native -O2 -pipe -frecord-gcc-switches  -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 examples/cpp/CMakeFiles/elf_builder.dir/elf_builder.cpp.o  -o examples/cpp/elf_builder  -Wl,-rpath,/var/tmp/portage/dev-util/lief-0.9.0_p20190505/work/lief-0.9.0_p20190505_build libLIEF.so && :
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: examples/cpp/CMakeFiles/elf_builder.dir/elf_builder.cpp.o: in function `main':
elf_builder.cpp:(.text.startup+0x68): undefined reference to `LIEF::ELF::Parser::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, LIEF::ELF::DYNSYM_COUNT_METHODS)'
collect2: error: ld returned 1 exit status
blshkv commented 5 years ago

I have no idea what is going on, but you can see that it is getting compiled (in 453) with your fixes (-D_GLIBCXX_USE_CXX11_ABI=1 and -std=gnu++11) but it fails later: undefined reference to `LIEF::Logger::set_level(LIEF::LOGGING_LEVEL) and undefined reference to `LIEF::ELF::Parser::parse(std::__cxx11::basic_string skip

romainthomas commented 5 years ago

Sorry but I won't spent more time on this issue as I can't reproduce it and it looks specific to Gentoo. Feel free to do a PR if you find the fix

blshkv commented 5 years ago

no worries, I will just disable "example" compilation and let it R.I.P.

blshkv commented 5 years ago

I managed to figure out the difference. We have BUILD_SHARED_LIBS flag enabled by default.

You can reproduce it with the following:

cmake -DBUILD_SHARED_LIBS=YES -DLIEF_EXAMPLES=ON -DLIEF_PYTHON_API=OFF CMakeLists.txt
make

The output:

[ 89%] Linking CXX shared library libLIEF.so
[ 89%] Built target LIB_LIEF
[ 90%] Building CXX object examples/cpp/CMakeFiles/dex_reader.dir/dex_reader.cpp.o
[ 90%] Linking CXX executable dex_reader
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/dex_reader.dir/dex_reader.cpp.o: in function `main':
dex_reader.cpp:(.text.startup+0x23): undefined reference to `LIEF::Logger::set_level(LIEF::LOGGING_LEVEL)'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: dex_reader.cpp:(.text.startup+0xf5): undefined reference to `LIEF::DEX::Parser::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/dex_reader.dir/dex_reader.cpp.o:(.data.rel.local.DW.ref._ZTIN4LIEF9exceptionE[DW.ref._ZTIN4LIEF9exceptionE]+0x0): undefined reference to `typeinfo for LIEF::exception'
collect2: error: ld returned 1 exit status
make[2]: *** [examples/cpp/CMakeFiles/dex_reader.dir/build.make:96: examples/cpp/dex_reader] Error 1
make[1]: *** [CMakeFiles/Makefile2:365: examples/cpp/CMakeFiles/dex_reader.dir/all] Error 2
make: *** [Makefile:152: all] Error 2
romainthomas commented 5 years ago

@blshkv It should be ok now: https://github.com/lief-project/LIEF/commit/352fa954a1135544839847fd9079e704b84c63cd

blshkv commented 5 years ago

ok, almost there. The last bit:

 * QA Notice: Files built without respecting CFLAGS have been detected
 *  Please include the following list of files in your report:
 * /usr/share/LIEF/examples/python/keygen/KeygenMe

 * QA Notice: Files built without respecting LDFLAGS have been detected
 *  Please include the following list of files in your report:
 * /usr/share/LIEF/examples/python/keygen/KeygenMe

Would you mind fixing cmake for that file to make sure these flags are passed?