我从这里下载了gtest 1.7.0源代码:
https://code.google.com/p/googletest/downloads/list
并在ubuntu 13.10上构建gtest .a文件(lib文件):
Linux ubuntu 3.11.0-15-generic #23-Ubuntu SMP Mon Dec 9 18:17:04 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)
并且生成的lib被称为:libgtest.a.在我的main.cpp文件中有:
#include <iostream>
#include "gtest/gtest.h"
int main(){
std::cout << "Test \n";
int argc = 2;
char* cp01;
char* cp02;
char* argv[] = {cp01, cp02};
testing::InitGoogleTest(&argc, argv);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
从我建立的终端:
g++ main.cpp -I/home/user/gtest-1.7.0/include -L/home/user/gtest-1.7.0/lib/.libs -lpthread -lgtest
Run Code Online (Sandbox Code Playgroud)
这给出了以下错误:
/home/user/gtest-1.7.0/lib/.libs/libgtest.so: undefined reference to `pthread_key_create'
/home/user/gtest-1.7.0/lib/.libs/libgtest.so: undefined reference to `pthread_getspecific'
/home/user/gtest-1.7.0/lib/.libs/libgtest.so: undefined reference to `pthread_key_delete'
/home/user/gtest-1.7.0/lib/.libs/libgtest.so: undefined reference to `pthread_setspecific' …Run Code Online (Sandbox Code Playgroud) 我有这个简单的python函数,可以提取zip文件(独立于平台)
def unzip(source, target):
with zipfile.ZipFile(source , "r") as z:
z.extractall(target)
print "Extracted : " + source + " to: " + target
Run Code Online (Sandbox Code Playgroud)
这在Python 2.7中运行良好,但在Python 2.6中失败:
AttributeError: ZipFile instance has no attribute '__exit__':
Run Code Online (Sandbox Code Playgroud)
我发现这个建议需要升级2.6 - > 2.7 https://bugs.launchpad.net/horizon/+bug/955994
但是可以将上面的代码移植到Python 2.6并仍然保持跨平台吗?