我正在尝试使用visual studio跨平台功能编译一些代码,但我遇到了一些问题,我复制了包含文件,就像他们说你应该和intellisense工作正常。在链接阶段编译期间,我找不到lib ...
Linking objects
1> Invoking ld
1> g++ -o "/home/pi/projects/PiLedTestSetup/bin/ARM/Debug/PiLedTestSetup.out" -Wl,--no-undefined -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack /home/pi/projects/PiLedTestSetup/obj/ARM/Debug/camera.o /home/pi/projects/PiLedTestSetup/obj/ARM/Debug/cameracontrol.o /home/pi/projects/PiLedTestSetup/obj/ARM/Debug/main.o /home/pi/projects/PiLedTestSetup/obj/ARM/Debug/Serial.o -lwiringPi -llibmmal_core -llibmmal_util -llibmmal_vc_client -llibvcos -llibbcm_host -llibbrcmGLESv2 -llibbrcmEGL.so
1> /usr/bin/ld: cannot find -llibmmal_core
1> /usr/bin//usr/bin/ld: cannot find -llibmmal_core
1> /usr/bin/ld: cannot find -llibmmal_util
1> /usr/bin/ld: cannot find -llibmmal_vc_client
1> /usr/bin/ld: cannot find -llibvcos
1> /usr/bin/ld: cannot find -llibbcm_host
1> /usr/bin/ld: cannot find -llibbrcmGLESv2
1> /usr/bin/ld: cannot find -llibbrcmEGL.so
1> collect2: error: ld returned 1 exit status
使用我最初使用的make文件(在pi上使用make编译工作正常!)它链接到lib文件夹,就像这个link_directories(/ opt / vc / lib)所以在vs中我添加了就像VC ++目录中的include目录一样 - >图书馆目录
所以我想知道我错过了什么?你们如何为你们添加图书馆。
编辑: 所以我发现了如何添加lib文件夹,转到properties-general-additional库目录
所以现在它在构建字符串中给出了-L(-L / opt / vc / lib)参数或者你称之为但仍然没有找到它。我甚至尝试使用文件扩展名,但这对以太没有帮助
1>Target Link:
1> Linking objects
1> Invoking ld
1> g++ -o "/home/pi/projects/PiLedTestSetup/bin/ARM/Debug/PiLedTestSetup.out" -Wl,--stats -Wl,--no-undefined -Wl,-L/opt/vc/lib -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack /home/pi/projects/PiLedTestSetup/obj/ARM/Debug/camera.o /home/pi/projects/PiLedTestSetup/obj/ARM/Debug/cameracontrol.o /home/pi/projects/PiLedTestSetup/obj/ARM/Debug/main.o /home/pi/projects/PiLedTestSetup/obj/ARM/Debug/Serial.o -lwiringPi -llibmmal_core.so -llibmmal_util.so -llibmmal_vc_client.so -llibvcos.so -llibbcm_host.so -llibbrcmGLESv2.so -llibbrcmEGL.so
1> /usr/bin/ld: cannot find -llibmmal_core.so
1> /usr/bin/ld: /usr/bin/ld: cannot find -llibmmal_core.so
1> /usr/bin/ld: cannot find -llibmmal_util.so
1> /usr/bin/ld: cannot find -llibmmal_vc_client.so
1> /usr/bin/ld: cannot find -llibvcos.so
1> /usr/bincannot find -llibmmal_util.so
1> /usr/bin/ld: cannot find -llibmmal_vc_client.so
1> /usr/bin/ld: cannot find -llibvcos.so
1> /usr/bin/ld: cannot find -llibbcm_host.so
1> /usr/bin/ld: cannot find -llibbrcmGLESv2.so
1> /usr/bin/ld: cannot find -llibbrcmEGL.so
1> /ld: cannot find -llibbcm_host.so
1> /usr/bin/ld: cannot find -llibbrcmGLESv2.so
1> /usr/bin/ld: cannot find -llibbrcmEGL.so
1> collect2: error: ld returned 1 exit status
pi上的make文件有这个,它编译和链接没有问题。我错过了什么吗?
cmake_minimum_required(VERSION 2.8)
project( picamdemo )
SET(COMPILE_DEFINITIONS -Werror)
include_directories(/opt/vc/include)
link_directories(/opt/vc/lib)
add_executable(picamdemo picam.cpp camera.cpp cameracontrol.cpp graphics.cpp)
target_link_libraries(picamdemo libmmal_core.so libmmal_util.so libmmal_vc_client.so libvcos.so libbcm_host.so libbrcmGLESv2.so libbrcmEGL.so)
答案 0 :(得分:0)
“使用'-l'开关,将省略文件扩展名和前缀'lib': 例如。如果库的名称是'libmmal_core.so',那么
-lmmal_core