I want to know this cause and solution - c++

[ 6%] Built target ChainedLib
[ 12%] Built target ChainedApp
[ 15%] Linking CXX executable ColorConsole
/usr/bin/ld: cannot open output file ColorConsole: Is a directory
collect2: error: ld returned 1 exit status
make[2]: *** [ColorConsole] 오류 1
make[1]: *** [CMakeFiles/ColorConsole.dir/all] 오류 2
make: *** [all] 오류 2
I install plog library.
cmake CMakeList.txt complete. but, makefile is fail
I don't know cause

You have a directory called ColorConsole. The makefile tries to produce a file with that name. The solution is most likely to remove (or rename) the directory.

Related

Using OPCUA Library in a New Cmake Project

In this time, I want to use Freeopcua to create a library to use in other project.
I have install all the tools in debian.soft file and build with following command sudo sh build.sh, cmake ., make, sudo make install. Although, in directory /usr/local/include and /usr/local/lib, there are opc directory and libopc*.so respectively, when I create a new cmake project, there is an error. Hope someone can help me or give some suggest. Thanks everyone~~~
I have refer to Libraries in /usr/local/lib not found, but it doesn't work for me
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.12)
project(OPCUAIndependent)
include_directories(/usr/local/include/)
link_directories(/usr/local/lib/)
add_executable(sourceCode sourceCode.cpp)
target_link_libraries(sourceCode opc)
Error
[ 50%] Linking CXX executable sourceCode
/usr/bin/ld: cannot find -lopc
collect2: error: ld returned 1 exit status
CMakeFiles/sourceCode.dir/build.make:96: recipe for target 'sourceCode' failed
make[2]: *** [sourceCode] Error 1
CMakeFiles/Makefile2:82: recipe for target 'CMakeFiles/sourceCode.dir/all' failed
make[1]: *** [CMakeFiles/sourceCode.dir/all] Error 2
Makefile:90: recipe for target 'all' failed
make: *** [all] Error 2

Error while generating the run-time armadillo library on ubuntu16.04

