No rule to make target `libbrcmEGL.so', needed by `HelloTriangle' - c++

I'm trying to cross-compile an OpenGLES2.0 example HelloTriangle using VisualGDB for the RaspberryPi 3 running Raspbian lite.
I assume I was able to include the libraries libbrcmEGL.so and libbrcmGLESv2.so correctly in my CMakeLists.txt file
because instead of giving me these errors:
c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/6/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -lLIBGLES
c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/6/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -lLIBEGL`
It gives me these errors
make[2]: *** No rule to make target `libbrcmEGL.so', needed by `HelloTriangle'. Stop.`
This is my CMakeLists file:
cmake_minimum_required(VERSION 2.7)
project(HelloTriangle)
set(LIBRARIES_FROM_REFERENCES "")
add_executable(HelloTriangle HelloTriangle.cpp esShapes.c esTransform.c esUtil.c esShader.c)
include_directories(include)
target_link_libraries(HelloTriangle ${CMAKE_BINARY_DIR}/libbrcmGLESv2.so ${CMAKE_BINARY_DIR}/libbrcmEGL.so "${LIBRARIES_FROM_REFERENCES}")
I don't understand what else it needs to make the target. Looking around stack overflow, I saw suggestions to add
LINK_DIRECTORIES(/opt/vc/lib/)
I also tried
target_link_libraries(HelloTriangle /opt/vc/lib/libbrcmGLESv2.so /opt/vc/lib/libbrcmEGL.so "${LIBRARIES_FROM_REFERENCES}")
I also checked that I have these libraries in my sysroot in:
C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot
I still get the same error:
I need some help figuring out what is missing from my CMakeLists.txt

Changed to target_link_libraries(HelloTriangle ${CMAKE_CURRENT_SOURCE_DIR}/lib/libbrcmGLESv2.so ${CMAKE_CURRENT_SOURCE_DIR}/lib/libbrcmEGL.so "${LIBRARIES_FROM_REFERENCES}") and it compiled

Related

" /bin/sh: 1: Syntax error: "(" unexpected " error while building code for raspberry pi pico

I am on Ubuntu.
I am trying to build a simple project that I know worked! (I already made it work) I don't think I changed something to it but it has been three days and I cannot find a way to make it build again.
I use a library named pico-DMX, whenever I don't add it to my project with "include" in cmake, than the make starts building.
Otherwise, if I include the library in the cmake code, cmake .. command process and generate normally but the build ctrying to build a simple project that I know workedrashes instantaneously. I cannot seem to understand where it comes from.
This is the error message:
PICO_SDK_PATH is /home/andrew/pico/pico-sdk
PICO platform is rp2040.
Build type is Release
PICO target board is pico.
Using board configuration from /home/andrew/pico/pico-sdk/src/boards/include/boards/pico.h
TinyUSB available at /home/andrew/pico/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB.
cyw43-driver available at /home/andrew/pico/pico-sdk/lib/cyw43-driver
lwIP available at /home/andrew/pico/pico-sdk/lib/lwip
-- Configuring done
-- Generating done
-- Build files have been written to: /home/andrew/pico/serial_pico (copy)/build
Scanning dependencies of target bs2_default
[ 1%] Building ASM object pico-sdk/src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/compile_time_choice.S.obj
[ 2%] Linking ASM executable bs2_default.elf
/bin/sh: 1: Syntax error: "(" unexpected
make[2]: *** [pico-sdk/src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/build.make:98: pico-sdk/src/rp2_common/boot_stage2/bs2_default.elf] Error 2
make[2]: *** Deleting file 'pico-sdk/src/rp2_common/boot_stage2/bs2_default.elf'
make[1]: *** [CMakeFiles/Makefile2:1493: pico-sdk/src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
This is my main cmake files:
cmake_minimum_required(VERSION 3.13)
include($ENV{PICO_SDK_PATH}/pico_sdk_init.cmake)
project(usb_control C CXX ASM)
set(CMAKE_CXX_STANDARD 17)
pico_sdk_init()
include($ENV{HOME}/pico/libraries/lib/Pico-DMX/interfaceLibForPicoSDK.cmake)
add_executable(usb_control
main.cpp
)
target_link_libraries(usb_control picodmx pico_stdlib hardware_pio hardware_dma)
pico_enable_stdio_usb(usb_control 1)
pico_enable_stdio_uart(usb_control 0)
pico_add_extra_outputs(usb_control)
The previous cmake file include $ENV{HOME}/pico/libraries/lib/Pico-DMX/interfaceLibForPicoSDK.cmake which contains :
## Include this file if you want to use the Pico-DMX library
## in YOUR (Pico-C-SDK-based) project.
cmake_minimum_required(VERSION 3.12)
# Define the Pico-DMX library
add_library(picodmx INTERFACE)
target_sources(picodmx INTERFACE
${CMAKE_CURRENT_LIST_DIR}/src/DmxInput.cpp
${CMAKE_CURRENT_LIST_DIR}/src/DmxOutput.cpp
)
pico_generate_pio_header(picodmx
${CMAKE_CURRENT_LIST_DIR}/extras/DmxInput.pio
)
pico_generate_pio_header(picodmx
${CMAKE_CURRENT_LIST_DIR}/extras/DmxOutput.pio
)
target_include_directories(picodmx INTERFACE
${CMAKE_CURRENT_LIST_DIR}/src
)
Again, I know there are no mistakes in the C++ code, it worked! It started to bug and wouldn't work again when I played with the Cmake to include directly the library dependencies of pico-dmx in its cmake file.
If you have any questions feel free to ask, I'll answer quickly. In advance thank you for your help
As mentioned in the comments, the cause is the name of your directory. In order to accurately explain why it happens, I reproduced your situation myself. I created a dummy project under "/tmp/test checkout (copy)" and built using CMake:
cd "/tmp/test checkout (copy)/build/pico-sdk/src/rp2_common/boot_stage2" && \
arm-none-eabi-objdump -h /tmp/test\ checkout\ (copy)/build/pico-sdk/src/rp2_common/boot_stage2/bs2_default.elf >bs2_default.dis
Note that the spaces in the full filename are correctly escaped with a backslash, but the parentheses are not. This confuses the shell.
I raised this issue on the Pico SDK. Until it is fixed, (EDIT: it was fixed in Dec 2022) people should steer clear of using special characters in their directory structures. This is a good recommendation in general as it avoids situations like these.

CMake not building a library when added as a subdirectory

I added the xgboost library as a git submodule of my project and I'm trying to add it to cmake as a subdirectory. Unfortunately it's not working. A simple hello world project with the following CMakeLists.txt replicates the error that I'm getting.
cmake_minimum_required(VERSION 3.2)
project(foo)
add_subdirectory(xgboost)
add_executable(${PROJECT_NAME} foo.cpp)
target_link_libraries(${PROJECT_NAME} xgboost)
After building the library there is nothing in the xgboost/lib directory so I get the following error.
clang: error: no such file or directory:
'/Users/.../myproject/xgboost/lib/libxgboost.dylib'
I think that the problem is generated in their CMakeLists file since they have two different targets. Maybe cmake is choosing the wrong target but I'm not familiar enough with cmake to figure it out. The following code is from xgboost's CMakeLists.
# Executable
add_executable(runxgboost $<TARGET_OBJECTS:objxgboost> src/cli_main.cc)
set_target_properties(runxgboost PROPERTIES
OUTPUT_NAME xgboost
)
set_output_directory(runxgboost ${PROJECT_SOURCE_DIR})
target_link_libraries(runxgboost ${LINK_LIBRARIES})
# Shared library
add_library(xgboost SHARED $<TARGET_OBJECTS:objxgboost>)
target_link_libraries(xgboost ${LINK_LIBRARIES})
set_output_directory(xgboost ${PROJECT_SOURCE_DIR}/lib)
#Ensure these two targets do not build simultaneously, as they produce outputs with conflicting names
add_dependencies(xgboost runxgboost)
My questions in order of importance are:
Is there any way to fix it without modifying xgboost's CMakeLists.txt file?
Is it reasonable to try to add xgboost to my project as a git submodule?
Is there any reason cmake is not instructing to build the library?
Note: There were several edits to this question since I tried to narrow down the problem and to provide more information.
(I would love to ask for few things beforehand in the comment section, but I have too low reputation to do so, so I will just give it a shot ;))
I have few suspects, and one of them is ${CMAKE_SOURCE_DIR} of the submodule's root CMakeLists.txt. Although the paths are set properly when you run that CMakeLists.txt alone, cmake gets confused the moment you add it as your subdirectory. Have you looked into another directories for your output binaries?
First I would suggest testing this hypothesis, and then I would suggest writing similar, but separate CMakeLists.txt file for xgboost library, and then substitute it in the project temporarily. Unfortunately the CMakeLists.txt filename is hardcoded and there is no possibility to have two files of that kind in one directory; so it seems that the answer to 1) is, that you rather have to change the file.
For the 2): as long as it does not require huge additional logic in your CMakeLists.txt, it makes sense. Other viable option is to create an install target, which you can use to install your xgboost library locally (using CMAKE_INSTALL_PREFIX(doc) variable), and then add the installation path to your CMAKE_LIBRARY_PATH(doc).

No rule to make target *.so

I am trying to build this https://github.com/felixendres/rgbdslam_v2 with ROS catkin. However, that shouldn't be that relevant. The error I am getting is with my installation of qt4.
No rule to make target /usr/lib/arm-linux-gnueabihf/libQtGui.so', needed by/home/odroid/catkin_ws/devel/lib/rgbdslam/rgbdslam'. Stop.
I heard else where that this is caused by duplicate library files, but when I do
ldconfig -p | grep libQtGui
I get
libQtGui.so.4 (libc6,hard-float) => /usr/lib/arm-linux-gnueabihf/libQtGui.so.4
libQtGui.so (libc6,hard-float) => /usr/lib/arm-linux-gnueabihf/libQtGui.so
How would I fix this build error? I think it has something to do with RGBDSLAM not being designed for arm and searching in the wrong place, but it is only doing a find_package(Qt4 REQUIRED) and include(${QT_USE_FILE})
Edit: Another example:
No rule to make target /usr/lib/libpcl_io.so', needed by/home/odroid/catkin_ws/devel/lib/pcl_ros/convert_pcd_to_image'
I compiled both qt4 and pcl from source and only did sudo make install.
This error means that a second copy of the library is lying around. Run aptitude search to find the extra copy.

I can't run a program that uses allegro5 with cmake

EDIT: If you want to look at the code, here it is:
https://github.com/WalterCapa/PercolationCpp/tree/master
I'm making a program that uses allegro5 library to generate an animation.
Because i want to avoid the installation of the library on every computer that uses the program, i tried to paste the headers and the .so files in my project dir. So the tree is like this:
root
include
allegro5 <- (Dir where the headers of allegro are)
Percolation.h
QuickUnion.h
lib
allegro5 <-(Dir where the .so files are)
Percolation.cpp
QuickUnion.cpp
PercolationVisualizer <- (Dir that has the main)
The problem is this. I installed allegro5 in my pc with LinuxMint 13. Everything is fine if I compile from Code::Blocks or if I do it from the terminal using -I to call the hedaers and -L to tell where the .so files are, and even using cmake works fine, but when i try to do it in another computer, even if it's windows like my laptop or a virtual machine with linuxmint, it generates this error:
make[2]: *** No rule to make target '/./lib/allegro5/liballegro.so/', needed by'
../bin/PercolationVisualizer'. Stop.
make[1]: *** [CMakeFiles/PercolationVisualizer.dir/all] Error 2
make: *** [all] Error 2
This is my CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.7)
project(PercolationCpp)
set(PercolationCpp_VERSION_MAJOR 0)
set(PercolationCpp_VERSION_MINOR 1)
set(EXECUTABLE_OUTPUT_PATH ../bin/)
set(percolation_SRCS PercolationVisualizer/PercolationVisualizer.cpp lib/Percolation.cpp lib/QuickUnion.cpp)
#Executable
add_executable(PercolationVisualizer ${percolation_SRCS})
#include Allegro
include_directories(./include)
link_directories(./lib/allegro5)
#connect all the libraries
set(allegro5_LIBS /./lib/allegro5/liballegro.so /./lib/allegro5/liballegro_primitives.so)
target_link_libraries(PercolationVisualizer ${allegro5_LIBS})
Btw, when trying it on windows with MinGW i used cmake -G "MinGW Makefiles" .. and mingw32-make.
It found the compiler and and cmake worked, but when i tried de second one it gave me the same error. In my desktop i'm compiling using g++.
I think that your actual problem is the leading / in this line:
set(allegro5_LIBS /./lib/allegro5/liballegro.so /./lib/allegro5/liballegro_primitives.so)
A leading slash will tell cmake to look for an absolute path (like /usr/lib...) and not prefix it with a CMAKE_*_DIR. Try this
set(allegro5_LIBS ${CMAKE_SOURCE_DIR}/lib/allegro5/liballegro.so ${CMAKE_SOURCE_DIR}/lib/allegro5/liballegro_primitives.so)
However I strong discourage you to include pre-built libraries in your project. If you can, integrate a tar-ball or a git-submodule. If the project you include is a cmake project itself, a simple call to add_subdirectory will make the targets (libraries usually) available to your project and create a dependency. If the project is based on configure you can use the ExternalProject-extension.

How to make Cmake to include gl/GL.h?

Hello I am new to Linux development, and just recently switched from Windows MSVS c++ development to Linux-based vim+cmake+gcc. I am using Debian Sid(unstable).
I am trying to get code on subdivision, I have gotten from a friend to run. I am not really used to Cmake, and googling for help often is troublesome, since every other dist seems to have different packages and different solutions.
cmake_minimum_required (VERSION 2.6) project (Benchmark)
Find_Package(Qt4 REQUIRED)
Include(${QT_USE_FILE})
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})
set(CORELIBS ${QT_LIBRARY} ${OPENGL_LIBRARY} )
File(GLOB SRC ".cpp")
File(GLOB HEAD ".h")
add_executable(Benchmark ${SRC})
target_link_libraries(Benchmark ${CORELIBS})
That is my current Cmake, I want to use find_package(), GLOB etc to make it as dynamic as possible, and not use absolute paths.
I get the following error when trying to build.
subdivbench/Matrix4x4.h:4:19: fatal error: gl/GL.h: No such file or directory #include gl/GL.h
compilation terminated. make[2]: [CMakeFiles/Benchmark.dir/Matrix4x4.cpp.o] Error 1 make[1]: [CMakeFiles/Benchmark.dir/all] Error 2
The code is fairly irrelevant, since it's working perfectly in windows, all I need to do is to make the include etc work for Linux.
Include GL/gl.h instead of gl/GL.h
From what hanslovsky said:
I have mesa installed on my system and made a small sample
CMakeLists.txt: FIND_PACKAGE(OpenGL REQUIRED)
MESSAGE("${OPENGL_INCLUDE_DIR}") The output is: /usr/include --
Configuring done -- Generating done -- Build files have been written
to: /home/phil/local/tmp/opengl So your cmake code appears correct to
me.
What I found out: I need to include GL/gl.h, not gl/GL.h. edit:
Sorry for that formatting, I did not know it does not work in
comments.
This worked. Thanks a tons hanslovsky, it was just a capitalization problem.