How to Link a third Party Library (LibUSB) in CMake

前端 未结 2 1507
臣服心动
臣服心动 2020-12-20 00:58

I am attempting to use LibUSB in a project. However whenever I attempt to use basic libUSB functions I get the following error:

...src/main/main.cpp.o: In f         


        
2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-20 01:22

    From your projects CMakeLists.txt file it doesn't become apparent to me how you've tried to link libusb. The way I would do is the following:

    target_link_libraries(project_name usb-1.0)

    (Just to clarify I mean the CMakeLIsts.txt file in which you add your executable)

    You're trying to import from thus you need to link usb-1.0 (the lib is always omitted from linker commands!)

    I'm on Fedora 23, also using KDevelop and I didn't have to specify a path. Especially because on my system all the environment variables used in the previous answer are NULL anyways.

    And to confirm where and how a library is installed in the future you can just do: locate libusb | grep .so

    Hope this was somewhat helpful.

提交回复
热议问题