先将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 如下
在linux上使用ZThread#include <iostream>
在linux上使用ZThread    #include 
<zthread/Thread.h>
在linux上使用ZThread    
在linux上使用ZThread    
using namespace ZThread;
在linux上使用ZThread    
using namespace std;
在linux上使用ZThread    
{
{
在linux上使用ZThread             
string str = "Hello from another thread";
在linux上使用ZThread             cout 
<< str << endl;
在linux上使用ZThread     }

在linux上使用ZThread    }
;
在linux上使用ZThread    
{
{
在linux上使用ZThread       Thread t(
new aRunnable);
在linux上使用ZThread       t.wait();
在linux上使用ZThread     }

{
在linux上使用ZThread       cerr 
<< e.what() << endl;
在linux上使用ZThread     }

在linux上使用ZThread     std::cout 
<< "Hello from the main thread" << std::endl;
在linux上使用ZThread     
return 0;
在linux上使用ZThread    }

然后再来一个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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-04
  • 2021-09-21
  • 2021-10-08
  • 2021-10-15
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
  • 2021-10-19
相关资源
相似解决方案