undefined reference to 'dlopen';undefined reference to 'dlclose';undefined reference to 'dlerror'等問題

轉載:undefined reference to涉及的連接問題html

http://blog.csdn.net/lyuan13141234/article/details/5667570linux

/----------------------------------------------------->>>>>post

在linux下,編譯連接的時候,常常會遇到這樣一個問題,undefined reference to.....,引發這個問題的緣由在於在連接的時候缺乏選項。下面舉幾個例子,並給出解決辦法。spa

一、  undefined reference to `dlerror'.net

 undefined reference to `dlopen'htm

 undefined reference to `dlerror';;解決方法:在makefile的 ldflags 後面把選項 -ldl添加上便可blog

二、undefined reference to `main';;解決方法:在makefile的 ldflags 後面添加 -nostartfiles 選項ci

三、undefined reference to `pthread_setspecific'get

   undefined reference to `pthread_key_delete'編譯

     undefined reference to `pthread_key_create'::解決辦法:在makefile的LDFLAGS後面添加 -lpthread 選項。

最後::若是undefined reference to後面的內容是在本身的文件中聲明或定義的東西,就不能用這種方法來解決了。這時就須要檢查一下本身的makefile涉及到源文件、頭文件的地方是否出錯了,也有多是其餘的緣由

轉載於:https://www.cnblogs.com/li-daphne/archive/2013/05/11/3073377.html