According to the Linux and macOS: Installation guide for Armadillo, on Debian machine(ubuntu-16.04) I was trying for installing the armadillo library and after executing the command : $cmake .
The full stop separated from "cmake" by a space is important.
I executed the command : $ make (also tried with root privileges still), the following error was thrown.
piyush#ubuntu:~/armadillo$ sudo make
Scanning dependencies of target armadillo
[ 33%] Building CXX object CMakeFiles/armadillo.dir/src/wrapper1.cpp.o
[ 66%] Building CXX object CMakeFiles/armadillo.dir/src/wrapper2.cpp.o
[100%] Linking CXX shared library libarmadillo.so
/usr/bin/ld: /usr/local/lib/libsuperlu.a(util.c.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libsuperlu.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
CMakeFiles/armadillo.dir/build.make:123: recipe for target 'libarmadillo.so.9.800.2' failed
make[2]: *** [libarmadillo.so.9.800.2] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/armadillo.dir/all' failed
make[1]: *** [CMakeFiles/armadillo.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
This library is available in Ubuntu. Just do
sudo apt install libarmadillo-dev
P.S. Never run sudo make, it's a very bad practice.

undefined reference to `omp_get_wtime'

i learn c++, OpenMP. I have tried compile my program with omp_get_wtime and it doesn't work, but when i deleted this, it works. i must add something, but what and where. In openmptryflags or Cmakelists?
snap/clion/61/bin/cmake/linux/bin/cmake --build /home/bapah/CLionProjects/omp1/cmake-build-debug --target omp1 -- -j 6
[ 50%] Linking CXX executable omp1
CMakeFiles/omp1.dir/main.cpp.o: In function `main':
/home/bapah/CLionProjects/omp1/main.cpp:36: undefined reference to `omp_get_wtime'
collect2: error: ld returned 1 exit status
CMakeFiles/omp1.dir/build.make:83: recipe for target 'omp1' failed
make[3]: *** [omp1] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/omp1.dir/all' failed
make[2]: *** [CMakeFiles/omp1.dir/all] Error 2
CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/omp1.dir/rule' failed
make[1]: *** [CMakeFiles/omp1.dir/rule] Error 2
Makefile:118: recipe for target 'omp1' failed
make: *** [omp1] Error 2
Solution :
add to CMakeList.txt
SET_TARGET_PROPERTIES(omp1 PROPERTIES COMPILE_FLAGS "-fopenmp"
LINK_FLAGS "-fopenmp")
P.s. omp1 - name your project.
P.p.s. also you can write target_link_libraries(omp1 -fopenmp)

Building Google glog with CMake on Windows (failed)

I need the glog library (https://github.com/google/glog) for a C++ project (Windows 10, Qt 5.10) and try to build it from sources using CMake. The CMake configuration process was succesful, the path to gflags is also set correctly.
After configurating glog with CMake, I tried to compile it with MinGW (command mingw32-make in the build folder). After 64%, the building process stopped with an error:
[ 64%] Linking CXX executable utilities_unittest.exe
libglog.a(symbolize.cc.obj):symbolize.cc:(.text+0x15f): undefined reference to `_imp__SymFromAddr#20'
libglog.a(symbolize.cc.obj):symbolize.cc:(.text$_ZN6google14SymInitializerC1Ev[__ZN6google14SymInitializerC1Ev]+0x2f): undefined reference to `_imp__SymSetOptions#4'
libglog.a(symbolize.cc.obj):symbolize.cc:(.text$_ZN6google14SymInitializerC1Ev[__ZN6google14SymInitializerC1Ev]+0x51): undefined reference to `_imp__SymInitialize#12'
libglog.a(symbolize.cc.obj):symbolize.cc:(.text$_ZN6google14SymInitializerD1Ev[__ZN6google14SymInitializerD1Ev]+0x12): undefined reference to `_imp__SymCleanup#4' libglog.a(demangle.cc.obj):demangle.cc:(.text+0x9e): undefined reference to `_imp__UnDecorateSymbolName#16'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\utilities_unittest.dir\build.make:98: recipe for target 'utilities_unittest.exe' failed
mingw32-make[2]: *** [utilities_unittest.exe] Error 1
CMakeFiles\Makefile2:482: recipe for target 'CMakeFiles/utilities_unittest.dir/all' failed
mingw32-make[1]:
*** [CMakeFiles/utilities_unittest.dir/all] Error 2
Makefile:159: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
Do you have any idea how to fix it?
I already tried to enable the
CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
option, but this did not solve the problem.
Thank you for your help!

How to run googletest in CLion?

I want to use Googletest in my CLion Project.
So here is what I did:
I copied my googletest folder into the lib folder of my project.
I changed my CMakeLists.txt files like described in that Video: https://youtu.be/8Up5eNZ0FLw
and created that simple test:
#include "gtest/gtest.h"
TEST(basic_check, test_eq){
EXPECT_EQ(1,0);
}
I tried to run the test by pressing Shift + Ctrl + F10 and I got the following error:
"F:\Programs\CLion 2016.3\bin\cmake\bin\cmake.exe" --build C:\Users\Christian\ClionProjects\Geldautomat\cmake-build-debug --target runBasicTests -- -j 4
[ 16%] Building CXX object Tests/lib/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.obj
In file included from C:/Users/Christian/ClionProjects/Geldautomat/Tests/lib/googletest/include/gtest/internal/gtest-internal.h:40:0,
from C:/Users/Christian/ClionProjects/Geldautomat/Tests/lib/googletest/include/gtest/gtest.h:58,
from C:\Users\Christian\ClionProjects\Geldautomat\Tests\lib\googletest\src\gtest-all.cc:39:
C:/Users/Christian/ClionProjects/Geldautomat/Tests/lib/googletest/include/gtest/internal/gtest-port.h: In function 'int testing::internal::posix::StrCaseCmp(const char*, const char*)':
C:/Users/Christian/ClionProjects/Geldautomat/Tests/lib/googletest/include/gtest/internal/gtest-port.h:2328:25: error: '_stricmp' was not declared in this scope
return _stricmp(s1, s2);
^
mingw32-make.exe[3]: *** [Tests/lib/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.obj] Error 1
mingw32-make.exe[2]: *** [Tests/lib/googletest/CMakeFiles/gtest.dir/all] Error 2
mingw32-make.exe[1]: *** [Tests/basic_tests/CMakeFiles/runBasicTests.dir/rule] Error 2
mingw32-make.exe: *** [runBasicTests] Error 2
Tests\lib\googletest\CMakeFiles\gtest.dir\build.make:62: recipe for target 'Tests/lib/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.obj' failed
CMakeFiles\Makefile2:162: recipe for target 'Tests/lib/googletest/CMakeFiles/gtest.dir/all' failed
CMakeFiles\Makefile2:267: recipe for target 'Tests/basic_tests/CMakeFiles/runBasicTests.dir/rule' failed
Makefile:200: recipe for target 'runBasicTests' failed
My CMakeLists.txt in this directory is:
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
add_executable(runBasicTests
basic_check.cpp)
target_link_libraries(runBasicTests gtest gtest_main)
target_link_libraries(runBasicTests src)
Where my Source Code can be found in directory src.
My main.cpp is in the root directory and my Basic Test is in Tests/basic_tests
Tried the same on my Linux Notebook with CLion. Got the Error:
/home/christian/Downloads/clion-2016.3/bin/cmake/bin/cmake --build /home/christian/ClionProjects/Geldautomat/cmake-build-debug --target runBasicTests -- -j 4
Scanning dependencies of target gtest
[ 16%] Building CXX object Tests/lib/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
[ 33%] Linking CXX static library libgtest.a
[ 33%] Built target gtest
Scanning dependencies of target gtest_main
[ 50%] Building CXX object Tests/lib/googletest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.o
[ 66%] Linking CXX static library libgtest_main.a
[ 66%] Built target gtest_main
Scanning dependencies of target runBasicTests
[ 83%] Building CXX object Tests/basic_tests/CMakeFiles/runBasicTests.dir/basic_check.cpp.o
[100%] Linking CXX executable runBasicTests
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: cannot find -lsrc
collect2: error: ld returned 1 exit status
Tests/basic_tests/CMakeFiles/runBasicTests.dir/build.make:97: recipe for target 'Tests/basic_tests/runBasicTests' failed
gmake[3]: *** [Tests/basic_tests/runBasicTests] Error 1
CMakeFiles/Makefile2:256: recipe for target 'Tests/basic_tests/CMakeFiles/runBasicTests.dir/all' failed
gmake[2]: *** [Tests/basic_tests/CMakeFiles/runBasicTests.dir/all] Error 2
CMakeFiles/Makefile2:268: recipe for target 'Tests/basic_tests/CMakeFiles/runBasicTests.dir/rule' failed
gmake[1]: *** [Tests/basic_tests/CMakeFiles/runBasicTests.dir/rule] Error 2
Makefile:201: recipe for target 'runBasicTests' failed
gmake: *** [runBasicTests] Error 2
It would be fine if my Project runs on Linux..
Any suggestions?
-ChrizZ
You can follow this link ->
https://www.youtube.com/channel/UCvHU1FkIE-ogFTtXnKZsqWA
There are 2 videos. Both are helpful. I set up googleTest in my CLion yesterday following the 8:19 long video.