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

你好,cmake和make之后该怎么运行helloworld例子 #46

Open
aoaforever opened this issue Jul 25, 2022 · 3 comments
Open

你好,cmake和make之后该怎么运行helloworld例子 #46

aoaforever opened this issue Jul 25, 2022 · 3 comments

Comments

@aoaforever
Copy link

在ubuntu下,我cmake和make之后,生成了libuv_cpp.a静态库,然后我用vscode编译一个helloworld例子,要怎么链接这些库?
vscode的tasks配置文件写成了如下:
但是这样做之后,他还是不能成功的编译出可执行文件,并且报错:EventLoop.cpp:(.text+0x2e):对‘uv_default_loop’未定义的引用,这一系列的链接失败的错误码。

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++ 生成活动文件",
            "command": "/usr/bin/g++",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-I","/home/aoa/Downloads/uv-cpp-master",
                "-I","/home/aoa/Downloads/uv-cpp-master/libuv1.30.0/include",
                "-L","/home/aoa/Downloads/uv-cpp-master/build",
                "-l","uv_cpp",
                "-Wl,-rpath=/home/aoa/Downloads/uv-cpp-master/build",
                "-std=c++11",
                "-Wall",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}",
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "调试器生成的任务。"
        }
    ],
    "version": "2.0.0"
}
/home/aoa/Downloads/uv-cpp-master/build/libuv_cpp.a(EventLoop.cpp.o):在函数‘uv::EventLoop::~EventLoop()’中:
EventLoop.cpp:(.text+0x2e):对‘uv_default_loop’未定义的引用
EventLoop.cpp:(.text+0x3c):对‘uv_loop_close’未定义的��用
/home/aoa/Downloads/uv-cpp-master/build/libuv_cpp.a(EventLoop.cpp.o):在函数‘uv::EventLoop::EventLoop(uv::EventLoop::Mode)’中:
EventLoop.cpp:(.text+0xbd):对‘uv_default_loop’未定义的引用
EventLoop.cpp:(.text+0x112):对‘uv_loop_init’未定义的引用
/home/aoa/Downloads/uv-cpp-master/build/libuv_cpp.a(EventLoop.cpp.o):在函数‘uv::EventLoop::run()’中:
EventLoop.cpp:(.text+0x1fd):对‘uv_run’未定义的引用
/home/aoa/Downloads/uv-cpp-master/build/libuv_cpp.a(EventLoop.cpp.o):��函数‘uv::EventLoop::runNoWait()’中:
EventLoop.cpp:(.text+0x250):对‘uv_run’未定义的引用
/home/aoa/Downloads/uv-cpp-master/build/libuv_cpp.a(EventLoop.cpp.o):在函数‘std::_Function_handler<void (uv::Async*), uv::EventLoop::stop()::{lambda(uv::Async*)#1}>::_M_invoke(std::_Any_data const&, uv::Async*&&)’���:
EventLoop.cpp:(.text+0x85):对‘uv_stop’未定义的引用
/home/aoa/Downloads/uv-cpp-master/build/libuv_cpp.a(EventLoop.cpp.o):在���数‘uv::EventLoop::GetErrorMessage(int)’中:
EventLoop.cpp:(.text+0x476):对‘uv_strerror’��定义的引用

……………………………………………………………………………………

collect2: error: ld returned 1 exit status
@aoaforever
Copy link
Author

请问,还需要额外的安装libuv库吗?我看到你的项目已经有libuv的库,不知道cmake的时候有没有编译到。

@wlgq2
Copy link
Owner

wlgq2 commented Jul 26, 2022

看起来是libuv库相关函数没找到。试试把libuv的.a文件也加入工程依赖。首先要确保libvu可以正常,大概率你用的libuv版本和编译器版本和我不一致,所以可能自己编译一遍libuv,生成.a文件。或者你尝试用工程里面的libuv.a文件看看。

@aoaforever
Copy link
Author

aoaforever commented Jul 26, 2022 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