Can't link Boost 1.63.0 through CMake - c++

what I'm trying to do is as you can guess from the title to link Boost libraries through CMake (I'm working with CLion to write cross platform code, so I have no other chance). I am sure I built everything correctly cause when I use it inside Visual Studio it works with no problem at all.
Here's my CMake code:
cmake_minimum_required(VERSION 3.7)
project(BoostHello)
set(BOOST_ROOT C:/boost_1.63.0)
find_package(BOOST 1.6.0 REQUIRED)
include_directories( ${Boost_INCLUDE_DIR} )
set(CMAKE_CXX_STANDARD 14)
set(SOURCE_FILES main.cpp)
add_executable(BoostHello ${SOURCE_FILES})
target_link_libraries( BoostHello ${Boost_LIBRARIES} )
And here are my compilation errors:
"C:\Program Files (x86)\JetBrains\CLion 2017.1\bin\cmake\bin\cmake.exe" --build C:\Users\Admin\CLionProjects\BoostHello\cmake-build-debug --target all -- -j 8
Scanning dependencies of target BoostHello
[ 50%] Building CXX object CMakeFiles/BoostHello.dir/main.cpp.obj
[100%] Linking CXX executable BoostHello.exe
CMakeFiles\BoostHello.dir/objects.a(main.cpp.obj): In function `main':
C:/Users/Admin/CLionProjects/BoostHello/main.cpp:6: undefined reference to `boost::filesystem::path::root_path() const'
C:/Users/Admin/CLionProjects/BoostHello/main.cpp:7: undefined reference to `boost::filesystem::path::relative_path() const'
C:/Users/Admin/CLionProjects/BoostHello/main.cpp:8: undefined reference to `boost::filesystem::path::filename() const'
CMakeFiles\BoostHello.dir/objects.a(main.cpp.obj): In function `_static_initialization_and_destruction_0':
C:/boost_1.63.0/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'
C:/boost_1.63.0/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
C:/boost_1.63.0/boost/system/error_code.hpp:223: undefined reference to `boost::system::system_category()'
CMakeFiles\BoostHello.dir/objects.a(main.cpp.obj): In function `ZN5boost10filesystem11path_traits7convertEPKwS3_RNSt7__cxx1112basic_stringIcSt1 1char_traitsIcESaIcEEE':
C:/boost_1.63.0/boost/filesystem/path.hpp:989: undefined reference to `boost::filesystem::path::codecvt()'
C:/boost_1.63.0/boost/filesystem/path.hpp:989: undefined reference to `boost::filesystem::path_traits::convert(wchar_t const*, wchar_t const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::codecvt<wchar_t, char, int> const&)'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\BoostHello.dir\build.make:96: recipe for target 'BoostHello.exe' failed
mingw32-make.exe[2]: *** [BoostHello.exe] Error 1
mingw32-make.exe[1]: *** [CMakeFiles/BoostHello.dir/all] Error 2
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/BoostHello.dir/all' failed
mingw32-make.exe: *** [all] Error 2
Makefile:82: recipe for target 'all' failed
And eventually here's the code I'm trying to compile:
#include <iostream>
#include <boost/filesystem.hpp>
int main(int argc, char** argv) {
boost::filesystem::path myPath = {L"C:/Users/Admin/ClionProjects/BoostHello"};
std::cout << "Root:\t" << myPath.root_path() << std::endl;
std::cout << "Relative:\t" << myPath.relative_path() << std::endl;
std::cout << "Filename:\t" << myPath.filename() << std::endl;
return 0;
}
What am I doing wrong?
I am compiling with MinGW.
Thanks in advance!

Replace
find_package(BOOST 1.6.0 REQUIRED)
by
find_package(Boost 1.63.0 REQUIRED filesystem system)
otherwise CMake doesn't know which boost library to link against.

Related

Undefined reference when using OpenCV and CMake in VSCode

Im trying to use OpenCV in VSCode and followed this videos instructions: https://www.youtube.com/watch?v=m9HBM1m_EMU&t=3s&ab_channel=NicolaiNielsen-ComputerVision%26AI
Difference from the video is im using mingw compiler and im unable to get the msvc compiler (Not the issue though).
main.cpp:
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace cv;
int main()
{
std::cout << "aa" << std::endl;
std::string img = "lenna.jpg";
Mat srcImage = imread(img);
if (!srcImage.data) {
return 1;
}
imshow("srcImage", srcImage);
waitKey(0);
return 0;
}
CMakeLists.txt:
cmake_minimum_required(VERSION 3.0.0)
project(OpenCV_Test VERSION 0.1.0)
include(CTest)
enable_testing()
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(OpenCV_Test main.cpp)
target_link_libraries(OpenCV_Test ${OpenCV_LIBS})
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
Im able to get it to compile and output "aa" if i remove everything with OpenCV, but adding it gives me this compile error:
[main] Building folder: OpenCVTest
[build] Starting build
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/Users/Chris/Desktop/OpenCVTest/build --config Debug --target all -j 10 --
[build] Consolidate compiler generated dependencies of target OpenCV_Test
[build] [ 50%] Building CXX object CMakeFiles/OpenCV_Test.dir/main.cpp.obj
[build] [100%] Linking CXX executable OpenCV_Test.exe
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/OpenCV_Test.dir/objects.a(main.cpp.obj):C:/Users/Chris/Desktop/OpenCVTest/main.cpp:12: undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/OpenCV_Test.dir/objects.a(main.cpp.obj): in function `main':
[build] C:/Users/Chris/Desktop/OpenCVTest/main.cpp:16: undefined reference to `cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Chris/Desktop/OpenCVTest/main.cpp:17: undefined reference to `cv::waitKey(int)'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Chris/Desktop/OpenCVTest/main.cpp:19: undefined reference to `cv::Mat::~Mat()'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Chris/Desktop/OpenCVTest/main.cpp:19: undefined reference to `cv::Mat::~Mat()'
[build] collect2.exe: error: ld returned 1 exit status
[build] make[2]: *** [CMakeFiles/OpenCV_Test.dir/build.make:117: OpenCV_Test.exe] Error 1
[build] make[1]: *** [CMakeFiles/Makefile2:839: CMakeFiles/OpenCV_Test.dir/all] Error 2
[build] make: *** [Makefile:121: all] Error 2
[build] Build finished with exit code 2

Can't compile MagickWand using CMake

I couldn't compile my program which uses MagickWand with CMake. I'm getting this error:
[ 33%] Linking CXX executable bin/ScreenRecorder
/usr/bin/ld: CMakeFiles/ScreenRecorder.dir/source/main.cpp.o: in function `std::thread::thread<void (&)(), , void>(void (&)())':
main.cpp:(.text._ZNSt6threadC2IRFvvEJEvEEOT_DpOT0_[_ZNSt6threadC5IRFvvEJEvEEOT_DpOT0_]+0x20): undefined reference to `pthread_create'
/usr/bin/ld: CMakeFiles/ScreenRecorder.dir/source/screenshot.cpp.o: in function `printScrn(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
screenshot.cpp:(.text+0xd): undefined reference to `MagickWandGenesis'
/usr/bin/ld: screenshot.cpp:(.text+0x1a): undefined reference to `NewMagickWand'
/usr/bin/ld: screenshot.cpp:(.text+0x31): undefined reference to `MagickReadImage'
/usr/bin/ld: screenshot.cpp:(.text+0x4f): undefined reference to `MagickWriteImage'
/usr/bin/ld: screenshot.cpp:(.text+0x62): undefined reference to `DestroyMagickWand'
/usr/bin/ld: screenshot.cpp:(.text+0x6b): undefined reference to `MagickWandTerminus'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/ScreenRecorder.dir/build.make:99: bin/ScreenRecorder] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/ScreenRecorder.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
This is my CMakeLists.txt:
cmake_minimum_required(VERSION 3.0)
project(ScreenRecorder)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall")
set(source_dir "${PROJECT_SOURCE_DIR}/source/")
set(EXECUTABLE_OUTPUT_PATH "${PROJECT_SOURCE_DIR}/bin/")
find_package(ImageMagick REQUIRED)
include_directories(
"/usr/include/ImageMagick-6/"
)
link_libraries(
"/usr/lib/x86_64-linux-gnu/"
)
file (GLOB src_files "${source_dir}*.cpp")
add_executable(ScreenRecorder ${src_files})
I tried using variables such as ${ImageMagick_MagickWand_INCLUDE_DIR} and ${ImageMagick_MagickWand_LIBS_DIR} but it says that "wand/MagickWand.h" not found.
Thanks for your answers.
I was able to resolve a similar issue by enclosing the auto-generated variables in quotes:
INCLUDE_DIRECTORIES(
"${ImageMagick_INCLUDE_DIRS}"
)
TARGET_LINK_LIBRARIES(MyProject
"${ImageMagick_LIBRARIES}"
)
The reason that this resolved the issue is that the variables are CMake lists.
Without quotes, they are concatenated to a long string:
MESSAGE(${ImageMagick_INCLUDE_DIRS})
MESSAGE(${ImageMagick_LIBRARIES})
->
1> [CMake] /usr/include/ImageMagick-6/usr/include/x86_64-linux-gnu/ImageMagick-6
1> [CMake] /usr/lib/x86_64-linux-gnu/libMagickWand-6.Q16.so
However, with quotes, the different elements of the list are separated using a semicolon:
MESSAGE("${ImageMagick_INCLUDE_DIRS}")
MESSAGE("${ImageMagick_LIBRARIES}")
->
1> [CMake] /usr/include/ImageMagick-6;/usr/include/x86_64-linux-gnu/ImageMagick-6
1> [CMake] /usr/lib/x86_64-linux-gnu/libMagickWand-6.Q16.so

OpenCV undefined reference to

I'm using Ubuntu 16.04 and OpenCV 2.4.9 and my quite simple example programs are constantly failing to build. I'm building on CLion.
As I'm kinda new to OpenCV I have some issues to narrow down the problem. I tried two different programs.
Number 1 is this one:
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
int main(int argc, char **argv) {
IplImage *img = cvLoadImage(argv[1]);
cvNamedWindow("Example1", CV_WINDOW_AUTOSIZE );
cvShowImage("Example1", img);
cvWaitKey(0);
cvReleaseImage(&img);
cvDestroyWindow("Example1" );
}
Which fails with:
Scanning dependencies of target untitled
[ 50%] Building CXX object CMakeFiles/untitled.dir/main.cpp.o
[100%] Linking CXX executable untitled
CMakeFiles/untitled.dir/main.cpp.o: In function `main':
/home/computervision/CLionProjects/untitled/main.cpp:7: undefined reference to `cvLoadImage'
/home/computervision/CLionProjects/untitled/main.cpp:8: undefined reference to `cvNamedWindow'
/home/computervision/CLionProjects/untitled/main.cpp:9: undefined reference to `cvShowImage'
/home/computervision/CLionProjects/untitled/main.cpp:10: undefined reference to `cvWaitKey'
/home/computervision/CLionProjects/untitled/main.cpp:11: undefined reference to `cvReleaseImage'
/home/computervision/CLionProjects/untitled/main.cpp:12: undefined reference to `cvDestroyWindow'
collect2: error: ld returned 1 exit status
CMakeFiles/untitled.dir/build.make:94: recipe for target 'untitled' failed
make[3]: *** [untitled] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/untitled.dir/all' failed
make[2]: *** [CMakeFiles/untitled.dir/all] Error 2
CMakeFiles/Makefile2:79: recipe for target 'CMakeFiles/untitled.dir/rule' failed
make[1]: *** [CMakeFiles/untitled.dir/rule] Error 2
Makefile:118: recipe for target 'untitled' failed
make: *** [untitled] Error 2
My 2nd one is this:
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
int main( int argc, char** argv ) {
cv::Mat image;
image = cv::imread("sample.jpeg" , CV_LOAD_IMAGE_COLOR);
if(! image.data ) {
std::cout << "Could not open or find the image" << std::endl ;
return -1;
}
cv::namedWindow( "Display window", cv::WINDOW_AUTOSIZE );
cv::imshow( "Display window", image );
cv::waitKey(0);
return 0;
}
Which fails with:
Scanning dependencies of target untitled
[ 50%] Building CXX object CMakeFiles/untitled.dir/main.cpp.o
[100%] Linking CXX executable untitled
CMakeFiles/untitled.dir/main.cpp.o: In function `main':
/home/computervision/CLionProjects/untitled/main.cpp:9: undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
/home/computervision/CLionProjects/untitled/main.cpp:16: undefined reference to `cv::namedWindow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
/home/computervision/CLionProjects/untitled/main.cpp:17: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
/home/computervision/CLionProjects/untitled/main.cpp:17: undefined reference to `cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)'
/home/computervision/CLionProjects/untitled/main.cpp:19: undefined reference to `cv::waitKey(int)'
CMakeFiles/untitled.dir/main.cpp.o: In function `cv::Mat::~Mat()':
/usr/local/include/opencv2/core/mat.hpp:278: undefined reference to `cv::fastFree(void*)'
CMakeFiles/untitled.dir/main.cpp.o: In function `cv::Mat::operator=(cv::Mat const&)':
/usr/local/include/opencv2/core/mat.hpp:298: undefined reference to `cv::Mat::copySize(cv::Mat const&)'
CMakeFiles/untitled.dir/main.cpp.o: In function `cv::Mat::release()':
/usr/local/include/opencv2/core/mat.hpp:367: undefined reference to `cv::Mat::deallocate()'
collect2: error: ld returned 1 exit status
CMakeFiles/untitled.dir/build.make:94: recipe for target 'untitled' failed
make[3]: *** [untitled] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/untitled.dir/all' failed
make[2]: *** [CMakeFiles/untitled.dir/all] Error 2
CMakeFiles/Makefile2:79: recipe for target 'CMakeFiles/untitled.dir/rule' failed
make[1]: *** [CMakeFiles/untitled.dir/rule] Error 2
Makefile:118: recipe for target 'untitled' failed
make: *** [untitled] Error 2
My CMakeLists.txt:
cmake_minimum_required(VERSION 3.9)
project(untitled)
set(CMAKE_CXX_STANDARD 11)
add_executable(untitled main.cpp)
I wonder what I could have done so wrong.
Most searches lead to wrong settings of the g++ command, but I assume CLion knows what it's doing (also I tried with the command too, same errors).
For instance this here: openCV error : undefined reference to `cvLoadImage' Ubuntu
I assume highgui is not linked properly. Which might be the case, my output of:
computervision#computervision-VirtualBox:~/ex$ pkg-config opencv --libs
/usr/local/lib/libopencv_core.so /usr/local/lib/libopencv_flann.so /usr/local/lib/libopencv_ml.so
looks kinda poor, I assume I made a mistake during installation (just which?).
Another error might be the CMakeLists.txt. Here it was recommended to change it. But the line
LIBRARIES += glog gflags protobuf leveldb snappy
causes an error.
Executing
export CMAKE_CXX_FLAGS=`pkg-config opencv --cflags --libs`
before starting CLion doesn't make any difference either.
EDIT:
Using cmake:
computervision#computervision-VirtualBox:~/CLionProjects/untitled$ cmake .
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- 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
OpenCV_LIBS: opencv_mlopencv_flannopencv_core
-- Configuring done
-- Generating done
-- Build files have been written to: /home/computervision/CLionProjects/untitled
computervision#computervision-VirtualBox:~/CLionProjects/untitled$ g++ -o untitled main.cpp `pkg-config opencv --cflags --libs`
/tmp/ccdAr2hr.o: In function `main':
main.cpp:(.text+0x78): undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
main.cpp:(.text+0x128): undefined reference to `cv::namedWindow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
main.cpp:(.text+0x1a2): undefined reference to `cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)'
main.cpp:(.text+0x1ca): undefined reference to `cv::waitKey(int)'
collect2: error: ld returned 1 exit status
EDIT (2):
Using make after cmake:
computervision#computervision-VirtualBox:~/CLionProjects/untitled$ make
Scanning dependencies of target untitled
[ 50%] Building CXX object CMakeFiles/untitled.dir/main.cpp.o
[100%] Linking CXX executable untitled
CMakeFiles/untitled.dir/main.cpp.o: In function `main':
main.cpp:(.text+0x78): undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
main.cpp:(.text+0x128): undefined reference to `cv::namedWindow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
main.cpp:(.text+0x1a2): undefined reference to `cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)'
main.cpp:(.text+0x1ca): undefined reference to `cv::waitKey(int)'
collect2: error: ld returned 1 exit status
CMakeFiles/untitled.dir/build.make:97: recipe for target 'untitled' failed
make[2]: *** [untitled] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/untitled.dir/all' failed
make[1]: *** [CMakeFiles/untitled.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Linking OpenCV in CMakeLists.txt is missing.
cmake_minimum_required(VERSION 3.9)
project(untitled)
set(CMAKE_CXX_STANDARD 11)
find_package( OpenCV REQUIRED ) # locate OpenCV in system
include_directories( ${OpenCV_INCLUDE_DIRS} ) # provide library headers
add_executable(untitled main.cpp)
target_link_libraries( untitled ${OpenCV_LIBS} /usr/lib/x86_64-linux-gnu/libopencv_highgui.so) # link OpenCV libraries , hightgui.so not found by cmake so this hack
MESSAGE("OpenCV_LIBS: " ${OpenCV_LIBS} ) #display opencv libs found
if your compiler finds OpenCV and after executing cmake it should show OpenCV libraries found.

Error with Poco

I want to use Poco libraries in my C++ project.
But I get an error on compilation.
I'm developing on Ubuntu OS, CLion 1.2.4 IDE
Here it is my source code:
#include "Poco/Net/ServerSocket.h"
#include <iostream>
int main(int arc, char** argv){
std::cout << "Hello world!";
return 0;
}
And this is my CMakeLists.txt file:
cmake_minimum_required(VERSION 3.3)
project(rcp)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")
include_directories("libraries")
add_executable(rcp ${SOURCE_FILES})
target_link_libraries(rcp pthread PocoNet PocoUtil PocoFoundation)
And this is the output when I do the compilation:
CMakeFiles/rcp.dir/main.cpp.o: In function `Poco::Net::Impl::IPv6SocketAddressImpl::host() const':
main.cpp:(.text._ZNK4Poco3Net4Impl21IPv6SocketAddressImpl4hostEv[_ZNK4Poco3Net4Impl21IPv6SocketAddressImpl4hostEv]+0x11): undefined reference to `Poco::Net::IPAddress::IPAddress(void const*, unsigned int, unsigned int)'
CMakeFiles/rcp.dir/main.cpp.o: In function `Poco::Net::Impl::IPv6SocketAddressImpl::~IPv6SocketAddressImpl()':
main.cpp:(.text._ZN4Poco3Net4Impl21IPv6SocketAddressImplD2Ev[_ZN4Poco3Net4Impl21IPv6SocketAddressImplD5Ev]+0x8): undefined reference to `Poco::Net::Impl::SocketAddressImpl::~SocketAddressImpl()'
CMakeFiles/rcp.dir/main.cpp.o: In function `Poco::Net::Impl::IPv6SocketAddressImpl::~IPv6SocketAddressImpl()':
main.cpp:(.text._ZN4Poco3Net4Impl21IPv6SocketAddressImplD0Ev[_ZN4Poco3Net4Impl21IPv6SocketAddressImplD5Ev]+0xc): undefined reference to `Poco::Net::Impl::SocketAddressImpl::~SocketAddressImpl()'
CMakeFiles/rcp.dir/main.cpp.o: In function `Poco::Net::Impl::IPv4SocketAddressImpl::~IPv4SocketAddressImpl()':
main.cpp:(.text._ZN4Poco3Net4Impl21IPv4SocketAddressImplD2Ev[_ZN4Poco3Net4Impl21IPv4SocketAddressImplD5Ev]+0x8): undefined reference to `Poco::Net::Impl::SocketAddressImpl::~SocketAddressImpl()'
CMakeFiles/rcp.dir/main.cpp.o: In function `Poco::Net::Impl::IPv4SocketAddressImpl::~IPv4SocketAddressImpl()':
main.cpp:(.text._ZN4Poco3Net4Impl21IPv4SocketAddressImplD0Ev[_ZN4Poco3Net4Impl21IPv4SocketAddressImplD5Ev]+0xc): undefined reference to `Poco::Net::Impl::SocketAddressImpl::~SocketAddressImpl()'
CMakeFiles/rcp.dir/main.cpp.o:(.rodata._ZTIN4Poco3Net4Impl21IPv4SocketAddressImplE[_ZTIN4Poco3Net4Impl21IPv4SocketAddressImplE]+0x10): undefined reference to `typeinfo for Poco::Net::Impl::SocketAddressImpl'
CMakeFiles/rcp.dir/main.cpp.o:(.rodata._ZTIN4Poco3Net4Impl21IPv6SocketAddressImplE[_ZTIN4Poco3Net4Impl21IPv6SocketAddressImplE]+0x10): undefined reference to `typeinfo for Poco::Net::Impl::SocketAddressImpl'
collect2: error: ld returned 1 exit status
CMakeFiles/rcp.dir/build.make:94: recipe for target '/home/john/projects/rightChoiceProperty/bin/rcp' failed
make[3]: *** [/home/john/projects/rightChoiceProperty/bin/rcp] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/rcp.dir/all' failed
make[2]: *** [CMakeFiles/rcp.dir/all] Error 2
CMakeFiles/Makefile2:79: recipe for target 'CMakeFiles/rcp.dir/rule' failed
make[1]: *** [CMakeFiles/rcp.dir/rule] Error 2
Makefile:118: recipe for target 'rcp' failed
make: *** [rcp] Error 2
Where is my problem I have search all of today but I couldn't find anything please help me to resolve this problem.
Thank you every body
I resolved the problem, as " M.M " guide in above comment:
The output suggests you didn't actually link against Poco::Net.
Another possibility might be if you're using Poco headers from a
different version of Poco than the compiled library you are linking
against
I removed changed the include to include right library.
At first this was my include line:
#include "Poco/Net/ServerSocket.h"
Changed to
#include <Poco/Net/ServerSocket.h>
Everything is working fine now.
Thank you M.M

OpenCV 3.0 undefined reference error?

I've just followed the instructions to install opencv 3 on my ubuntu computer (I've already installed and ran programs using opencv 3 on a different linux device), however, when I tried to run one of my test programs from my old computer I get the following errors:
CMakeFiles/VideoTest.dir/VideoTest.cpp.o: In function `main':
VideoTest.cpp:(.text+0x6f): undefined reference to `cv::VideoWriter::fourcc(char,char,char, char)'
VideoTest.cpp:(.text+0xc3): undefined reference to `cv::VideoWriter::open(cv::String const&, int, double, cv::Size_<int>, bool)'
VideoTest.cpp:(.text+0x103): undefined reference to `cv::namedWindow(cv::String const&, int)'
VideoTest.cpp:(.text+0x146): undefined reference to `cv::VideoCapture::read(cv::_OutputArray const&)'
VideoTest.cpp:(.text+0x1b1): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
CMakeFiles/VideoTest.dir/VideoTest.cpp.o: In function `cv::String::String(char const*)':
VideoTest.cpp:(.text._ZN2cv6StringC2EPKc[_ZN2cv6StringC5EPKc]+0x3b): undefined reference to `cv::String::allocate(unsigned int)'
CMakeFiles/VideoTest.dir/VideoTest.cpp.o: In function `cv::String::~String()':
VideoTest.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0xd): undefined reference to `cv::String::deallocate()'
collect2: ld returned 1 exit status
make[2]: *** [VideoTest] Error 1
make[1]: *** [CMakeFiles/VideoTest.dir/all] Error 2
make: *** [all] Error 2
Any idea what's going on? I'm relatively new to opencv. Here's my test code for reference:
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/opencv.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char* argv[]){
VideoCapture vCap(0);
VideoWriter vWrite;
vWrite.open("test.avi", vWrite.fourcc('M','J','P','G'), 20, Size(640, 480), true);
while (1) {
namedWindow("VideoFeed", WINDOW_AUTOSIZE);
Mat frame;
vCap.read(frame);
vWrite.write(frame);
imshow("VideoFeed", frame);
char c = waitKey(50);
if (c == 27) {
break;
}
}
return 0;
}
Thanks in advance.
Edit: My CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
project(VideoTest)
find_package(OpenCV REQUIRED)
add_executable(VideoTest VideoTest.cpp)
target_link_libraries(VideoTest ${OpenCV_LIBS})
VideoCapture and VideoWriter were moved to the videoio module in 3.0, so you have to additionally
#include "opencv2/videoio.hpp"
also, you don't seem to link to any of the required opencv libs, those are:
opencv_core, opencv_videoio, opencv_highgui
Alright, I've finally figured out what's going on. Something internally in the CMakeFiles folder went screwy when I moved the directory over to my new system. Removing all files/directories besides the project .cpp file and the CMakeLists.txt file, and running "cmake ." and "make" again seems to solve the problem.
Below cmake file works for me.
cmake_minimum_required(VERSION 3.5)
project(ImageProcessing)
set(CMAKE_CXX_STANDARD 14)
find_package(OpenCV REQUIRED)
include_directories( ${OpenCV_INCLUDE_DIRS} )
set(SOURCE_FILES main.cpp)
add_executable(ImageProcessing ${SOURCE_FILES})
target_link_libraries( ImageProcessing ${OpenCV_LIBS} )
# Print some message showing some of them
message(STATUS "OpenCV library status:")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")