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.
Related
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.
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
I've been trying to install the nana library for c++. I've used these guides:
https://github.com/qPCR4vir/nana-docs/wiki/Installation
https://github.com/qPCR4vir/nana-docs/wiki/Install-and-use-nana-with-mingw---step-by-step
I got stuck on the part that says "Create a static linkage library solution within a IDE/build system you use, and add all the files which are placed in NanaPath/source and in all its sub directories to the project. Then compile the solution and you will get a static linkage file NanaStatic in a path similar to NanaPath/build/bin/IDEName."
I downloaded MinGW, git, and cmake like it said. I opened up the bat file, ran the "git clone" with the link, ran
cmake -G "MinGW Makefiles"
It did it's thing and finished successfully. Then I tried running "make" and it got to 6% when this showed up:
In file included from C:/Users/.../nana/verbose_prepocessor.hpp:99:0,
from C:\Users\...\nana\source\deploy.cpp:242:C/Users/.../nana/include/filesystem/filesystem.hpp:71:39: fatal error: experimental/filesystem: No such file or directory
# include<experimental/filesystem>
^
compilation terminated.
make[2]: *** [CMakeFiles\nana.dir\build.make:163: CMakeFiles/nana.dir/source/deploy.cpp.obj] Error 1
make[1]: *** [CMakeFiles\Makefile2:67: CMakeFiles/nana.dir/all] Error 2
make: *** [Makefile:129: all] Error 2
I tried using a different source of the code (git and sourceforge) and that didn't make a difference. I tried using the GUI cmake, but I had other errors with that not recognizing MinGW. I looked around for answers online, but they mostly led back to the guides I was using. I checked my GCC and G++ version with gcc/g++ --version, and they're both 6.3.0.
I'll take any suggestions/advice, thanks!
I have not used Eclipse, so I cant help with that. But I will try to help with nana:
Originaly there was no std::filesystem and nana offered one JinHao invented. With the apparition of std::experimental::filsystem candidate, an experimental filesystem in the sdt:: c++ library of some versions of some compilers we adapted the nana filesystem to be a partial implementation of that. Then nana try to configure itself to use the provided std:: (or Boost) implementation or if it is not there then nana::filesystem. It seems like MinGW have problems with filesystem, I'm not sure about that but here you can read: https://github.com/Alexpux/MINGW-packages/issues/2292
Please try to undertstand what is going on in your case an let us know about. We will then try to fix the configuration of nana to work even in that situation.
You can always simply choise to (force) use the nana implementation. Just please compile both the nana library and your project with all the same options, including what filesytem you use. For example adding -DNANA_CMAKE_NANA_FILESYSTEM_FORCE=True to your cmake or define NANA_FILESYSTEM_FORCE in your built system (or IDE).
I have downloaded armadillo 6.5. it needs superLU(4.3) library to solve sparse matrix system of equations.
I have downloaded superlu from here but when i want to make it in windows, it gives:
( cd SRC; make )
process_begin: CreateProcess(NULL, ( cd SRC; make ), ...) failed.
make (e=2): The system cannot find the file specified.
Makefile:36: recipe for target 'superlulib' failed
make: *** [superlulib] Error 2
if i cd to SRC directory manually and do make in there, a lot of *.o file is created but again i get this error:
ar cr /Codes/SuperLU/SuperLU_4.3/lib/libsuperlu_4.3.a \
sgssv.o sgssvx.o ssp_blas2.o ssp_blas3.o sgscon.o slangs.o sgsequ.o slaqgs.o spivotgrowth.o sgsrfs.o sgstrf.o sgstrs.o scopy_to_ucol.o ssnode_dfs.o ssnode_bmod.o spanel_dfs.o sp
anel_bmod.o sreadhb.o sreadrb.o sreadtriple.o scolumn_dfs.o scolumn_bmod.o spivotL.o spruneL.o smemory.o sutil.o smyblas2.o sgsisx.o sgsitrf.o sldperm.o ilu_sdrop_row.o ilu_ssnode_dfs.o
ilu_scolumn_dfs.o ilu_spanel_dfs.o ilu_scopy_to_ucol.o ilu_spivotL.o sdiagonal.o superlu_timer.o util.o memory.o get_perm_c.o mmd.o sp_coletree.o sp_preorder.o sp_ienv.o relax_snode.o
heap_relax_snode.o colamd.o ilu_relax_snode.o ilu_heap_relax_snode.o mark_relax.o mc64ad.o qselect.o lsame.o xerbla.o slacon.o slamch.o
ar: /Codes/SuperLU/SuperLU_4.3/lib/libsuperlu_4.3.a: No such file or directory
Makefile:117: recipe for target 'single' failed
make: *** [single] Error 1
i almost have no experience with "make" and "superlu". how can i make superlu in windows? is there any precompiled superlu library available for windows?
Well, it seems that makefile is written for linux systems.
I could do three thing:
follow the instructions on superLU FAQ page:
This was tested in MS Visual Studio. However the configuration highly
depends on which compiler you using. Normally there is an IDE
(Integrated Development Environment) editor associated with your
compiler. You can do it in two steps:
Step I: Create SuperLU library file
Create a new project, then include all the .c and .h files in SRC directory (they can be put in two folders of the IDE).
Change the property of the project to make the output as Library file .lib (not .exe or .dll file).
Compile the project to produce the library file, e.g. superlu.lib. (after you successfully compile it, you can build a
release version without the debug information).
Step II: Build your own application Create a new project with your own
source files which call the SuperLU routines.Add the SRC directory and
the directory where superlu.lib is located to the include path and
library searching path respectively.
Add superlu.lib as the link optional library.
Compile your own .dll or .exe file. Then you are done.
If you are using a compiler with command line only, you have to play
with the makefile or -I -L -O -c options. As SuperLU calls BLAS
routines but BLAS is not a native library of MS Visual Studio, you
have to build your own BLAS library in the similar way as SuperLU
library. The SuperLU distribution includes a C version of BLAS in
SuperLU/CBLAS directory. This version is only functional but not fast.
For speed, it's better to use vendor-supplied BLAS (e.g., Intel MKL)
or public domain versions (e.g., ATLAS, or Goto BLAS).
i could not do it right.
rewrite the whole makefile for windows(i couldn't do it either because i dont know how to write a makefile)
And finally the working solution(for me):
I found a repo in github that added superLU build support for windows!
you can find it here
it has a Visual Studio(2010) solution file that builds the library and gives a lib file.
I am running sample programs in g2o graph library in linux using cmake. I am getting the following error. The file i am running has the following code
#include <Eigen/Core>
which is causing the error.
[ 3%] Building CXX object data_fitting/CMakeFiles/circle_fit.dir/circle_fit.o g2o/trunk/g2o/examples/data_fitting/circle_fit.cpp:27:2 3: fatal error: Eigen/Core: No such file or directory
compilation terminated.
make[2]: *** [data_fitting/CMakeFiles/circle_fit.dir/circle_fit.o] Error 1
make[1]: *** [data_fitting/CMakeFiles/circle_fit.dir/all] Error 2
I am new to using cmake. Is this because of an error in the CMakeLists.txt file?
INCLUDE_DIRECTORIES(${CSPARSE_INCLUDE_DIR})
ADD_EXECUTABLE(circle_fit
circle_fit.cpp
)
SET_TARGET_PROPERTIES(circle_fit PROPERTIES OUTPUT_NAME circle_fit${EXE_POSTFIX})
TARGET_LINK_LIBRARIES(circle_fit core solver_csparse)
ADD_EXECUTABLE(curve_fit
curve_fit.cpp
)
SET_TARGET_PROPERTIES(curve_fit PROPERTIES OUTPUT_NAME curve_fit${EXE_POSTFIX})
TARGET_LINK_LIBRARIES(curve_fit core)
I am struggling with this for a day now. The tutorials available for cmake are also not helping much. How can I fix this error?
I tried adding include statement for /usr/include/eigen3 as the first answer suggested. But I cannot find any file named eigen3 in the /usr/include directory.
Is there any other possible path? How can I find it in linux?
Try to include the eigen include folder in cmake.
INCLUDE_DIRECTORIES( /usr/include/eigen3 )
It worked for me on the same error.
The readme says that you need to install libeigen3-dev (https://svn.openslam.org/data/svn/g2o/trunk/README)
If you are on Ubuntu user install it using apt-get or synaptic.
And for Windows :
"If you are compiling on Windows, please download Eigen3 and extract it.
Within cmake-gui set the variable G2O_EIGEN3_INCLUDE to that directory"
Do read the 'readme' :)