Natty Narwhal和Oneiric Ocelot之间共享对象链接的差异
Difference in shared object linking between Natty Narwhal and Oneiric Ocelot
我正在编写一个简单的概念证明C++应用程序(可在 https://github.com/paulspencerwilliams/CPlusPlusSocialPlayground 获得),使用twitcurl编译,使用 http://code.google.com/p/twitcurl/wiki/WikiHowToUseTwitcurlLibrary 的确切说明。我可以毫无问题地编译和安装 twitcurl,我可以在 Natty Narwhal 上编译和执行我的应用程序。但是,在Oneiric Ocelot上编译我的应用程序(通过Makefile)会给我以下链接问题:
g++ -ltwitcurl twitterClient.cpp -o twitterClient
/tmp/ccbxmSF3.o: In function `main':
twitterClient.cpp:(.text+0x1f7): undefined reference to `twitCurl::twitCurl()'
twitterClient.cpp:(.text+0x22e): undefined reference to `twitCurl::setTwitterUsername(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
twitterClient.cpp:(.text+0x247): undefined reference to `twitCurl::setTwitterPassword(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
twitterClient.cpp:(.text+0x280): undefined reference to `twitCurl::getOAuth()'
twitterClient.cpp:(.text+0x292): undefined reference to `oAuth::setConsumerKey(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
twitterClient.cpp:(.text+0x2e9): undefined reference to `twitCurl::getOAuth()'
twitterClient.cpp:(.text+0x2fb): undefined reference to `oAuth::setConsumerSecret(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
twitterClient.cpp:(.text+0x50c): undefined reference to `twitCurl::getOAuth()'
twitterClient.cpp:(.text+0x51e): undefined reference to `oAuth::setOAuthTokenKey(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
twitterClient.cpp:(.text+0x52d): undefined reference to `twitCurl::getOAuth()'
twitterClient.cpp:(.text+0x53f): undefined reference to `oAuth::setOAuthTokenSecret(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
twitterClient.cpp:(.text+0x56c): undefined reference to `twitCurl::oAuthRequestToken(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
twitterClient.cpp:(.text+0x664): undefined reference to `twitCurl::getOAuth()'
twitterClient.cpp:(.text+0x676): undefined reference to `oAuth::setOAuthPin(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
twitterClient.cpp:(.text+0x691): undefined reference to `twitCurl::oAuthHandlePIN(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
twitterClient.cpp:(.text+0x6a0): undefined reference to `twitCurl::oAuthAccessToken()'
twitterClient.cpp:(.text+0x6af): undefined reference to `twitCurl::getOAuth()'
twitterClient.cpp:(.text+0x6c1): undefined reference to `oAuth::getOAuthTokenKey(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
twitterClient.cpp:(.text+0x6d0): undefined reference to `twitCurl::getOAuth()'
twitterClient.cpp:(.text+0x6e2): undefined reference to `oAuth::getOAuthTokenSecret(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
twitterClient.cpp:(.text+0x88e): undefined reference to `twitCurl::statusUpdate(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
twitterClient.cpp:(.text+0x8ab): undefined reference to `twitCurl::getLastWebResponse(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
twitterClient.cpp:(.text+0x8e7): undefined reference to `twitCurl::getLastCurlError(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
twitterClient.cpp:(.text+0x97e): undefined reference to `twitCurl::timelineUserGet(bool, bool, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool)'
twitterClient.cpp:(.text+0x9bb): undefined reference to `twitCurl::getLastWebResponse(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
twitterClient.cpp:(.text+0x9f7): undefined reference to `twitCurl::getLastCurlError(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
twitterClient.cpp:(.text+0xa86): undefined reference to `twitCurl::~twitCurl()'
twitterClient.cpp:(.text+0xc64): undefined reference to `twitCurl::~twitCurl()'
collect2: ld returned 1 exit status
make: *** [all] Error 1
任何想法在这两个平台上编译有什么区别?为了进行精确的比较,我已经在 AWS 上的 Ubuntu 64 位映像上尝试过这个,并得到了相同的症状。
编辑:我已经更改了Makefile中参数的顺序,似乎没有通过第一个问题。但是,我现在在编译时出现以下错误:
g++ twitterClient.cpp -o twitterClient -ltwitcurl
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib/libtwitcurl.so: undefined reference to `curl_easy_getinfo'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib/libtwitcurl.so: undefined reference to `curl_easy_setopt'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib/libtwitcurl.so: undefined reference to `curl_easy_init'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib/libtwitcurl.so: undefined reference to `curl_slist_append'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib/libtwitcurl.so: undefined reference to `curl_slist_free_all'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib/libtwitcurl.so: undefined reference to `curl_easy_perform'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib/libtwitcurl.so: undefined reference to `curl_easy_cleanup'
collect2: ld returned 1 exit status
make: *** [all] Error 1
Oneiric 的较新gcc
版本要求在源文件之后设置 link 参数:
g++ twitterClient.cpp -o twitterClient -ltwitcurl
相关文章:
- 使用nvcc(CUDA-RINSIDE)正确链接对象文件
- 如何在Linux中使用GLFW函数正确链接C++对象?
- 无法链接".o"对象文件
- C 链接对象列表
- 如何在Visual Studio中未经编造的链接对象名称
- 从最基本的Qt应用程序重新链接对象 - 链接器错误
- g++链接对象文件无法链接
- 链接对象文件和静态库时出现多定义错误
- 链接对象和静态库
- 警告LNK4206:找不到预编译类型信息; 未链接或覆盖;链接对象,就好像没有调试信息一样
- 使用 G++ 链接对象时出现问题
- c++链接错误:无法链接对象
- so中未定义的符号(在链接对象中定义)
- C++链接对象的文件 (G++)
- 链接.o (C对象文件)到Linux上的c++文件/项目
- 清理链接对象的动态内存
- 限制链接对象的全局符号的作用域
- 如何在不使用makefile的情况下链接对象文件和库
- 在运行时链接c++对象
- 从一个链接对象到另一个链接对象的访问