Coder Social home page Coder Social logo

Comments (6)

Clcanny avatar Clcanny commented on June 14, 2024

发现:无论是main还是co_main都需要存在一个thread_group类型的变量才能正常静态链接/运行。

from libgo.

yyzybb537 avatar yyzybb537 commented on June 14, 2024

首先建议不要使用 -I这种方式, 而是把libgo通过make install安装到系统目录里来include,当然这不影响结果。
1.会出现链接错误是因为gcc静态链接的向后查找机制,libgo_main是依赖于libgo的,所以链接选项中应该把-llibgo_main放在-llibgo的前面!
2.运行时错误是因为gcc的thread相关导致的问题,你可以尝试把-lpthread改为-pthread来解决问题,详细原因参见gcc manpage.

from libgo.

Clcanny avatar Clcanny commented on June 14, 2024

您好!感谢回复:

  1. 链接的问题已经解决了(无论是调整顺序还是把库重复一遍)
  2. -pthread没有解决运行时的问题

from libgo.

yyzybb537 avatar yyzybb537 commented on June 14, 2024

我比较好奇为什么你不使用libgo里面的cmake来编译教程代码呢?

from libgo.

yyzybb537 avatar yyzybb537 commented on June 14, 2024

g++ -std=c++11 sample2_yield.cpp -llibgo_main -llibgo -lboost_coroutine -lboost_context -lboost_thread -lboost_system -ldl -pthread -static -static-libstdc++
这是我刚刚测试使用编译命令,你可以试一下

from libgo.

Clcanny avatar Clcanny commented on June 14, 2024

额,因为CMake好像是用动态链接的方式来的
我只是很好奇为什么会有这种奇怪的现象
至少在g++ (Debian 6.3.0-18) 6.3.0 20170516 + debian 9下还是不行
有可能是debian或者g++的bug
一个会被优化掉的变量不应该对运行时行为产生影响

多谢!

from libgo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.