我是使用CImg和boost的新手。我将在下面分享的代码中获得未定义的符号引用,如下所述。
我正在使用此命令行来构建它:g ++ -lboost_filesystem -lboost_system -L / usr / X11R6 / lib -lm -lpthread -lX11 grayscaleConvertor.cpp&> errLog.txt
我在编译器命令中使用-l args。例如:-lboost_filesystem我在stackoverflow中的另一篇文章中读到了,但这并没有帮助解决boost :: filesystem :: symbols
找到CImg:/usr/include/CImg.h
找到boost:/ usr / include / boost(加上更多行)
errLog.txt
/tmp/ccRIIPim.o:在函数
main': grayscaleConvertor.cpp:(.text+0x179): undefined reference to
boost :: filesystem :: path :: extension()const' grayscaleConvertor.cpp :(。text + 0x213):未定义引用boost::filesystem::path::filename() const' /tmp/ccRIIPim.o: In function
__ static_initialization_and_destruction_0(int,int)': grayscaleConvertor.cpp :(。text + 0x68e):对boost::system::generic_category()' grayscaleConvertor.cpp:(.text+0x698): undefined reference to
boost :: system :: generic_category()'的未定义引用 grayscaleConvertor.cpp :(。text + 0x6a2):未定义引用boost::system::system_category()' /tmp/ccRIIPim.o: In function
boost :: system :: error_code :: error_code()': grayscaleConvertor.cpp :(。text._ZN5boost6system10error_codeC2Ev [_ZN5boost6system10error_codeC5Ev] + 0x10):未定义引用boost::system::system_category()' /tmp/ccRIIPim.o: In function
boost :: system :: error_code :: clear()': grayscaleConvertor.cpp :(。text._ZN5boost6system10error_code5clearEv [_ZN5boost6system10error_code5clearEv] + 0x10):未定义引用boost::system::system_category()' /tmp/ccRIIPim.o: In function
boost :: filesystem :: path :: compare(std :: __ cxx11 :: basic_string,std :: allocator> const& amp; ;)const': grayscaleConvertor.cpp :(。text._ZNK5boost10filesystem4path7compareERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE [_ZNK5boost10filesystem4path7compareERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE] + 0x3b):未定义引用boost::filesystem::path::compare(boost::filesystem::path const&) const' /tmp/ccRIIPim.o: In function
boost :: filesystem :: exists(boost :: filesystem :: path const&)': grayscaleConvertor.cpp :(。text._ZN5boost10filesystem6existsERKNS0_4pathE [_ZN5boost10filesystem6existsERKNS0_4pathE] + 0x24):未定义引用boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)' /tmp/ccRIIPim.o: In function
boost :: filesystem :: is_directory(boost :: filesystem :: path const&)': grayscaleConvertor.cpp :(。text._ZN5boost10filesystem12is_directoryERKNS0_4pathE [_ZN5boost10filesystem12is_directoryERKNS0_4pathE] + 0x24):未定义引用boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)' /tmp/ccRIIPim.o: In function
boost :: filesystem :: is_regular_file(boost :: filesystem :: path const&)': grayscaleConvertor.cpp :(。text._ZN5boost10filesystem15is_regular_fileERKNS0_4pathE [_ZN5boost10filesystem15is_regular_fileERKNS0_4pathE] + 0x24):未定义引用boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)' /tmp/ccRIIPim.o: In function
boost :: filesystem :: directory_entry :: status(boost :: system :: error_code&)const': grayscaleConvertor.cpp :(。text._ZNK5boost10filesystem15directory_entry6statusERNS_6system10error_codeE [_ZNK5boost10filesystem15directory_entry6statusERNS_6system10error_codeE] + 0x31):未定义引用boost::filesystem::directory_entry::m_get_status(boost::system::error_code*) const' /tmp/ccRIIPim.o: In function
boost :: filesystem :: directory_entry :: symlink_status(boost :: system :: error_code&)const': grayscaleConvertor.cpp :(。text._ZNK5boost10filesystem15directory_entry14symlink_statusERNS_6system10error_codeE [_ZNK5boost10filesystem15directory_entry14symlink_statusERNS_6system10error_codeE] + 0x31):未定义引用boost::filesystem::directory_entry::m_get_symlink_status(boost::system::error_code*) const' /tmp/ccRIIPim.o: In function
boost :: filesystem :: detail :: dir_itr_imp :: ~dir_itr_imp()': grayscaleConvertor.cpp :(。text._ZN5boost10filesystem6detail11dir_itr_impD2Ev [_ZN5boost10filesystem6detail11dir_itr_impD5Ev] + 0x2e):未定义引用boost::filesystem::detail::dir_itr_close(void*&, void*&)' /tmp/ccRIIPim.o: In function
boost :: filesystem :: directory_iterator :: directory_iterator(boost :: filesystem :: path const&)': grayscaleConvertor.cpp :(。text._ZN5boost10filesystem18directory_iteratorC2ERKNS0_4pathE [_ZN5boost10filesystem18directory_iteratorC5ERKNS0_4pathE] + 0x4a):对boost::filesystem::detail::directory_iterator_construct(boost::filesystem::directory_iterator&, boost::filesystem::path const&, boost::system::error_code*)' /tmp/ccRIIPim.o: In function
boost :: filesystem :: directory_iterator :: directory_iterator的未定义引用(boost :: filesystem :: path const&,boost :: system: :ERROR_CODE&安培;)&#39 ;: grayscaleConvertor.cpp :(。text._ZN5boost10filesystem18directory_iteratorC2ERKNS0_4pathERNS_6system10error_codeE [_ZN5boost10filesystem18directory_iteratorC5ERKNS0_4pathERNS_6system10error_codeE] + 0x4b):未定义引用boost::filesystem::detail::directory_iterator_construct(boost::filesystem::directory_iterator&, boost::filesystem::path const&, boost::system::error_code*)' /tmp/ccRIIPim.o: In function
boost :: filesystem :: directory_iterator :: increment()': grayscaleConvertor.cpp :(。text._ZN5boost10filesystem18directory_iterator9incrementEv [_ZN5boost10filesystem18directory_iterator9incrementEv] + 0xf):未定义引用boost::filesystem::detail::directory_iterator_increment(boost::filesystem::directory_iterator&, boost::system::error_code*)' /tmp/ccRIIPim.o: In function
cimg_library :: cimg :: Mutex_info :: trylock(unsigned int)': grayscaleConvertor.cpp :(。text._ZN12cimg_library4cimg10Mutex_info7trylockEj [_ZN12cimg_library4cimg10Mutex_info7trylockEj] + 0x1c):对pthread_mutex_trylock' /tmp/ccRIIPim.o: In function
的未定义引用cimg_library :: CImgDisplay :: screen_width()': grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay12screen_widthEv [_ZN12cimg_library11CImgDisplay12screen_widthEv] + 0x26):对XOpenDisplay' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay12screen_widthEv[_ZN12cimg_library11CImgDisplay12screen_widthEv]+0x96): undefined reference to
XCloseDisplay'的未定义引用 /tmp/ccRIIPim.o:在函数cimg_library::CImgDisplay::screen_height()': grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay13screen_heightEv[_ZN12cimg_library11CImgDisplay13screen_heightEv]+0x26): undefined reference to
XOpenDisplay' grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay13screen_heightEv [_ZN12cimg_library11CImgDisplay13screen_heightEv] + 0x96):未定义引用XCloseDisplay' /tmp/ccRIIPim.o: In function
cimg_library :: CImgDisplay :: _ handle_events(_XEvent const *)': grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent [_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent] + 0xb5):对XUnmapWindow' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x112): undefined reference to
XCheckWindowEvent'的未定义引用 grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent [_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent] +0x1f0):对XResizeWindow' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x2c2): undefined reference to
XCheckWindowEvent'的未定义引用 grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent [_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent] + 0x317):对XGetWindowAttributes' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x335): undefined reference to
XSync'的未定义引用 grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent [_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent] + 0x356):未定义引用XSetInputFocus' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x472): undefined reference to
XCheckWindowEvent' grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent [_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent] + 0x5c4):对XCheckWindowEvent' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x601): undefined reference to
XLookupString'的未定义引用 grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent [_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent] +0x635):对XQueryKeymap' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x6d8): undefined reference to
XLookupString'的未定义引用 grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent [_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent] + 0x71b):对XCheckWindowEvent' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x7f0): undefined reference to
XCheckWindowEvent'的未定义引用 grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent [_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent] + 0x861):对XCheckWindowEvent' /tmp/ccRIIPim.o: In function
的未定义引用cimg_library :: CImgDisplay :: _ events_thread(void *)': grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay14_events_threadEPv [_ZN12cimg_library11CImgDisplay14_events_threadEPv] + 0x6a):对XCheckTypedEvent' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_events_threadEPv[_ZN12cimg_library11CImgDisplay14_events_threadEPv]+0x94): undefined reference to
XCheckMaskEvent'的未定义引用 grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay14_events_threadEPv [_ZN12cimg_library11CImgDisplay14_events_threadEPv] + 0x14c):未定义引用pthread_testcancel' /tmp/ccRIIPim.o: In function
cimg_library :: CImgDisplay :: _ set_colormap(unsigned long&amp ;, unsigned int)': grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay13_set_colormapERmj [_ZN12cimg_library11CImgDisplay13_set_colormapERmj] + 0x2a2):对XStoreColors' /tmp/ccRIIPim.o: In function
的未定义引用cimg_library :: CImgDisplay :: _ map_window()': grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay11_map_windowEv [_ZN12cimg_library11CImgDisplay11_map_windowEv] + 0x50):未定义引用XMapRaised' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay11_map_windowEv[_ZN12cimg_library11CImgDisplay11_map_windowEv]+0x74): undefined reference to
XWindowEvent' grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay11_map_windowEv [_ZN12cimg_library11CImgDisplay11_map_windowEv] +0xcb):对XGetWindowAttributes' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay11_map_windowEv[_ZN12cimg_library11CImgDisplay11_map_windowEv]+0xe9): undefined reference to
XSync'的未定义引用 /tmp/ccRIIPim.o:在函数cimg_library::CImgDisplay::_paint(bool)': grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay6_paintEb[_ZN12cimg_library11CImgDisplay6_paintEb]+0xcd): undefined reference to
XSendEvent' grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay6_paintEb [_ZN12cimg_library11CImgDisplay6_paintEb] + 0x130):未定义引用XPutImage' /tmp/ccRIIPim.o: In function
cimg_library :: CImgDisplay :: _ init_fullscreen()': grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv [_ZN12cimg_library11CImgDisplay16_init_fullscreenEv] + 0xfe):对XCreateWindow' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x1df): undefined reference to
XCreateImage'的未定义引用 grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv [_ZN12cimg_library11CImgDisplay16_init_fullscreenEv] + 0x208):对XSelectInput' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x226): undefined reference to
XMapRaised'的未定义引用 grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv [_ZN12cimg_library11CImgDisplay16_init_fullscreenEv] + 0x24a):对XWindowEvent' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x2c1): undefined reference to
XPutImage'的未定义引用 grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv [_ZN12cimg_library11CImgDisplay16_init_fullscreenEv] +0x2e6):对XGetWindowAttributes' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x304): undefined reference to
XSync'的未定义引用 /tmp/ccRIIPim.o:在函数cimg_library::CImgDisplay::_desinit_fullscreen()': grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay19_desinit_fullscreenEv[_ZN12cimg_library11CImgDisplay19_desinit_fullscreenEv]+0x28): undefined reference to
XUngrabKeyboard' grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay19_desinit_fullscreenEv [_ZN12cimg_library11CImgDisplay19_desinit_fullscreenEv] + 0x4d):未定义引用XDestroyWindow' /tmp/ccRIIPim.o: In function
cimg_library :: CImgDisplay :: _ assign(unsigned int,unsigned int,char const *,unsigned int,bool,bool)& #39 ;: grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb [_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb] + 0xf7):未定义引用XOpenDisplay' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x330): undefined reference to
XVisualIDFromVisual' grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb [_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb] + 0x34b):对XGetVisualInfo' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x392): undefined reference to
XFree'的未定义引用 grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb [_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb] + 0x3d2):对pthread_create' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x57c): undefined reference to
XCreateWindow'的未定义引用 grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb [_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb] +0x5e3):对XCreateSimpleWindow' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x614): undefined reference to
XSelectInput'的未定义引用 grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb [_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb] +0x650):对XStoreName' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x6ab): undefined reference to
XCreateColormap'的未定义引用 grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb [_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb] + 0x703):对XSetWindowColormap' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x70b): undefined reference to
XAllocClassHint'的未定义引用 grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb [_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb] + 0x741):对XSetClassHint' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x74f): undefined reference to
XFree'的未定义引用 grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb [_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb] + 0x84a):对XCreateImage' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x870): undefined reference to
XInternAtom'的未定义引用 grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb [_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb] + 0x896):对XInternAtom' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x8ce): undefined reference to
XSetWMProtocols'的未定义引用 grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb [_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb] + 0x902):对XGrabKeyboard' /tmp/ccRIIPim.o: In function
的未定义引用cimg_library :: CImgDisplay :: assign()': grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay6assignEv [_ZN12cimg_library11CImgDisplay6assignEv] + 0x10c):对XDestroyWindow' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay6assignEv[_ZN12cimg_library11CImgDisplay6assignEv]+0x17b): undefined reference to
XFreeColormap'的未定义引用 grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay6assignEv [_ZN12cimg_library11CImgDisplay6assignEv] + 0x198):未定义引用XSync' /tmp/ccRIIPim.o: In function
cimg_library :: CImgDisplay :: resize(int,int,bool)': grayscaleConvertor.cpp :(。text._ZN12cimg_library11CImgDisplay6resizeEiib [_ZN12cimg_library11CImgDisplay6resizeEiib] + 0x208):对XResizeWindow' grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay6resizeEiib[_ZN12cimg_library11CImgDisplay6resizeEiib]+0x227): undefined reference to
XGetWindowAttributes'的未定义引用 /tmp/ccRIIPim.o:在函数cimg_library::CImgDisplay::move(int, int)': grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay4moveEii[_ZN12cimg_library11CImgDisplay4moveEii]+0x72): undefined reference to
XMoveWindow&#39; /tmp/ccRIIPim.o:在函数void cimg_library::CImgDisplay::_resize<unsigned char>(unsigned char, unsigned int, unsigned int, bool)': grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_resizeIhEEvT_jjb[_ZN12cimg_library11CImgDisplay7_resizeIhEEvT_jjb]+0x106): undefined reference to
XCreateImage&#39; /tmp/ccRIIPim.o:在函数void cimg_library::CImgDisplay::_resize<unsigned short>(unsigned short, unsigned int, unsigned int, bool)': grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_resizeItEEvT_jjb[_ZN12cimg_library11CImgDisplay7_resizeItEEvT_jjb]+0x10b): undefined reference to
XCreateImage&#39; /tmp/ccRIIPim.o:在函数void cimg_library::CImgDisplay::_resize<unsigned int>(unsigned int, unsigned int, unsigned int, bool)': grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_resizeIjEEvT_jjb[_ZN12cimg_library11CImgDisplay7_resizeIjEEvT_jjb]+0x106): undefined reference to
XCreateImage&#39; /tmp/ccRIIPim.o:在函数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*)': grayscaleConvertor.cpp:(.text._ZN5boost10filesystem4pathC2INS0_15directory_entryEEERKT_PNS_9enable_ifINS0_11path_traits11is_pathableINS_5decayIS4_E4typeEEEvE4typeE[_ZN5boost10filesystem4pathC5INS0_15directory_entryEEERKT_PNS_9enable_ifINS0_11path_traits11is_pathableINS_5decayIS4_E4typeEEEvE4typeE]+0x21): undefined reference to
boost :: filesystem :: path_traits :: dispatch(boost :: filesystem :: directory_entry const&amp;,std :: __ cxx11 :: basic_string,std :: allocator&gt;&amp; ;)&#39; collect2:错误:ld返回1退出状态
grayscaleConvertor.cpp
#define BOOST_FILESYSTEM_VERSION 3
#define BOOST_FILESYSTEM_NO_DEPRECATED
#include <boost/filesystem.hpp>
#include "CImg.h"
#include <iostream>
#include <string>
using namespace cimg_library;
using namespace std;
namespace fs = ::boost::filesystem;
int main()
{
const string ext = ".png";
fs::path root("/Downloads/testdata1/");
if(!fs::exists(root) || !fs::is_directory(root)) return -1;
fs::recursive_directory_iterator it(root);
fs::recursive_directory_iterator endit;
while(it != endit)
{
if(fs::is_regular_file(*it) && it->path().extension()==ext)
{
CImg<unsigned char> image(it->path().filename().string().c_str()),
gray(image.width(), image.height(), 1, 1, 0),
grayWeight(image.width(), image.height(), 1, 1, 0),
imgR(image.width(), image.height(), 1, 3, 0),
imgG(image.width(), image.height(), 1, 3, 0),
imgB(image.width(), image.height(), 1, 3, 0);
}
++it;
}
return 0;
}