लिंकर समस्या के कारण डार्क्स लाइब्रेरी के साथ यसोड का उपयोग करना असंभव प्रतीत होता है। मैंने समस्या को ट्रैक किया और डार्क्स आंतरिक से परिचित लोगों द्वारा इसके आसपास काम करने के लिए संकेतों की आवश्यकता है।यसोड और डार्क्स लाइब्रेरी का उपयोग करते समय डुप्लिकेट प्रतीक त्रुटि के आसपास कैसे काम करें?
जब एक Yesod आवेदन में darcs library का उपयोग कर, मैं निम्नलिखित त्रुटि मिलती है:
GHCi runtime linker: fatal error: I found a duplicate definition for symbol
sha256_init
whilst processing object file
/home/sebfisch/.cabal/lib/darcs-2.9.5/ghc-7.4.2/libHSdarcs-2.9.5.a
This could be caused by:
* Loading two different object files which export the same symbol
* Specifying the same object file twice on the GHCi command line
* An incorrect `package.conf' entry, causing some object to be
loaded twice.
GHCi cannot safely continue in this situation. Exiting now. Sorry.
यह संबंधित वस्तु फ़ाइलों के माध्यम से खोज के रूप में, darcs और cryptohash एक ही प्रतीक उजागर पुस्तकालयों की वजह से हो गया लगता है का पता चलता है :
:# for file in `find ~/.cabal/lib/ -name "*.a"`; do (readelf -s $file | grep -i sha256_init) && (echo $file; echo); done
293: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND sha256_init
17: 0000000000000690 94 FUNC GLOBAL DEFAULT 1 sha256_init
~/.cabal/lib/cryptohash-0.7.5/ghc-7.4.2/libHScryptohash-0.7.5.a
10: 0000000000000290 45 FUNC GLOBAL DEFAULT 1 sha256_init
~/.cabal/lib/darcs-2.8.2/ghc-7.4.2/libHSdarcs-2.8.2.a
मैं पुष्टि करते हैं कि darcs और cryptohash पुस्तकालयों संघर्ष में हैं एक परीक्षण कार्यक्रम में लिखा था
import Crypt.SHA256 (sha256sum)
import Crypto.Hash.SHA256 (hash)
import Data.ByteString (empty)
import qualified Data.ByteString.Char8 as BS
main :: IO()
main = do
BS.putStrLn $ hash empty -- cryptohash
putStrLn $ sha256sum empty -- darcs
यह एक समान त्रुटि के साथ संकलित करने के लिए विफल रहता है:
/home/sebfisch/.cabal/lib/cryptohash-0.7.5/ghc-7.4.2/libHScryptohash-0.7.5.a(sha256.o): In function `sha256_update': sha256.c:(.text+0x4b0): multiple definition of `sha256_update'
/home/sebfisch/.cabal/lib/darcs-2.8.2/ghc-7.4.2/libHSdarcs-2.8.2.a(sha2.o):sha2.c:(.text+0xf90): first defined here
/home/sebfisch/.cabal/lib/cryptohash-0.7.5/ghc-7.4.2/libHScryptohash-0.7.5.a(sha256.o): In function `sha224_update': sha256.c:(.text+0x640): multiple definition of `sha224_update'
/home/sebfisch/.cabal/lib/darcs-2.8.2/ghc-7.4.2/libHSdarcs-2.8.2.a(sha2.o):sha2.c:(.text+0xbb0): first defined here
/home/sebfisch/.cabal/lib/cryptohash-0.7.5/ghc-7.4.2/libHScryptohash-0.7.5.a(sha256.o): In function `sha256_init': sha256.c:(.text+0x690): multiple definition of `sha256_init'
/home/sebfisch/.cabal/lib/darcs-2.8.2/ghc-7.4.2/libHSdarcs-2.8.2.a(sha2.o):sha2.c (.text+0x290): first defined here
/home/sebfisch/.cabal/lib/cryptohash-0.7.5/ghc-7.4.2/libHScryptohash-0.7.5.a(sha256.o): In function `sha224_init': sha256.c:(.text+0x6f0): multiple definition of `sha224_init'
/home/sebfisch/.cabal/lib/darcs-2.8.2/ghc-7.4.2/libHSdarcs-2.8.2.a(sha2.o):sha2.c (.text+0x620): first defined here
collect2: ld returned 1 exit status
cryptohash पुस्तकालय yesod-static के लिए आवश्यक है और आसानी से जब एक Yesod आवेदन लिख टाला नहीं जा सकता। मैं उसी एप्लिकेशन में यसोड और डार्क्स (लाइब्रेरी के रूप में) का उपयोग कैसे कर सकता हूं?
क्या यह एक लाइब्रेरी से डुप्लिकेट प्रतीकों को हटाने में मदद करेगा? दोनों पैकेज एफएफआई के माध्यम से हैशिंग फ़ंक्शन एक्सेस करते हैं लेकिन विभिन्न फ़ाइलों का उपयोग करते हैं।
foreign import ccall unsafe "sha2.h sha256" c_sha256
:: Ptr CChar -> CSize -> Ptr Word8 -> IO()
cryptohash/Crypto.Hash.SHA256 से:
foreign import ccall unsafe "sha256.h sha256_init"
c_sha256_init :: Ptr Ctx -> IO()
foreign import ccall "sha256.h sha256_update"
c_sha256_update :: Ptr Ctx -> CString -> Word32 -> IO()
foreign import ccall unsafe "sha256.h sha256_finalize"
c_sha256_finalize :: Ptr Ctx -> CString -> IO()
एक और विचार Darcs के पुनर्लेखन के लिए अपने स्वयं के हैशिंग समारोह का उपयोग नहीं करने के लिए है। क्रिप्टोश का उपयोग करने के लिए मैं Darcs के SHA256
मॉड्यूल को कैसे कार्यान्वित कर सकता हूं? मेरे परीक्षण कार्यक्रम के main
फ़ंक्शन में दो बयान एक ही आउटपुट नहीं देते हैं (अन्य कथन को टिप्पणी करके परीक्षण किया जाता है), इसलिए डार्क्स में क्रिप्टोश का उपयोग पूरी तरह से सरल नहीं लगता है।
क्या आप इस कार्य के डार्क्स संस्करण का नाम बदलकर 'darcs_sha256_init' जैसे नहीं कर सकते? –
यदि मैं सही ढंग से समझता हूं, तो समस्या यह है कि प्रतीक को एफएफआई के माध्यम से उपयोग की जाने वाली दो अलग-अलग सी फाइलों में परिभाषित किया गया है, इसलिए हास्केल फ़ंक्शन का नाम बदलने में मदद नहीं मिलेगी, है ना? –
हालांकि सी फ़ंक्शन का नाम बदलना मदद करता है। मेरा संशोधित उत्तर देखें। –