I am trying to install Armadillo link.
However, make command complains about "clapack.h" which does exists at location /usr/include/atlas/clapack.h. Some help would be appreciated.
Note, I can run it if I copy that file to /usr/include/ and then make:
$ sudo cp /usr/include/atlas/clapack.h /usr/include/
$ make
But, I am not comfortable in making copies of same file in multiple location. Could it be dangerous?
This is what I did so far:
1) I downloaded and tar the armadillo library. After that, I changed following lines in CMakeLists.txt (I have Lapack, Blas, Atlas):
set(ARMA_USE_LAPACK true)
set(ARMA_USE_BLAS true)
set(ARMA_USE_ATLAS true)
set(ARMA_USE_HDF5_ALT false)
set(ARMA_USE_ARPACK false)
set(ARMA_USE_CXX11_RNG false)
set(ARMA_USE_WRAPPER true )
then "$cmake ." runs successfully and finds Lapack, Blas and Atlas.
However, when I run "make" it gives following error (line 26 marked in the code include_atlas.hpp):
$ make
Scanning dependencies of target armadillo
[100%] Building CXX object CMakeFiles/armadillo.dir/src/wrapper.cpp.o
In file included from /home/dkumar/Downloads/armadillo-4.600.3/src/wrapper.cpp:10:0:
/home/dkumar/Downloads/armadillo-4.600.3/tmp/include/armadillo_bits/include_atlas.hpp:26:47: fatal error: /usr/include/clapack.h: No such file or directory
#include ARMA_INCFILE_WRAP(ARMA_CLAPACK)
^
compilation terminated.
make[2]: *** [CMakeFiles/armadillo.dir/src/wrapper.cpp.o] Error 1
make[1]: *** [CMakeFiles/armadillo.dir/all] Error 2
make: *** [all] Error 2
When I look at include_atlas.hpp, it seems that ARMA_USE_ATLAS is still set false:
// Copyright (C) 2008-2011 Conrad Sanderson
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#if defined(ARMA_USE_ATLAS)
#if !defined(ARMA_ATLAS_INCLUDE_DIR)
extern "C"
{
#include <cblas.h>
#include <clapack.h>
}
#else
#define ARMA_STR1(x) x
#define ARMA_STR2(x) ARMA_STR1(x)
#define ARMA_CBLAS ARMA_STR2(ARMA_ATLAS_INCLUDE_DIR)ARMA_STR2(cblas.h)
#define ARMA_CLAPACK ARMA_STR2(ARMA_ATLAS_INCLUDE_DIR)ARMA_STR2(clapack.h)
extern "C"
{
#include ARMA_INCFILE_WRAP(ARMA_CBLAS)
#include ARMA_INCFILE_WRAP(ARMA_CLAPACK) // This is line no 26
}
#undef ARMA_STR1
#undef ARMA_STR2
#undef ARMA_CBLAS
#undef ARMA_CLAPACK
#endif
#endif
If I replace ARMA_CLAPACK with "/usr/include/atlas/clapack.h", it still complains:
$ make
Scanning dependencies of target armadillo
[100%] Building CXX object CMakeFiles/armadillo.dir/src/wrapper.cpp.o
In file included from /home/dkumar/Downloads/armadillo-4.600.3/src/wrapper.cpp:10:0:
/home/dkumar/Downloads/armadillo-4.600.3/tmp/include/armadillo_bits/include_atlas.hpp:26:89: fatal error: "/usr/include/atlas/clapack.h": No such file or directory
#include ARMA_INCFILE_WRAP("/usr/include/atlas/clapack.h") // This is line no 26
^
compilation terminated.
make[2]: *** [CMakeFiles/armadillo.dir/src/wrapper.cpp.o] Error 1
make[1]: *** [CMakeFiles/armadillo.dir/all] Error 2
make: *** [all] Error 2
I was having same problem while running make after cmake . when I check the cmake output it was pointing to wrong atlas directory i.e. it was pointing to ATLAS_INCLUDE_DIR = /usr/include/ where as it should have been pointing to ATLAS_INCLUDE_DIR = /usr/include/atlas.
-- Found ATLAS: /usr/lib/libatlas.so
-- Found BLAS: /usr/lib/libblas.so
-- Found LAPACK: /usr/lib/liblapack.so
-- MKL_FOUND = NO
-- ACMLMP_FOUND = NO
-- ACML_FOUND = NO
-- OpenBLAS_FOUND = NO
-- ATLAS_FOUND = YES
-- BLAS_FOUND = YES
-- LAPACK_FOUND = YES
-- ATLAS_INCLUDE_DIR = /usr/include/
-- ARPACK_FOUND = NO
--
-- *** Armadillo wrapper library will use the following libraries:
-- *** ARMA_LIBS = /usr/lib/libatlas.so;/usr/lib/libblas.so;/usr/lib/liblapack.so
I correct this by adding correct path in CmakeCache.txt file. After that it make and make install run fine.
But I am having this error while running after compiling example using
g++ -O2 -o example1 example1.cpp -larmadillo
the error is
./example1: error while loading shared libraries: libarmadillo.so.4: cannot open shared object file: No such file or directory
Note: The above error can be solved by creating a symbolic link of libarmadillo.so and libarmadillo.so.4 in /usr/lib directory.
Related
This question already has answers here:
CMake link to external library
(6 answers)
Closed 2 years ago.
I have the following code that works perfectly with gcc by running the command:
gcc -L ~/Installed/C_LIBS/cmocka/lib -I ~/Installed/C_LIBS/cmocka/include hello.c -lcmocka -o hello
When I try to convert that to a CMakeLists.txt it breaks after running cd build && cmake .. && make with the following error codes:
Scanning dependencies of target hello
[ 50%] Building C object CMakeFiles/hello.dir/main.c.o
[100%] Linking C executable hello
ld: library not found for -lcmocka
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [hello] Error 1
make[1]: *** [CMakeFiles/hello.dir/all] Error 2
make: *** [all] Error 2
I have the code setup like this:
my-proj/
- CMakeLists.txt
- main.c
- build/
Here are my files:
main.c
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
/* A test case that does nothing and succeeds. */
static void null_test_success(void **state) {
(void) state; /* unused */
}
int main(void) {
const struct CMUnitTest tests[] = {
cmocka_unit_test(null_test_success),
};
return cmocka_run_group_tests(tests, NULL, NULL);
}
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.9)
project (hello)
include_directories(
SYSTEM ~/Installed/C_LIBS/cmocka/lib
SYSTEM ~/Installed/C_LIBS/cmocka/include
)
add_executable(hello main.c)
target_link_libraries(hello cmocka)
Can someone please tell me what I am doing wrong here? Also maybe point me in the direction of where to learn CMake better?
The include_directories() command only affects header search paths (stuff that is used through #include). It has no effect on library search paths.
Since you know the full path of the library, you should just be linking directly against said full path:
target_link_libraries(hello ~/Installed/C_LIBS/cmocka/lib/libcmocka.a)
However, this is just patching your CMakeLists.txt. What you should be doing is use CMake's library functions, which will be a lot more flexible:
# Include dir
find_path(MOCKA_INCLUDE_DIR
NAMES cmocka.h
PATHS ~/Installed/C_LIBS/cmocka/include
)
#library itself
find_library(MOCKA_LIBRARY
NAMES cmocka
PATHS ~/Installed/C_LIBS/cmocka/lib
)
target_include_directories(hello PRIVATE ${MOCKA_INCLUDE_DIR})
target_link_libraries(hello ${MOCKA_LIBRARY})
I am trying to use the libavformat from ffmpeg in a C++ project. I have ffmpeg installed using homebrew.
My CMakeLists.txt :
cmake_minimum_required(VERSION 3.14)
project(av_test)
set(CMAKE_CXX_STANDARD 11)
INCLUDE_DIRECTORIES(/usr/local/Cellar/ffmpeg/4.2.1_2/include)
LINK_DIRECTORIES(/usr/local/Cellar/ffmpeg/4.2.1_2/lib)
add_executable(av_test main.cpp)
TARGET_LINK_LIBRARIES(av_test libavformat)
When running cmake I get this error:
ld: library not found for -llibavformat
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [av_test] Error 1
make[2]: *** [CMakeFiles/av_test.dir/all] Error 2
make[1]: *** [CMakeFiles/av_test.dir/rule] Error 2
make: *** [av_test] Error 2
A quick find libavformat* into /usr/local/Cellar/ffmpeg/4.2.1_2/lib returns:
libavformat.58.29.100.dylib
libavformat.58.dylib
libavformat.a
libavformat.dylib
Also in /usr/local/Cellar/ffmpeg/4.2.1_2/include/libavformat there is avformat.h
My main.cpp:
#include <libavformat/avformat.h>
int main() {
AVFormatContext *pFormatContext;
return 0;
}
I am running on mac os 10.14 with cmake version 3.15.5 , ffmpeg version 4.2.1
The problem here is noted from the error:
ld: library not found for -llibavformat
As you can see, it has both '-l' and 'lib' as prefix even though '-l' should replace 'lib' before the library name. It seems the TARGET_LINK_LIBRARIES function parses library names with a prefix -l (or lib) automatically attached. So, you need to write either of the following:
TARGET_LINK_LIBRARIES(av_test avformat)
TARGET_LINK_LIBRARIES(av_test -lavformat)
Adding -l at start doesn't make a difference, but is still accepted by cmake.
Ive downloaded the SDL2 library using brew install SDL2 but when I am trying to compile melonDS for Mac, I keep banging my head against the wall of the annoying error of
bash-3.2$ make
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/bigman/melonDS/build
[ 1%] Building CXX object CMakeFiles/melonDS.dir/src/libui_sdl/main.cpp.o
/Users/bigman/melonDS/src/libui_sdl/main.cpp:24:10: fatal error:
'SDL2/SDL.h' file not found
#include <SDL2/SDL.h>
^~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/melonDS.dir/src/libui_sdl/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/melonDS.dir/all] Error 2
make: *** [all] Error 2
bash-3.2$
I've uninstalled, reinstalled, tried to use compiler flags in the makefile (which did't work because the project uses cmake) but to no avail. Any other reccomendations would be great.
I'm trying to make Boost libs to work with Eclipse Luna (I know it's an old version but I'm tied to work with it).
My system is a Linux Mint 18.1.
I downloaded, unpacked and installed the libraries following this guide.
I ended up with unpacked libraries in my home folder and compiled ones in usr/local/include/boost folder.
Next I added the latter to the LD LIBRARY PATH and resetted the ldconfig.
At this point I copied some code on an empty C++ project.
The header I'm using is "share_ptr.hpp" so I set the #include .
After that I added the include path to the included headers under Project -> Properties -> C/C++ General -> Paths and Symbols.
I added the path /usr/local/include as included directory.
When I build I get the error: "No such file or directory".
If I #include the header with the absolute path, I can find the file but I get another error cause this .hpp file has references to the "relative" path /boost/smart_ptr/share_ptr, so it doesn't find all those headers:
#ifndef BOOST_SMART_PTR_HPP_INCLUDED
#define BOOST_SMART_PTR_HPP_INCLUDED
#include <boost/config.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/scoped_array.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/shared_array.hpp>
#if !defined(BOOST_NO_MEMBER_TEMPLATES) || defined(BOOST_MSVC6_MEMBER_TEMPLATES)
# include <boost/weak_ptr.hpp>
# include <boost/intrusive_ptr.hpp>
# include <boost/enable_shared_from_this.hpp>
# include <boost/make_shared.hpp>
#endif
#endif // #ifndef BOOST_SMART_PTR_HPP_INCLUDED
Looks like to me that Eclipse can't get the include path correctly.
Another thing that I tried was adding the -L for the linker, but it doesn't work either.
This is what I'm including:
#include <vector>
#include <boost/shared_ptr.hpp>
Could you help me to understand what it's going on ?
Adding informations:
CODE:
#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>
int main()
{
using namespace boost::lambda;
typedef std::istream_iterator<int> in;
std::for_each(
in(std::cin), in(), std::cout << (_1 * 3) << " " );
}
CONSOLE:
08:13:11 **** Incremental Build of configuration Build (GNU) for project TESTCODE ****
make all
make all-recursive
make[1]: Entering directory '/home/daniele/workspace/TESTCODE'
Making all in src
make[2]: Entering directory '/home/daniele/workspace/TESTCODE/src'
arm-poky-linux-gnueabi-g++ -march=armv7ve -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/opt/fsl-imx-fb/4.1.15-2.0.1/sysroots/cortexa7hf-neon-poky-linux-gnueabi -DHAVE_CONFIG_H -I. -I.. --sysroot=/opt/fsl-imx-fb/4.1.15-2.0.1/sysroots/cortexa7hf-neon-poky-linux-gnueabi -g -O0 --sysroot=/opt/fsl-imx-fb/4.1.15-2.0.1/sysroots/cortexa7hf-neon-poky-linux-gnueabi -MT TESTCODE.o -MD -MP -MF .deps/TESTCODE.Tpo -c -o TESTCODE.o TESTCODE.cpp
TESTCODE.cpp:11:35: fatal error: boost/lambda/lambda.hpp: No such file or directory
compilation terminated.
make[2]: *** [TESTCODE.o] Error 1
Makefile:398: recipe for target 'TESTCODE.o' failed
make[1]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/daniele/workspace/TESTCODE/src'
make: *** [all] Error 2
Makefile:403: recipe for target 'all-recursive' failed
make[1]: Leaving directory '/home/daniele/workspace/TESTCODE'
Makefile:335: recipe for target 'all' failed
08:13:11 Build Finished (took 84ms)
ERRORS:
Description Resource Path Location Type fatal error:
boost/lambda/lambda.hpp: No such file or
directory TESTCODE.cpp /TESTCODE/src line 11 C/C++ Problem make: *
[all] Error 2 TESTCODE C/C++ Problem make1: * [all-recursive]
Error 1 TESTCODE C/C++ Problem make[2]: *** [TESTCODE.o] Error
1 TESTCODE C/C++ Problem recipe for target 'all-recursive'
failed Makefile /TESTCODE line 403 C/C++ Problem recipe for target
'all' failed Makefile /TESTCODE line 335 C/C++ Problem recipe for
target 'TESTCODE.o' failed Makefile /TESTCODE line 398 C/C++ Problem
I have problem building Port Audio on windows machine. I am following this tutorial: http://portaudio.com/docs/v19-doxydocs/compile_windows_mingw.html
Running make after ./configure runs build process and finally outputs this message and that is where build process stop.
/bin/sh ./libtool --mode=link gcc -shared -rpath /usr/local/lib -no-undefined -
export-symbols-regex "(Pa|PaMacCore|PaJack|PaAlsa|PaAsio|PaOSS)_.*" -version-inf
o 2:0:0 -o lib/libportaudio.la src/common/pa_allocation.lo src/common/pa_convert
ers.lo src/common/pa_cpuload.lo src/common/pa_dither.lo src/common/pa_debugprint
.lo src/common/pa_front.lo src/common/pa_process.lo src/common/pa_stream.lo src/
common/pa_trace.lo src/hostapi/skeleton/pa_hostapi_skeleton.lo src/hostapi/wmme/
pa_win_wmme.lo src/os/win/pa_win_hostapis.lo src/os/win/pa_win_util.lo src/os/wi
n/pa_win_waveformat.lo -lwinmm
*** Warning: linker path does not have real file for library -lwinmm.
*** I have the capability to make that library automatically link in when
*** you link to this library. But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libwinmm but no candidates were found. (...for file magic test)
*** The inter-library dependencies that have been dropped here will be
*** automatically added whenever a program is linked with this library
*** or is declared to -dlopen it.
*** Since this library must not contain undefined symbols,
*** because either the platform does not support them or
*** it was explicitly requested with -no-undefined,
*** libtool will only create a static version of it.
libtool: link: lib -OUT:lib/.libs/libportaudio.lib src/common/pa_allocation.o s
rc/common/pa_converters.o src/common/pa_cpuload.o src/common/pa_dither.o src/com
mon/pa_debugprint.o src/common/pa_front.o src/common/pa_process.o src/common/pa_
stream.o src/common/pa_trace.o src/hostapi/skeleton/pa_hostapi_skeleton.o src/ho
stapi/wmme/pa_win_wmme.o src/os/win/pa_win_hostapis.o src/os/win/pa_win_util.o s
rc/os/win/pa_win_waveformat.o
./libtool: line 1115: lib: command not found
make: *** [lib/libportaudio.la] Error 127
I am newbie in building libraries so i dont understand what is wrong here.
Any help is appreciated.