先将ZThread-2.3.1.tar.gz解压至任一目录,我的目录是/home/sidle/test/ZThread-2.3.1/ 。在当前目录找到 configure 文件执行之,完了当前目录上会有一个Makefile。在这里运行make,喝杯热茶后正好看到结果。make的信息多而乱,看了看最后几行后直接find -name libZThread.a (懒人的办法),在 ZThread-2.3.1/src/.libs目录下看到生成了不少文件,正是我们所需要的
我只是测试ZThread在linux上的编译情况,代码自然得选个短小精悍的 :D
vi /home/sidle/test/ZThread_Test/main.cpp 如下
然后再来一个makefile
CXX = g++
INCS = -I"../ZThread-2.3.1/include/"
LIBS = -L"../ZThread-2.3.1/src/.libs/"
BIN = test
OBJS = main.o
$(BIN): $(OBJS)
$(CXX) $< -o $(BIN) $(LIBS) -lZThread
main.o: main.cpp
$(CXX) -c $< -o $@ $(INCS)
make后运行一把程序,跳出两行错误提示
./test: error while loading shared libraries: libZThread-2.3.so.1: cannot open
hared object file: No such file or directory
呵,不好意思,还得把 libZThread-2.3.so.1 cp 到/usr/lib目录,然后,然后自然就一切OK了 。
操作系统:
Red Hat Linux release 9 (Shrike)
Kernel 2.4.20-8 on an i686
我只是测试ZThread在linux上的编译情况,代码自然得选个短小精悍的 :D
vi /home/sidle/test/ZThread_Test/main.cpp 如下
#include <iostream>
#include <zthread/Thread.h>
using namespace ZThread;
using namespace std;
class aRunnable : public Runnable {
void run() {
string str = "Hello from another thread";
cout << str << endl;
}
};
int main() {
try {
Thread t(new aRunnable);
t.wait();
}
catch(Synchronization_Exception& e) {
cerr << e.what() << endl;
}
std::cout << "Hello from the main thread" << std::endl;
return 0;
}
#include <zthread/Thread.h>
using namespace ZThread;
using namespace std;
class aRunnable : public Runnable {
void run() {
string str = "Hello from another thread";
cout << str << endl;
}
};
int main() {
try {
Thread t(new aRunnable);
t.wait();
}
catch(Synchronization_Exception& e) {
cerr << e.what() << endl;
}
std::cout << "Hello from the main thread" << std::endl;
return 0;
}
然后再来一个makefile
CXX = g++
INCS = -I"../ZThread-2.3.1/include/"
LIBS = -L"../ZThread-2.3.1/src/.libs/"
BIN = test
OBJS = main.o
$(BIN): $(OBJS)
$(CXX) $< -o $(BIN) $(LIBS) -lZThread
main.o: main.cpp
$(CXX) -c $< -o $@ $(INCS)
make后运行一把程序,跳出两行错误提示
./test: error while loading shared libraries: libZThread-2.3.so.1: cannot open
hared object file: No such file or directory
呵,不好意思,还得把 libZThread-2.3.so.1 cp 到/usr/lib目录,然后,然后自然就一切OK了 。
操作系统:
Red Hat Linux release 9 (Shrike)
Kernel 2.4.20-8 on an i686