zoukankan      html  css  js  c++  java
  • Ubuntu下编译程序是出现pthread_create未定义错误

    gcc -c node_list.c -o node_list.o
    gcc -lpthread sim.o cli.o list.o node_list.o -o sim.exe
    sim.o: In function `sim_add_node':
    sim.c:(.text+0xa55): undefined reference to `pthread_create'
    sim.c:(.text+0xa8a): undefined reference to `pthread_create'
    sim.o: In function `sim_kill_nodes':
    sim.c:(.text+0xb5a): undefined reference to `pthread_kill'
    cli.o: In function `kill_node':
    cli.c:(.text+0x4ec): undefined reference to `pthread_kill'
    cli.c:(.text+0x512): undefined reference to `pthread_kill'
    collect2: ld returned 1 exit status
    make: *** [sim.exe] Error 1

    百思不得其姐。。。

    最后在这里看到了,泪流满面啊。(-l包含库指令的位置要在最后!!)

    换了位置之后

    gcc sim.o cli.o list.o node_list.o -o sim.exe -lpthread
    cp sim.exe ../test/test_sim

    可以了。

    实际上,这可能不是这么简单地将该指令放在最后这么简单。这或许是涉及到lpthread和pthread的用法问题,请参考网友的文章。

    http://chaoslawful.iteye.com/blog/568602

  • 相关阅读:
    Next Permutation
    SpringMVC配置信息
    Servlet详解(转载)
    Length of Last Word
    Maximum Subarray**
    Divide Two Integers
    Generate Parentheses***
    http解码-2
    编码-1
    扫描工具对比
  • 原文地址:https://www.cnblogs.com/tfanalysis/p/3543219.html
Copyright © 2011-2022 走看看