undefined reference to boost::filesystem::path_traits::dispatch - c++

I wrote a simple program using boost filesystem library. I linked to libboost_filesystem but yet I get undefined reference linkage error.
Here is my CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project(client)
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11")
add_executable(client main.cpp UploadWorker.cpp FileSystemWatcher.cpp)
target_link_libraries(client boost_filesystem boost_system pthread)
I tried all of the solutions in other topics, but none of them was helpful.
and here is my error:
-- The C compiler identification is GNU 5.4.1
-- The CXX compiler identification is GNU 4.9.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/saeed/projects/threads/Debug
Scanning dependencies of target client
Scanning dependencies of target server
[ 50%] Building CXX object server/CMakeFiles/server.dir/main.cpp.o
[ 50%] Building CXX object client/CMakeFiles/client.dir/main.cpp.o
[ 50%] Building CXX object client/CMakeFiles/client.dir/UploadWorker.cpp.o
[ 66%] Building CXX object client/CMakeFiles/client.dir/FileSystemWatcher.cpp.o
[ 83%] Linking CXX executable server
[ 83%] Built target server
[100%] Linking CXX executable client
CMakeFiles/client.dir/FileSystemWatcher.cpp.o: In function `boost::filesystem::path::path<boost::filesystem::directory_entry>(boost::filesystem::directory_entry const&, boost::enable_if<boost::filesystem::path_traits::is_pathable<boost::decay<boost::filesystem::directory_entry>::type>, void>::type*)':
/usr/include/boost/filesystem/path.hpp:140: undefined reference to `boost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry const&, std::string&)'
collect2: error: ld returned 1 exit status
client/CMakeFiles/client.dir/build.make:146: recipe for target 'client/client' failed
make[2]: *** [client/client] Error 1
CMakeFiles/Makefile2:85: recipe for target 'client/CMakeFiles/client.dir/all' failed
make[1]: *** [client/CMakeFiles/client.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
My machine is Ubuntu 16.04, g++ v4.9.4 and boost v1.58.

Related

c++17 parallel algorithms and CMake on ubuntu 20.04

I had installed gcc-11/g++-11 and tbb
$ dpkg -l | grep tbb
ii libtbb-dev:amd64 2020.1-2 amd64 parallelism library for C++ - development files
ii libtbb2:amd64 2020.1-2 amd64 parallelism library for C++ - runtime files
$ dpkg -l | grep gcc-11
ii gcc-11 11.1.0-1ubuntu1~20.04 amd64 GNU C compiler
ii gcc-11-base:amd64 11.1.0-1ubuntu1~20.04 amd64 GCC, the GNU Compiler Collection (base package)
ii libgcc-11-dev:amd64 11.1.0-1ubuntu1~20.04 amd64 GCC support library (development files)
$ dpkg -l | grep g++-11
ii g++-11 11.1.0-1ubuntu1~20.04 amd64 GNU C++ compiler
then, I wrote cmake like below
https://github.com/yumetodo/SigContrastFastAviUtl/blob/master/test/CMakeLists.txt
...
find_package(TBB REQUIRED tbb)
...
target_link_libraries(SigContrastFastAviUtl_test ${TBB_IMPORTED_TARGETS})
...
However, it's seemed me that find_package doesn't work and link error was occurred.
$ cmake -B build -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_C_COMPILER=gcc-11
-- Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_CXX_COMPILER= g++-11
CMAKE_C_COMPILER= gcc-11
CMAKE_CXX_COMPILER= g++-11
-- The CXX compiler identification is GNU 11.1.0
-- Check for working CXX compiler: /usr/bin/g++-11
-- Check for working CXX compiler: /usr/bin/g++-11 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- The C compiler identification is GNU 11.1.0
-- Check for working C compiler: /usr/bin/gcc-11
-- Check for working C compiler: /usr/bin/gcc-11 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/yumetodo/SigContrastFastAviUtl/test/build
$ cmake --build build/
Scanning dependencies of target SigContrastFastAviUtl_test
[ 16%] Building CXX object CMakeFiles/SigContrastFastAviUtl_test.dir/LUT.cpp.o
[ 33%] Building CXX object CMakeFiles/SigContrastFastAviUtl_test.dir/random.cpp.o
[ 50%] Building CXX object CMakeFiles/SigContrastFastAviUtl_test.dir/RSigmoidTable.cpp.o
[ 66%] Building CXX object CMakeFiles/SigContrastFastAviUtl_test.dir/SigmoidTable.cpp.o
[ 83%] Building CXX object CMakeFiles/SigContrastFastAviUtl_test.dir/test.cpp.o
/home/yumetodo/SigContrastFastAviUtl/test/test.cpp: In member function ‘virtual void iu_Analyzer_x_iutest_x_calcAverage_Test::Body()’:
/home/yumetodo/SigContrastFastAviUtl/test/test.cpp:114:19: warning: unused variable ‘_’ [-Wunused-variable]
114 | for (auto _ : std::views::iota(0, 1000)) input.emplace_back(d(engine));
| ^
/home/yumetodo/SigContrastFastAviUtl/test/test.cpp: In member function ‘virtual void iu_Analyzer_x_iutest_x_calcStdev_Test::Body()’:
/home/yumetodo/SigContrastFastAviUtl/test/test.cpp:124:19: warning: unused variable ‘_’ [-Wunused-variable]
124 | for (auto _ : std::views::iota(0, 1000)) input.emplace_back(d(engine));
| ^
[100%] Linking CXX executable SigContrastFastAviUtl_test
/usr/bin/ld: CMakeFiles/SigContrastFastAviUtl_test.dir/test.cpp.o: in function `tbb::task_group_context::task_group_context(tbb::internal::string_index)':
test.cpp:(.text._ZN3tbb18task_group_contextC2ENS_8internal12string_indexE[_ZN3tbb18task_group_contextC5ENS_8internal12string_indexE]+0x41): undefined reference to `tbb::task_group_context::init()'
/usr/bin/ld: CMakeFiles/SigContrastFastAviUtl_test.dir/test.cpp.o: in function `tbb::task::task()':
test.cpp:(.text._ZN3tbb4taskC2Ev[_ZN3tbb4taskC5Ev]+0x13): undefined reference to `vtable for tbb::task'
/usr/bin/ld: CMakeFiles/SigContrastFastAviUtl_test.dir/test.cpp.o: in function `tbb::task::~task()':
.
.
.
(full log is here)
I watched below but not resolved.
c++17 parallel algorithms and CMake
https://github.com/oneapi-src/oneTBB/blob/tbb_2020/cmake/README.rst#binary-package-integration
How should I do?
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 46dcc93..8b662dc 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
## -60,6 +60,7 ## if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUC)
if(WIN32)
target_link_libraries(SigContrastFastAviUtl_test wsock32 ws2_32)
endif()
- target_link_libraries(SigContrastFastAviUtl_test ${TBB_IMPORTED_TARGETS})
+ #target_link_libraries(SigContrastFastAviUtl_test ${TBB_IMPORTED_TARGETS})
+ target_link_libraries(SigContrastFastAviUtl_test TBB::tbb)
endif()
target_link_libraries(SigContrastFastAviUtl_test Threads::Threads)
-- Configuring done
CMake Error at CMakeLists.txt:58 (add_executable):
Target "SigContrastFastAviUtl_test" links to target "TBB::tbb" but the
target was not found. Perhaps a find_package() call is missing for an
IMPORTED target, or an ALIAS target is missing?
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
make: *** [Makefile:296: cmake_check_build_system] Error 1

Build using cmake a g++ command with -I,-L and -l

This is the program I want to run, main.cpp:
#include <iostream>
#include "yaracpp/yaracpp.h"
int main() {
yaracpp::YaraDetector yara;
yara.addRules(R"(
rule example {
strings:
$s = "Hello"
condition:
$s
})");
if (yara.analyze("test_file")) {
for (const auto& rule : yara.getDetectedRules()) {
std::cout << rule << '\n';
}
}
}
When I run this command on the terminal it compiles successfully:
g++ -Iinclude -Ibuild/deps/yara/src/yara/libyara/include/ -Lbuild/src/ -Lbuild/deps/yara/src/yara/libyara/.libs/ main.cpp -lyaracpp -lyara -lpthread -lssl -lcrypto
My CMakeLists.txt is:
cmake_minimum_required(VERSION 3.6)
project(main CXX C)
add_executable(main main.cpp)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Iinclude -Ibuild/deps/yara/src/yara/libyara/include -Lbuild/src -Lbuild/deps/yara/src/yara/libyara/.libs/")
target_link_libraries (main yaracpp yara pthread ssl crypto)
This happens when I try to build it:
cmake .
-- The CXX compiler identification is GNU 7.4.0
-- The C compiler identification is GNU 7.4.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mevasu/yaracpp
make
[ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o
/home/mevasu/yaracpp/main.cpp:2:10: fatal error: yaracpp/yaracpp.h: No such file or directory
#include "yaracpp/yaracpp.h"
^~~~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/main.dir/build.make:62: recipe for target 'CMakeFiles/main.dir/main.cpp.o' failed
make[2]: *** [CMakeFiles/main.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/main.dir/all' failed
make[1]: *** [CMakeFiles/main.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Looking at the output, there is the following line:
c++: error: yaracpp/main.cpp: No such file or directory
Does the file exist? Looking at your CMakeLists.txt, the file appears in the following command:
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} [..] yaracpp/main.cpp ")
^^^^^^^^^^^^^^^^
Why do you add yaracpp/main.cpp into CMAKE_CXX_FLAGS when it (apparently) has already been added in the following line?
add_executable(main main.cpp)
^^^^^^^^
I highly suggest learning the basics of CMake before continuing in your endeavors.

make openmp g++-6.2.0 no such file [duplicate]

This question already has an answer here:
CMake - set_property could not find CACHE variable
(1 answer)
Closed 6 years ago.
cmakelist.txt
cmake_minimum_required(VERSION 3.7)
project(multithreading)
# Find ITK.
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})
FIND_PACKAGE( OpenMP REQUIRED)
if(OPENMP_FOUND)
message("OPENMP FOUND")
set(CMAKE_C_FLAGS “${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}”)
set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}“)
set(CMAKE_EXE_LINKER_FLAGS “${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}”)
endif()
add_executable(multithreading multithreading.cpp )
target_link_libraries(multithreading ${ITK_LIBRARIES})
TARGET_LINK_LIBRARIES(multithreading ${OpenMP_CXX_LIBRARIES})
And then I change default compiler which is AppleClang to gcc-6.2.0, and then cmake
,all openmp flags find, and configure is fine.
cmake -DCMAKE_C_COMPILER=/usr/local/gcc-6.2.0/bin/gcc-6.2.0 -DCMAKE_CXX_COMPILER=/usr/local/gcc-6.2.0/bin/g++-6.2.0 ./
-- The C compiler identification is GNU 6.2.0
-- The CXX compiler identification is GNU 6.2.0
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Check for working C compiler: /usr/local/gcc-6.2.0/bin/gcc-6.2.0
-- Check for working C compiler: /usr/local/gcc-6.2.0/bin/gcc-6.2.0 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /usr/local/gcc-6.2.0/bin/g++-6.2.0
-- Check for working CXX compiler: /usr/local/gcc-6.2.0/bin/g++-6.2.0 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Try OpenMP C flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
-- Try OpenMP CXX flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
-- Found OpenMP: -fopenmp
OPENMP FOUND
-- Configuring done
-- Generating done
then next when I do ‘make’ it shows me
canning dependencies of target multithreading
[ 50%] Building CXX object CMakeFiles/multithreading.dir/multithreading.cpp.o
g++-6.2.0: error: “: No such file or directory
g++-6.2.0: fatal error: no input files
compilation terminated.
/bin/sh: -fopenmp“: command not found
make[2]: *** [CMakeFiles/multithreading.dir/multithreading.cpp.o] Error 127
make[1]: *** [CMakeFiles/multithreading.dir/all] Error 2
make: *** [all] Error 2
If I do g++ -fopenmp myproject.cpp it will not link ITK Library
g++ -fopenmp multithreading.cpp
multithreading.cpp:4:44: fatal error: itkRescaleIntensityImageFilter.h: No such file or directory
#include "itkRescaleIntensityImageFilter.h"
^
compilation terminated.
So I am wondering how can I fix that issue, so use itk and openmp as library at the same time.
You're using language/locale-specific double quotes. Most programming languages don't support these, including CMake. Use the "normal" double quotes: "

SDL project CMake build failure

I try to set up an SDL project using CMake, but it seems like the executable isn't linked properly.
This is the CMakeLists.txt I use
cmake_minimum_required(VERSION 3.0)
project(MuspellsheimR)
# includes cmake/FindSDL2.cmake
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)
# find SDL2
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIR})
set(SOURCE_FILES src/main.cpp)
add_executable(MuspellsheimR ${SOURCE_FILES})
target_link_libraries(MuspellsheimR ${SDL_LIBRARY})
src/main.cpp looks like this:
#include <iostream>
#include <SDL.h>
int main(int, char**){
if (SDL_Init(SDL_INIT_VIDEO) != 0){
std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl;
return 1;
}
SDL_Quit();
return 0;
}
Here is the log output.
[omtcyf0#localhost MuspellsheimR_Build]$ cmake -G "Unix Makefiles" ../MuspellsheimR
-- The C compiler identification is GNU 5.1.1
-- The CXX compiler identification is GNU 5.1.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found SDL2: /usr/local/lib/libSDL2main.a;/usr/local/lib/libSDL2.so;-lpthread
-- Configuring done
-- Generating done
-- Build files have been written to: /home/omtcyf0/Desktop/MuspellsheimR_Build
[omtcyf0#localhost MuspellsheimR_Build]$
[omtcyf0#localhost MuspellsheimR_Build]$ ls
CMakeCache.txt CMakeFiles cmake_install.cmake Makefile
[omtcyf0#localhost MuspellsheimR_Build]$ make
Scanning dependencies of target MuspellsheimR
[100%] Building CXX object CMakeFiles/MuspellsheimR.dir/src/main.cpp.o
Linking CXX executable MuspellsheimR
CMakeFiles/MuspellsheimR.dir/src/main.cpp.o: In function `main':
main.cpp:(.text+0x25): undefined reference to `SDL_Init'
main.cpp:(.text+0x3e): undefined reference to `SDL_SetVideoMode'
main.cpp:(.text+0x51): undefined reference to `SDL_RWFromFile'
main.cpp:(.text+0x5e): undefined reference to `SDL_LoadBMP_RW'
main.cpp:(.text+0x7c): undefined reference to `SDL_UpperBlit'
main.cpp:(.text+0x88): undefined reference to `SDL_Flip'
main.cpp:(.text+0x92): undefined reference to `SDL_Delay'
main.cpp:(.text+0x9e): undefined reference to `SDL_FreeSurface'
main.cpp:(.text+0xa3): undefined reference to `SDL_Quit'
collect2: error: ld returned 1 exit status
CMakeFiles/MuspellsheimR.dir/build.make:85: recipe for target 'MuspellsheimR' failed
make[2]: *** [MuspellsheimR] Error 1
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/MuspellsheimR.dir/all' failed
make[1]: *** [CMakeFiles/MuspellsheimR.dir/all] Error 2
Makefile:116: recipe for target 'all' failed
make: *** [all] Error 2
What am I doing wrong?
SDL_LIBRARY is the wrong variable. You need to use SDL2_LIBRARY.

Linking error of BLAS with CMake

I have the following CMakeLists.txt:
cmake_minimum_required (VERSION 2.6)
project (MTSOS)
# Select flags.
set(CMAKE_C_FLAGS "-std=c99")
# Blas library
find_package( BLAS REQUIRED )
include_directories(${BLAS_INCLUDE_DIR})
add_executable (test_MTSOS test_MTSOS.c barrier_front.c dynamics_front.c
MTSOS.c csparse.c)
# Linking CImg dependencies.
target_link_libraries (test_MTSOS m blas ${BLAS_LIBRARIES})
When I run cmake .. :
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for dgemm_
-- Looking for dgemm_ - found
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- A library with BLAS API found.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/jabuntu14/Desktop/MTSOS/build
However, when I try to compile with make:
Scanning dependencies of target test_MTSOS
[ 20%] Building C object CMakeFiles/test_MTSOS.dir/test_MTSOS.c.o
[ 40%] Building C object CMakeFiles/test_MTSOS.dir/barrier_front.c.o
/home/jabuntu14/Desktop/MTSOS/barrier_front.c: In function ‘so_barrier’:
/home/jabuntu14/Desktop/MTSOS/barrier_front.c:83:25: warning: implicit declaration of function ‘dsyr’ [-Wimplicit-function-declaration]
dsyr(uplo, &u_size, &alpha, &Df[i*U_size], &one, A, &u_size);
^
[ 60%] Building C object CMakeFiles/test_MTSOS.dir/dynamics_front.c.o
[ 80%] Building C object CMakeFiles/test_MTSOS.dir/MTSOS.c.o
/home/jabuntu14/Desktop/MTSOS/MTSOS.c: In function ‘so_MakeA’:
/home/jabuntu14/Desktop/MTSOS/MTSOS.c:1561:13: warning: implicit declaration of function ‘dgemv’ [-Wimplicit-function-declaration]
dgemv(chn, &m_m, &n_m, &one, &M_dynamics[i*State_size*State_size], &m_m, &S_prime[i*State_size], &p_m, &zero, datam, &p_m);
^
[100%] Building C object CMakeFiles/test_MTSOS.dir/csparse.c.o
Linking C executable test_MTSOS
CMakeFiles/test_MTSOS.dir/barrier_front.c.o: In function `so_barrier':
barrier_front.c:(.text+0x4a7): undefined reference to `dsyr'
CMakeFiles/test_MTSOS.dir/MTSOS.c.o: In function `so_MakeA':
MTSOS.c:(.text+0x5e41): undefined reference to `dgemv'
MTSOS.c:(.text+0x5ee4): undefined reference to `dgemv'
MTSOS.c:(.text+0x5f87): undefined reference to `dgemv'
collect2: error: ld returned 1 exit status
make[2]: *** [test_MTSOS] Error 1
make[1]: *** [CMakeFiles/test_MTSOS.dir/all] Error 2
make: *** [all] Error 2
So I am having a linking problem but I cannot figure out why. Any help is welcome. Thanks!!
NOTE: Working under Ubuntu 14.04 with GCC. In the .c files I have included #include "cblas.h" as I saw in other websites.
EDIT: running make VERBOSE=1 the output is:
jabuntu14#ubuntu:~/Desktop/MTSOS/build$ make VERBOSE=1
/usr/bin/cmake -H/home/jabuntu14/Desktop/MTSOS -B/home/jabuntu14/Desktop/MTSOS/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/jabuntu14/Desktop/MTSOS/build/CMakeFiles /home/jabuntu14/Desktop/MTSOS/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/jabuntu14/Desktop/MTSOS/build'
make -f CMakeFiles/test_MTSOS.dir/build.make CMakeFiles/test_MTSOS.dir/depend
make[2]: Entering directory `/home/jabuntu14/Desktop/MTSOS/build'
cd /home/jabuntu14/Desktop/MTSOS/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/jabuntu14/Desktop/MTSOS /home/jabuntu14/Desktop/MTSOS /home/jabuntu14/Desktop/MTSOS/build /home/jabuntu14/Desktop/MTSOS/build /home/jabuntu14/Desktop/MTSOS/build/CMakeFiles/test_MTSOS.dir/DependInfo.cmake --color=
make[2]: Leaving directory `/home/jabuntu14/Desktop/MTSOS/build'
make -f CMakeFiles/test_MTSOS.dir/build.make CMakeFiles/test_MTSOS.dir/build
make[2]: Entering directory `/home/jabuntu14/Desktop/MTSOS/build'
Linking C executable test_MTSOS
/usr/bin/cmake -E cmake_link_script CMakeFiles/test_MTSOS.dir/link.txt --verbose=1
/usr/bin/cc -std=c99 CMakeFiles/test_MTSOS.dir/test_MTSOS.c.o CMakeFiles/test_MTSOS.dir/barrier_front.c.o CMakeFiles/test_MTSOS.dir/dynamics_front.c.o CMakeFiles/test_MTSOS.dir/MTSOS.c.o CMakeFiles/test_MTSOS.dir/csparse.c.o -o test_MTSOS -rdynamic -lm -lblas -lf77blas -latlas
CMakeFiles/test_MTSOS.dir/barrier_front.c.o: In function `so_barrier':
barrier_front.c:(.text+0x4a7): undefined reference to `dsyr'
CMakeFiles/test_MTSOS.dir/MTSOS.c.o: In function `so_MakeA':
MTSOS.c:(.text+0x5e41): undefined reference to `dgemv'
MTSOS.c:(.text+0x5ee4): undefined reference to `dgemv'
MTSOS.c:(.text+0x5f87): undefined reference to `dgemv'
collect2: error: ld returned 1 exit status
make[2]: *** [test_MTSOS] Error 1
make[2]: Leaving directory `/home/jabuntu14/Desktop/MTSOS/build'
make[1]: *** [CMakeFiles/test_MTSOS.dir/all] Error 2
make[1]: Leaving directory `/home/jabuntu14/Desktop/MTSOS/build'
make: *** [all] Error 2
The functions in standard blas libraries are
dgemv_
Instead of
dgemv
As shown in your error, notice the trailing underscore.
So you probably have something in your code calling dgemv() instead of dgemv_(), change that and then you should be fine.
(I had the same issue where the code I was using had some like #define dgemv_ dgemv)