I would like to add a 3rd party lib (called taco) to my project. In the CMakeLists.txt of my project I did the following:
FetchContent_Declare(
taco
GIT_REPOSITORY https://github.com/tensor-compiler/taco.git
GIT_TAG master
)
FetchContent_MakeAvailable(taco)
When compiling, the compiler complains
[ 48%] Building CXX object _deps/taco-build/src/CMakeFiles/taco.dir/lower/tensor_path.cpp.o
/home/miaodi/repo/mfemMechanics/release/_deps/taco-src/src/lower/lowerer_impl_imperative.cpp: In member function ‘std::vector<taco::ir::Stmt> taco::LowererImplImperative::constructInnerLoopCasePreamble(taco::ir::Expr, taco::IndexVar, taco::MergeLattice, std::map<taco::Iterator, taco::ir::Expr>&)’:
/home/miaodi/repo/mfemMechanics/release/_deps/taco-src/src/lower/lowerer_impl_imperative.cpp:1935:21: error: reference to ‘conjunction’ is ambiguous
1935 | nonZeroCase = conjunction({coordComparisons[i], valueComparisons[i]});
| ^~~~~~~~~~~
In file included from /home/miaodi/repo/mfemMechanics/release/_deps/taco-src/src/lower/lowerer_impl_imperative.cpp:12:
/home/miaodi/repo/mfemMechanics/release/_deps/taco-src/include/taco/ir/ir_generators.h:20:6: note: candidates are: ‘taco::ir::Expr taco::ir::conjunction(std::vector<taco::ir::Expr>)’
20 | Expr conjunction(std::vector<Expr> exprs);
| ^~~~~~~~~~~
In file included from /usr/include/c++/9/bits/move.h:55,
from /usr/include/c++/9/bits/stl_pair.h:59,
from /usr/include/c++/9/bits/stl_algobase.h:64,
from /usr/include/c++/9/vector:60,
from /home/miaodi/repo/mfemMechanics/release/_deps/taco-src/include/taco/lower/mode_format_impl.h:4,
from /home/miaodi/repo/mfemMechanics/release/_deps/taco-src/include/taco/lower/mode_format_compressed.h:4,
from /home/miaodi/repo/mfemMechanics/release/_deps/taco-src/src/lower/lowerer_impl_imperative.cpp:1:
/usr/include/c++/9/type_traits:155:12: note: ‘template<class ... _Bn> struct std::conjunction’
155 | struct conjunction
| ^~~~~~~~~~~
If I build this library (taco) without using FetchContent_Declare (mkdir build && cd build && cmake ..), this issue won't show up.
After I fixed this by adding the scope 'taco::ir::' to conjunction, I got the second issue:
/home/miaodi/repo/mfemMechanics/release/_deps/taco-src/tools/taco.cpp:35:10: fatal error: taco/version.h: No such file or directory
35 | #include "taco/version.h"
| ^~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [_deps/taco-build/tools/CMakeFiles/taco-tool.dir/build.make:76: _deps/taco-build/tools/CMakeFiles/taco-tool.dir/taco.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:889: _deps/taco-build/tools/CMakeFiles/taco-tool.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
which also does not happen when I compile it without using FetchContent_Declare.
My question is: how can I fix these issues without touching the source code?
Related
any ideas for this?
I try to build SDRangel on my M1 Mac but at 77% I get this error ...
-- GIT_EXECUTABLE /opt/local/bin/git
-- GIT LIVE REPO VERSION RETRIEVED
-- X265 RELEASE VERSION 3.5+68-40e37bce9
-- Detected CXX compiler using -O3 optimization level
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/build/sdrangel/build/external/x265/src/x265-build
[ 27%] Performing build step for 'x265'
Consolidate compiler generated dependencies of target common
[ 45%] Built target common
Consolidate compiler generated dependencies of target encoder
[ 65%] Built target encoder
[ 76%] Built target x265-static
[ 77%] Linking CXX shared library libx265.dylib
Undefined symbols for architecture arm64:
"x265_entropyStateBits", referenced from:
_x265_costCoeffNxN_neon in pixel-util.S.o
(maybe you meant: _x265_entropyStateBits)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[5]: *** [libx265.206.dylib] Error 1
make[4]: *** [CMakeFiles/x265-shared.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [external/x265/src/x265-stamp/x265-build] Error 2
make[1]: *** [external/CMakeFiles/x265.dir/all] Error 2
make: *** [all] Error 2
I am stuck. Don't know what to try to solve this issue.
I did not find anything anywhere ...
Working on it for most of 2 days, I did find this site that presents a working method of building libx265 stuff on Apple Silicon and works for me on macOS 13.0.1. https://www.osxexperts.net/ Problem is, it only builds the libraries for building it into ffmpeg, no executable binary.
When I tried to get the executable also, by removing -DENABLE_CLI=OFF from the last cmake command, the error comes back. Put it back in, everything completes without error.
Here is the full process that works for me (no executable). It builds a multilibrary that can encode 8, 10, or 12-bit video:
cd x265/source
#### 12 bit
cmake -DCMAKE_INSTALL_PREFIX:PATH=${TARGET} -DHIGH_BIT_DEPTH=ON -DMAIN12=ON -DENABLE_SHARED=NO -DEXPORT_C_API=NO -DENABLE_CLI=OFF .
make
mv libx265.a libx265_main12.a
make clean-generated
rm CMakeCache.txt
#### 10bit
cmake -DCMAKE_INSTALL_PREFIX:PATH=${TARGET} -DHIGH_BIT_DEPTH=ON -DMAIN10=ON -DENABLE_SHARED=NO -DEXPORT_C_API=NO -DENABLE_CLI=OFF .
make clean
make
mv libx265.a libx265_main10.a
make clean-generated && rm CMakeCache.txt
#### 8 bit and all together
# removed -DENABLE_CLI=OFF from last one so we get the x265 binary
cmake -DCMAKE_INSTALL_PREFIX:PATH=${TARGET} -DEXTRA_LIB="x265_main10.a;x265_main12.a" -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=ON -DLINKED_12BIT=ON -DENABLE_SHARED=OFF -DENABLE_CLI=OFF .
make clean
make
mv libx265.a libx265_main.a
# this is Apple's libtool
libtool -static -o libx265.a libx265_main.a libx265_main10.a libx265_main12.a
make install
When I remove the last -DENABLE_CLI=OFF, here's the error:
[100%] Linking CXX executable x265
Undefined symbols for architecture arm64:
"x265_entropyStateBits", referenced from:
_x265_costCoeffNxN_neon in libx265.a(pixel-util.S.o)
_x265_10bit_costCoeffNxN_neon in libx265_main10.a(pixel-util.S.o)
_x265_12bit_costCoeffNxN_neon in libx265_main12.a(pixel-util.S.o)
(maybe you meant: _x265_entropyStateBits)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [x265] Error 1
make[1]: *** [CMakeFiles/cli.dir/all] Error 2
make: *** [all] Error 2
JimsMBPro:source jim$
EDIT: #Peter Betz, see the issue report. Until the developers correct this error, it will compile if you edit x265/source/common/aarch64/pixel-util.S, line 2410. Add an underscore as follows. Change:
movrel x1, x265_entropyStateBits
to
movrel x1, _x265_entropyStateBits
My Yocto sources are on Warrior currently and I am in a process of migrating them to dunfell so I cloned all the required layers for dunfell branch including meta-swupdate.
Now, I am trying to generate swupdate image by bitbake swupdate-image command for dunfell and I am getting errors as given below:
.
.
In file included from /home/panther2/dunfell/build/tmp/work/corei7-64-poky-linux/swupdate/2021.04-r0/git/corelib/verify_signature.c:15:
/home/panther2/dunfell/build/tmp/work/corei7-64-poky-linux/swupdate/2021.04-r0/git/include/sslapi.h:31:10: fatal error: openssl/bio.h: No such file or directory
31 | #include <openssl/bio.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
.
.
make[2]: *** [core/swupdate.o] Error 1
/home/panther2/dunfell/build/tmp/work/corei7-64-poky-linux/swupdate/2021.04-r0/git/mongoose/mongoose.c:4473:10: fatal error: openssl/ssl.h: No such file or directory
4473 | #include <openssl/ssl.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
.
.
Looks like it is unable to find ssl related header files. Any lead on this?
There is no openssl dependency in the swupdate recipe.
Adding DEPENDS += "openssl" in a swupdate_%.bbappend file helps.
I installed CGAL and tried to follow manual, but I failed to build example Triangulation_2. I used terminal in mac and run the code.
[ 50%] Building CXX object CMakeFiles/draw_triangulation_2.dir/draw_triangulation_2.cpp.o
In file included from /Users/janeh/Downloads/CGAL-5.0.2/examples/Triangulation_2/draw_triangulation_2.cpp:3:
/usr/local/include/CGAL/draw_triangulation_2.h:16:10: fatal error:
'CGAL/Qt/Basic_viewer_qt.h' file not found
#include <CGAL/Qt/Basic_viewer_qt.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/draw_triangulation_2.dir/draw_triangulation_2.cpp.o] Error 1
make[1]: *** [CMakeFiles/draw_triangulation_2.dir/all] Error 2
I checked Basic_viewer_qt.h and it is at the right location
/Users/janeh/Downloads/CGAL-5.0.2/include/CGAL/Qt/Basic_viewer_qt.h
But somehow draw_triangulation_2.h can't include it. Is there any reason why this happens?
I have started with a project that are using the simple2d library (https://github.com/simple2d/simple2d). But when I try to build my small example project I get a DSO missing error. I think a have manage to link the dependencies for simple2d, but apparently I'm still some thing.
Here is the output:
> ====================[ Build | c_game | Debug ]==================================
/home/fredrik/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/192.5728.100/bin/cmake/linux/bin/cmake --build /home/fredrik/Repos/c_game/cmake-build-debug --target c_game -- -j 2 -m
[ 50%] Linking C executable c_game
/usr/bin/ld: /usr/local/lib/libsimple2d.a(gl.o): undefined reference to symbol 'fmin##GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/c_game.dir/build.make:85: recipe for target 'c_game' failed
make[3]: *** [c_game] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/c_game.dir/all' failed
make[2]: *** [CMakeFiles/c_game.dir/all] Error 2
CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/c_game.dir/rule' failed
make[1]: *** [CMakeFiles/c_game.dir/rule] Error 2
Makefile:118: recipe for target 'c_game' failed
make: *** [c_game] Error 2
And here is my CMakeList.txt, I hope someone can help me.
cmake_minimum_required(VERSION 3.14)
project(c_game C)
set(CMAKE_C_STANDARD 11)
find_package(SDL2 REQUIRED)
find_package(GLEW REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS})
add_executable(c_game main.c)
find_library(SIMPLE2D_LIB libsimple2d.a /usr/local/lib)
message(${SIMPLE2D_LIB})
message(${SDL2_INCLUDE_DIRS})
message(${GLEW_INCLUDE_DIRS})
target_include_directories(c_game PUBLIC ${SDL2_INCLUDE_DIRS} ${GLEW_INCLUDE_DIRS})
target_link_libraries(c_game ${SIMPLE2D_LIB} ${SDL2_LIBRARIES} ${GLEW_LIBRARIES})
On the command line, the following produces an executable:
g++ -o a.out main.cpp class1.cc class2.cc /usr/lib/libgsl.a /usr/lib/libgslcblas.a
However I am unsure how to get cmake to work properly.
When I add a line like
include_directories(/usr/lib/)
link_libraries(usr/lib/libgsl.a usr/libgslcblas.a)
the configuring seems to work but building fails:
CMakeFiles/kmv.dir/main.o: In function `main':
main.cpp:27: undefined reference to `gsl_matrix_alloc'
main.cpp:35: undefined reference to `gsl_matrix_fscanf'
collect2: ld returned 1 exit status
make[2]: *** [kmv] Error 1
make[1]: *** [CMakeFiles/kmv.dir/all] Error 2
make: *** [all] Error 2
*** Failed ***
Seems to be a synthax problem. Any hint is welcome. Thank you.
Instead of
include_directories(/usr/lib)
link_libraries(usr/lib/libgsl.a usr/libgslcblas.a)
try
add_executable (targetName main.cpp class1.cc class2.cc)
target_link_libraries(targetName gsl gslcblas)
Where targetName is the name of the output binary you intend to create. The path /usr/lib should already be in the default library search path for CMake, so you shouldn't have to specify that, but if you did have to specify a custom library path, you would do it like so
link_directories(/some/custom/library/path)
The include_directories CMake directive is used for adding header search paths, not library search paths...
Probably, link_libraries is deprecated
http://www.cmake.org/pipermail/cmake/2009-April/028439.html
Try using target_link_libraries instead.