Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo生成问题,使用HelloWorld CPP里面的命令生成的时候,出现了以下问题 #48

Closed
XiDianZuoYun opened this issue Mar 19, 2020 · 10 comments

Comments

@XiDianZuoYun
Copy link

[ 50%] Linking CXX executable ../bin/HelloServer
/usr/local/tars/cpp/lib/libtarsutil.a(tc_thread.cpp.o): In function tars::TC_Thread::start()': tc_thread.cpp:(.text+0xb79): undefined reference to pthread_create'
/usr/local/tars/cpp/lib/libtarsservant.a(Application.cpp.o): In function tars::Application::main(tars::TC_Option const&)': Application.cpp:(.text.startup+0x8a3): undefined reference to pthread_create'
Application.cpp:(.text.startup+0x1002): undefined reference to pthread_create' /usr/local/tars/cpp/lib/libtarsutil.a(tc_logger.cpp.o): In function tars::TC_LoggerThreadGroup::start(unsigned long)':
tc_logger.cpp:(.text+0x1e3): undefined reference to pthread_create' /usr/local/tars/cpp/lib/libtarsutil.a(tc_timeprovider.cpp.o): In function tars::TC_TimeProvider::getInstance()':
tc_timeprovider.cpp:(.text+0x132): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
src/CMakeFiles/HelloServer.dir/build.make:122: recipe for target 'bin/HelloServer' failed
make[2]: *** [bin/HelloServer] Error 1
CMakeFiles/Makefile2:223: recipe for target 'src/CMakeFiles/HelloServer.dir/all' failed
make[1]: *** [src/CMakeFiles/HelloServer.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
这似乎是由于生成tars静态库libtarsutil.a的时候没有正确链接lpthread导致?但是我之前的利用源码编译tars框架和tarsweb的时候是完全按照指南做的,没有发现有需要特别链接lphtread的地方

@ruanshudong
Copy link
Contributor

HelloServer, 怎么来的?
你用的版本似乎很老啊?现在都是c++11做得, 用的std::thread, 按说不应该有pthread_create这种提示?

@XiDianZuoYun
Copy link
Author

我用了官方文档中创建服务这一项的命令:/usr/local/tars/cpp/script/cmake_tars_server.sh TestApp HelloServer Hello
令,现在会报出“/usr/bin/ld: cannot find -lnghttp2_static”的错误

@ruanshudong
Copy link
Contributor

这是因为你编译tars没有开启http2, 这种情况下:
cmake .. -DTARS_HTTPS=OFF -DTARS_SSL=OFF
make

可以参考:
https://tarscloud.github.io/TarsDocs/dev/tarscpp/tars-http2.html

@XiDianZuoYun
Copy link
Author

除此以外,我重启服务器后,切换到root用户,再次运行pm2 start tars-web-system,返回了script not found 的错误,似乎pm2查找脚本的目录是当前目录

@ruanshudong
Copy link
Contributor

ruanshudong commented Mar 26, 2020 via email

@XiDianZuoYun
Copy link
Author

XiDianZuoYun commented Mar 26, 2020

运行了,重启之后依然无效
步骤是 root用户下运行/linux-install.sh 然后source ~/.bashrc
提示192.168.216.XXX:3000 可以访问,然后网页访问进去发现500,127.0.0.1:3001 无法连接
重启
切换到root用户,运行pm2 start tars-node-web ,无法找到script

@XiDianZuoYun
Copy link
Author

另外之前两个问题我已经解决了,第一个我选择更新GCC到5.3+,第二个我安装了libnghttp2,并复制libnghttp2.a重命名libnghttp2_static.a

@ruanshudong
Copy link
Contributor

ruanshudong commented Mar 26, 2020 via email

@XiDianZuoYun
Copy link
Author

XiDianZuoYun commented Mar 26, 2020

不是我需不需要的问题,我完全按照https://tarscloud.github.io/TarsDocs/installation/source.html这个里面的说明进行安装的,
然后我试图运行https://tarscloud.github.io/TarsDocs/hello-world/tarscpp.html
分别遇见了打不开tars-node-web、找不到-lnghttp2_static的问题
后者已经解决

@ruanshudong
Copy link
Contributor

ruanshudong commented Mar 26, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants