我試圖將libcurl鏈接到我的程序,但鏈接器告訴我一些錯誤。 我檢查過選項「-lcurl」已被使用。我也檢查過libcurl是否正確安裝。 我嘗試的命令是:(dlang)如何使用gdc鏈接libcurl?
gdc myprogram.d -o myprogram -lcurl
和鏈接告訴我下面的錯誤:
/usr/lib/gcc/x86_64-linux-gnu/4.8/libgphobos2.a(curl.o): In function `_D3std3net4curl4Curl18_sharedStaticCtor1FZv':
/build/buildd/gcc-4.8-4.8.2/build/x86_64-linux-gnu/libphobos/src/../../../../src/libphobos/src/std/net/curl.d:3432: undefined reference to `curl_global_init'
/usr/lib/gcc/x86_64-linux-gnu/4.8/libgphobos2.a(curl.o): In function `_D3std3net4curl4Curl8shutdownMFZv':
/build/buildd/gcc-4.8-4.8.2/build/x86_64-linux-gnu/libphobos/src/../../../../src/libphobos/src/std/net/curl.d:3561: undefined reference to `curl_easy_cleanup'
/usr/lib/gcc/x86_64-linux-gnu/4.8/libgphobos2.a(curl.o): In function `shutdown':
/build/buildd/gcc-4.8-4.8.2/build/x86_64-linux-gnu/libphobos/src/../../../../src/libphobos/src/std/net/curl.d:3561: undefined reference to `curl_easy_cleanup'
/build/buildd/gcc-4.8-4.8.2/build/x86_64-linux-gnu/libphobos/src/../../../../src/libphobos/src/std/net/curl.d:3561: undefined reference to `curl_easy_cleanup'
/build/buildd/gcc-4.8-4.8.2/build/x86_64-linux-gnu/libphobos/src/../../../../src/libphobos/src/std/net/curl.d:3561: undefined reference to `curl_easy_cleanup'
/usr/lib/gcc/x86_64-linux-gnu/4.8/libgphobos2.a(curl.o): In function `_D3std3net4curl4HTTP4Impl6__dtorMFZv':
/build/buildd/gcc-4.8-4.8.2/build/x86_64-linux-gnu/libphobos/src/../../../../src/libphobos/src/std/net/curl.d:2033: undefined reference to `curl_slist_free_all'
有一些情況下使用官方的編譯器DMD,但我無法找到與GDC的情況。 任何想法?
(Ubuntu的14.02 LTS AMD64)
嘗試在命令行的開始處放置'-lcurl',使'gdc -lcurl myprogram.d'並查看會發生什麼。我之前看到過一個bug,它與鏈接的順序有關,這可能會有所幫助。 –
我嘗試了你寫的,但是同樣的錯誤發生了。發生了什麼!?!? – carrot031