I'm trying to compile the message pack (http://msgpack.org/) example code and keep getting these errors which I can't get to the bottom of:
g++ -o"MsgPack2" ./src/MsgPack2.o -lmsgpack -lmsgpackc
./src/MsgPack2.o: In function `main':
/mnt/eoh/workspace/MsgPack2/Debug/../src/MsgPack2.cpp:38:
undefined reference to msgpack::rpc::server::listen(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&, unsigned
short)'
./src/MsgPack2.o: In functionloop':
/usr/local/include/msgpack/rpc/loop.h:30: undefined reference to
mp::wavy::loop::loop()'
./src/MsgPack2.o: In functionbase':
/usr/local/include/msgpack/rpc/server.h:59: undefined reference to
msgpack::rpc::server::server(msgpack::rpc::loop)'
/usr/local/include/msgpack/rpc/server.h:59: undefined reference to
msgpack::rpc::server::serve(msgpack::rpc::dispatcher*)'
/usr/local/include/msgpack/rpc/server.h:59: undefined reference to
msgpack::rpc::server::~server()'
./src/MsgPack2.o: In function~base':
/usr/local/include/msgpack/rpc/server.h:64: undefined reference to
msgpack::rpc::server::~server()'
./src/MsgPack2.o: In function
myserver::dispatch(msgpack::rpc::request)':
/mnt/eoh/workspace/MsgPack2/Debug/../src/MsgPack2.cpp:14:
undefined reference to msgpack::rpc::request::method()'
/mnt/eoh/workspace/MsgPack2/Debug/../src/MsgPack2.cpp:18:
undefined reference tomsgpack::rpc::request::params()'
./src/MsgPack2.o: In function
msgpack::rpc::loop_util<msgpack::rpc::session_pool>::run(unsigned
long)':
/usr/local/include/msgpack/rpc/loop_util.h:34: undefined reference
tomsgpack::rpc::session_pool::get_loop()'
/usr/local/include/msgpack/rpc/loop_util.h:34: undefined reference
to mp::wavy::loop::run(unsigned long)'
./src/MsgPack2.o: In functionvoid
msgpack::rpc::request::call(int&,
msgpack::type::nil&)':
/usr/local/include/msgpack/rpc/request.h:119: undefined reference
to msgpack::rpc::request::is_sent() const'
/usr/local/include/msgpack/rpc/request.h:122: undefined reference
tomsgpack::rpc::request::get_msgid() const'
/usr/local/include/msgpack/rpc/request.h:125: undefined reference
to msgpack::rpc::request::send_data(msgpack::sbuffer*)'
./src/MsgPack2.o: In functionvoid
msgpack::rpc::request::call(msgpack::type::nil&, unsigned char&)':
/usr/local/include/msgpack/rpc/request.h:119: undefined reference
to msgpack::rpc::request::is_sent() const'
/usr/local/include/msgpack/rpc/request.h:122: undefined reference
tomsgpack::rpc::request::get_msgid() const'
/usr/local/include/msgpack/rpc/request.h:125: undefined reference
to msgpack::rpc::request::send_data(msgpack::sbuffer*)'
./src/MsgPack2.o: In functionvoid
msgpack::rpc::request::call, std::allocator >
(msgpack::type::nil&, std::basic_string,
std::allocator >&)':
/usr/local/include/msgpack/rpc/request.h:119: undefined reference
to msgpack::rpc::request::is_sent() const'
/usr/local/include/msgpack/rpc/request.h:122: undefined reference
tomsgpack::rpc::request::get_msgid() const'
/usr/local/include/msgpack/rpc/request.h:125: undefined reference
to msgpack::rpc::request::send_data(msgpack::sbuffer*)'
./src/MsgPack2.o: In function__shared_count':
/usr/include/c++/4.5/tr1/shared_ptr.h:121: undefined reference to
mp::wavy::loop::~loop()'
./src/MsgPack2.o: In function
std::tr1::_Sp_deleter::operator()(mp::wavy::loop*)
const':
/usr/include/c++/4.5/tr1/shared_ptr.h:99: undefined reference to
`mp::wavy::loop::~loop()'
collect2: ld returned 1 exit status
make: * [MsgPack2] Error 1
And here is the code:
#include <msgpack/rpc/server.h>
class myserver : public msgpack::rpc::server::base {
public:
void add(msgpack::rpc::request req, int a1, int a2)
{
req.result(a1 + a2);
}
public:
void dispatch(msgpack::rpc::request req)
try {
std::string method;
req.method().convert(&method);
if(method == "add") {
msgpack::type::tuple<int, int> params;
req.params().convert(¶ms);
add(req, params.get<0>(), params.get<1>());
} else {
req.error(msgpack::rpc::NO_METHOD_ERROR);
}
} catch (msgpack::type_error& e) {
req.error(msgpack::rpc::ARGUMENT_ERROR);
return;
} catch (std::exception& e) {
req.error(std::string(e.what()));
return;
}
};
int main(void)
{
myserver svr;
svr.instance.listen("127.0.0.1", 80800);
svr.instance.run(4); // run 4 threads
return 0;
}
If anyone has any ideas, it would be greatly appreciated.
Many thanks in advance,
You need -lmsgpack-rpc.
[Side note: 80800 is not a valid port.]
Related
I build vfptr.cpp with fsanitize=vptr to an static file.
It has errors messages about "undefined reference to __dynamic_cast".
Both g++7.4.0 and g++11.0.0 have the problem. Is it reasonable for using sanitizer=vptr?
vptr.cpp
struct A {
virtual ~A() {};
};
int main() { A a; }
compiled option
g++ vptr.C -fsanitize=vptr -static
error message:
/usr/lib/gcc/x86_64-linux-gnu/7/libubsan.a(ubsan_type_hash_itanium.o): In function `isDerivedFromAtOffset(__cxxabiv1::__class_type_info const*, __cxxabiv1::__class_type_info const*, long)':
(.text+0x52): undefined reference to `__dynamic_cast'
(.text+0x5e): undefined reference to `typeinfo for __cxxabiv1::__vmi_class_type_info'
(.text+0x6b): undefined reference to `__dynamic_cast'
/usr/lib/gcc/x86_64-linux-gnu/7/libubsan.a(ubsan_type_hash_itanium.o): In function `findBaseAtOffset(__cxxabiv1::__class_type_info const*, long)':
(.text+0x151): undefined reference to `__dynamic_cast'
(.text+0x15d): undefined reference to `typeinfo for __cxxabiv1::__vmi_class_type_info'
(.text+0x16a): undefined reference to `__dynamic_cast'
/usr/lib/gcc/x86_64-linux-gnu/7/libubsan.a(ubsan_type_hash_itanium.o): In function `__ubsan::checkDynamicType(void*, void*, unsigned long)':
(.text+0x293): undefined reference to `__dynamic_cast'
collect2: error: ld returned 1 exit status
I am new to using CImg and boost. I am getting undefined symbol references as mentioned below, in the code also shared below.
I am using this command line to build it: g++ -lboost_filesystem -lboost_system -L/usr/X11R6/lib -lm -lpthread -lX11 grayscaleConvertor.cpp &> errLog.txt
I am using the -l args in the compiler command. eg: -lboost_filesystem which I read on another post in stackoverflow, but that is not helping resolve the boost::filesystem:: symbols
locate CImg : /usr/include/CImg.h
locate boost: /usr/include/boost (plus more lines)
errLog.txt
/tmp/ccRIIPim.o: In function main':
grayscaleConvertor.cpp:(.text+0x179): undefined reference toboost::filesystem::path::extension() const'
grayscaleConvertor.cpp:(.text+0x213): undefined reference to boost::filesystem::path::filename() const'
/tmp/ccRIIPim.o: In function__static_initialization_and_destruction_0(int, int)':
grayscaleConvertor.cpp:(.text+0x68e): undefined reference to boost::system::generic_category()'
grayscaleConvertor.cpp:(.text+0x698): undefined reference toboost::system::generic_category()'
grayscaleConvertor.cpp:(.text+0x6a2): undefined reference to boost::system::system_category()'
/tmp/ccRIIPim.o: In functionboost::system::error_code::error_code()':
grayscaleConvertor.cpp:(.text._ZN5boost6system10error_codeC2Ev[_ZN5boost6system10error_codeC5Ev]+0x10): undefined reference to boost::system::system_category()'
/tmp/ccRIIPim.o: In functionboost::system::error_code::clear()':
grayscaleConvertor.cpp:(.text._ZN5boost6system10error_code5clearEv[_ZN5boost6system10error_code5clearEv]+0x10): undefined reference to boost::system::system_category()'
/tmp/ccRIIPim.o: In functionboost::filesystem::path::compare(std::__cxx11::basic_string, std::allocator > const&) const':
grayscaleConvertor.cpp:(.text._ZNK5boost10filesystem4path7compareERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZNK5boost10filesystem4path7compareERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x3b): undefined reference to boost::filesystem::path::compare(boost::filesystem::path const&) const'
/tmp/ccRIIPim.o: In functionboost::filesystem::exists(boost::filesystem::path const&)':
grayscaleConvertor.cpp:(.text._ZN5boost10filesystem6existsERKNS0_4pathE[_ZN5boost10filesystem6existsERKNS0_4pathE]+0x24): undefined reference to boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
/tmp/ccRIIPim.o: In functionboost::filesystem::is_directory(boost::filesystem::path const&)':
grayscaleConvertor.cpp:(.text._ZN5boost10filesystem12is_directoryERKNS0_4pathE[_ZN5boost10filesystem12is_directoryERKNS0_4pathE]+0x24): undefined reference to boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
/tmp/ccRIIPim.o: In functionboost::filesystem::is_regular_file(boost::filesystem::path const&)':
grayscaleConvertor.cpp:(.text._ZN5boost10filesystem15is_regular_fileERKNS0_4pathE[_ZN5boost10filesystem15is_regular_fileERKNS0_4pathE]+0x24): undefined reference to boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
/tmp/ccRIIPim.o: In functionboost::filesystem::directory_entry::status(boost::system::error_code&) const':
grayscaleConvertor.cpp:(.text._ZNK5boost10filesystem15directory_entry6statusERNS_6system10error_codeE[_ZNK5boost10filesystem15directory_entry6statusERNS_6system10error_codeE]+0x31): undefined reference to boost::filesystem::directory_entry::m_get_status(boost::system::error_code*) const'
/tmp/ccRIIPim.o: In functionboost::filesystem::directory_entry::symlink_status(boost::system::error_code&) const':
grayscaleConvertor.cpp:(.text._ZNK5boost10filesystem15directory_entry14symlink_statusERNS_6system10error_codeE[_ZNK5boost10filesystem15directory_entry14symlink_statusERNS_6system10error_codeE]+0x31): undefined reference to boost::filesystem::directory_entry::m_get_symlink_status(boost::system::error_code*) const'
/tmp/ccRIIPim.o: In functionboost::filesystem::detail::dir_itr_imp::~dir_itr_imp()':
grayscaleConvertor.cpp:(.text._ZN5boost10filesystem6detail11dir_itr_impD2Ev[_ZN5boost10filesystem6detail11dir_itr_impD5Ev]+0x2e): undefined reference to boost::filesystem::detail::dir_itr_close(void*&, void*&)'
/tmp/ccRIIPim.o: In functionboost::filesystem::directory_iterator::directory_iterator(boost::filesystem::path const&)':
grayscaleConvertor.cpp:(.text._ZN5boost10filesystem18directory_iteratorC2ERKNS0_4pathE[_ZN5boost10filesystem18directory_iteratorC5ERKNS0_4pathE]+0x4a): undefined reference to boost::filesystem::detail::directory_iterator_construct(boost::filesystem::directory_iterator&, boost::filesystem::path const&, boost::system::error_code*)'
/tmp/ccRIIPim.o: In functionboost::filesystem::directory_iterator::directory_iterator(boost::filesystem::path const&, boost::system::error_code&)':
grayscaleConvertor.cpp:(.text._ZN5boost10filesystem18directory_iteratorC2ERKNS0_4pathERNS_6system10error_codeE[_ZN5boost10filesystem18directory_iteratorC5ERKNS0_4pathERNS_6system10error_codeE]+0x4b): undefined reference to boost::filesystem::detail::directory_iterator_construct(boost::filesystem::directory_iterator&, boost::filesystem::path const&, boost::system::error_code*)'
/tmp/ccRIIPim.o: In functionboost::filesystem::directory_iterator::increment()':
grayscaleConvertor.cpp:(.text._ZN5boost10filesystem18directory_iterator9incrementEv[_ZN5boost10filesystem18directory_iterator9incrementEv]+0xf): undefined reference to boost::filesystem::detail::directory_iterator_increment(boost::filesystem::directory_iterator&, boost::system::error_code*)'
/tmp/ccRIIPim.o: In functioncimg_library::cimg::Mutex_info::trylock(unsigned int)':
grayscaleConvertor.cpp:(.text._ZN12cimg_library4cimg10Mutex_info7trylockEj[_ZN12cimg_library4cimg10Mutex_info7trylockEj]+0x1c): undefined reference to pthread_mutex_trylock'
/tmp/ccRIIPim.o: In functioncimg_library::CImgDisplay::screen_width()':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay12screen_widthEv[_ZN12cimg_library11CImgDisplay12screen_widthEv]+0x26): undefined reference to XOpenDisplay'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay12screen_widthEv[_ZN12cimg_library11CImgDisplay12screen_widthEv]+0x96): undefined reference toXCloseDisplay'
/tmp/ccRIIPim.o: In function cimg_library::CImgDisplay::screen_height()':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay13screen_heightEv[_ZN12cimg_library11CImgDisplay13screen_heightEv]+0x26): undefined reference toXOpenDisplay'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay13screen_heightEv[_ZN12cimg_library11CImgDisplay13screen_heightEv]+0x96): undefined reference to XCloseDisplay'
/tmp/ccRIIPim.o: In functioncimg_library::CImgDisplay::_handle_events(_XEvent const*)':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0xb5): undefined reference to XUnmapWindow'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x112): undefined reference toXCheckWindowEvent'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x1f0): undefined reference to XResizeWindow'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x2c2): undefined reference toXCheckWindowEvent'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x317): undefined reference to XGetWindowAttributes'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x335): undefined reference toXSync'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x356): undefined reference to XSetInputFocus'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x472): undefined reference toXCheckWindowEvent'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x5c4): undefined reference to XCheckWindowEvent'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x601): undefined reference toXLookupString'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x635): undefined reference to XQueryKeymap'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x6d8): undefined reference toXLookupString'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x71b): undefined reference to XCheckWindowEvent'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x7f0): undefined reference toXCheckWindowEvent'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x861): undefined reference to XCheckWindowEvent'
/tmp/ccRIIPim.o: In functioncimg_library::CImgDisplay::_events_thread(void*)':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_events_threadEPv[_ZN12cimg_library11CImgDisplay14_events_threadEPv]+0x6a): undefined reference to XCheckTypedEvent'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_events_threadEPv[_ZN12cimg_library11CImgDisplay14_events_threadEPv]+0x94): undefined reference toXCheckMaskEvent'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_events_threadEPv[_ZN12cimg_library11CImgDisplay14_events_threadEPv]+0x14c): undefined reference to pthread_testcancel'
/tmp/ccRIIPim.o: In functioncimg_library::CImgDisplay::_set_colormap(unsigned long&, unsigned int)':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay13_set_colormapERmj[_ZN12cimg_library11CImgDisplay13_set_colormapERmj]+0x2a2): undefined reference to XStoreColors'
/tmp/ccRIIPim.o: In functioncimg_library::CImgDisplay::_map_window()':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay11_map_windowEv[_ZN12cimg_library11CImgDisplay11_map_windowEv]+0x50): undefined reference to XMapRaised'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay11_map_windowEv[_ZN12cimg_library11CImgDisplay11_map_windowEv]+0x74): undefined reference toXWindowEvent'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay11_map_windowEv[_ZN12cimg_library11CImgDisplay11_map_windowEv]+0xcb): undefined reference to XGetWindowAttributes'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay11_map_windowEv[_ZN12cimg_library11CImgDisplay11_map_windowEv]+0xe9): undefined reference toXSync'
/tmp/ccRIIPim.o: In function cimg_library::CImgDisplay::_paint(bool)':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay6_paintEb[_ZN12cimg_library11CImgDisplay6_paintEb]+0xcd): undefined reference toXSendEvent'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay6_paintEb[_ZN12cimg_library11CImgDisplay6_paintEb]+0x130): undefined reference to XPutImage'
/tmp/ccRIIPim.o: In functioncimg_library::CImgDisplay::_init_fullscreen()':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0xfe): undefined reference to XCreateWindow'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x1df): undefined reference toXCreateImage'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x208): undefined reference to XSelectInput'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x226): undefined reference toXMapRaised'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x24a): undefined reference to XWindowEvent'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x2c1): undefined reference toXPutImage'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x2e6): undefined reference to XGetWindowAttributes'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x304): undefined reference toXSync'
/tmp/ccRIIPim.o: In function cimg_library::CImgDisplay::_desinit_fullscreen()':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay19_desinit_fullscreenEv[_ZN12cimg_library11CImgDisplay19_desinit_fullscreenEv]+0x28): undefined reference toXUngrabKeyboard'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay19_desinit_fullscreenEv[_ZN12cimg_library11CImgDisplay19_desinit_fullscreenEv]+0x4d): undefined reference to XDestroyWindow'
/tmp/ccRIIPim.o: In functioncimg_library::CImgDisplay::_assign(unsigned int, unsigned int, char const*, unsigned int, bool, bool)':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0xf7): undefined reference to XOpenDisplay'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x330): undefined reference toXVisualIDFromVisual'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x34b): undefined reference to XGetVisualInfo'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x392): undefined reference toXFree'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x3d2): undefined reference to pthread_create'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x57c): undefined reference toXCreateWindow'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x5e3): undefined reference to XCreateSimpleWindow'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x614): undefined reference toXSelectInput'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x650): undefined reference to XStoreName'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x6ab): undefined reference toXCreateColormap'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x703): undefined reference to XSetWindowColormap'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x70b): undefined reference toXAllocClassHint'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x741): undefined reference to XSetClassHint'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x74f): undefined reference toXFree'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x84a): undefined reference to XCreateImage'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x870): undefined reference toXInternAtom'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x896): undefined reference to XInternAtom'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x8ce): undefined reference toXSetWMProtocols'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x902): undefined reference to XGrabKeyboard'
/tmp/ccRIIPim.o: In functioncimg_library::CImgDisplay::assign()':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay6assignEv[_ZN12cimg_library11CImgDisplay6assignEv]+0x10c): undefined reference to XDestroyWindow'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay6assignEv[_ZN12cimg_library11CImgDisplay6assignEv]+0x17b): undefined reference toXFreeColormap'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay6assignEv[_ZN12cimg_library11CImgDisplay6assignEv]+0x198): undefined reference to XSync'
/tmp/ccRIIPim.o: In functioncimg_library::CImgDisplay::resize(int, int, bool)':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay6resizeEiib[_ZN12cimg_library11CImgDisplay6resizeEiib]+0x208): undefined reference to XResizeWindow'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay6resizeEiib[_ZN12cimg_library11CImgDisplay6resizeEiib]+0x227): undefined reference toXGetWindowAttributes'
/tmp/ccRIIPim.o: In function cimg_library::CImgDisplay::move(int, int)':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay4moveEii[_ZN12cimg_library11CImgDisplay4moveEii]+0x72): undefined reference toXMoveWindow'
/tmp/ccRIIPim.o: In function 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 toXCreateImage'
/tmp/ccRIIPim.o: In function 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 toXCreateImage'
/tmp/ccRIIPim.o: In function 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 toXCreateImage'
/tmp/ccRIIPim.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*)':
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 toboost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry const&, std::__cxx11::basic_string, std::allocator >&)'
collect2: error: ld returned 1 exit status
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;
}
I need to use ZBar libs for my own c++ program, but I can't even compile the examples.
It looks like the compiler can't find the object files or something like that,
I get errors like "undefined reference to `_zbar_get_error_code'".
I copied from their wiki the following source:
#include <iostream>
#include <zbar.h>
using namespace std;
using namespace zbar;
class MyHandler : public Image::Handler
{
void image_callback (Image &image)
{
for(SymbolIterator symbol = image.symbol_begin();
symbol != image.symbol_end();
++symbol)
cout << "decoded " << symbol->get_type_name() << " symbol "
<< "\"" << symbol->get_data() << "\"" << endl;
}
};
int main (int argc, char **argv)
{
const char *device = "/dev/video0";
if(argc > 1)
device = argv[1];
Processor proc(true, device);
proc.set_config(ZBAR_NONE, ZBAR_CFG_ENABLE, 1);
MyHandler my_handler;
proc.set_handler(my_handler);
proc.set_visible();
proc.set_active();
try {
proc.user_wait();
}
catch(ClosedError &e) {
}
return(0);
}
and I try to compile it with the shell command (copied from their wiki)
g++ -o processor -lzbar processor.cpp
and here are the errors i get:
/tmp/ccex0UN8.o: In function `zbar::throw_exception(void const*)':
scan.cpp:(.text+0xe): undefined reference to `_zbar_get_error_code'
/tmp/ccex0UN8.o: In function `zbar::Exception::what() const':
scan.cpp:(.text._ZNK4zbar9Exception4whatEv[zbar::Exception::what() const]+0x29): undefined reference to `_zbar_error_string'
/tmp/ccex0UN8.o: In function `zbar::SymbolSet::ref(int) const':
scan.cpp:(.text._ZNK4zbar9SymbolSet3refEi[zbar::SymbolSet::ref(int) const]+0x1f): undefined reference to `zbar_symbol_set_ref'
/tmp/ccex0UN8.o: In function `zbar::Symbol::ref(int) const':
scan.cpp:(.text._ZNK4zbar6Symbol3refEi[zbar::Symbol::ref(int) const]+0x1f): undefined reference to `zbar_symbol_ref'
/tmp/ccex0UN8.o: In function `zbar::Symbol::get_type_name() const':
scan.cpp:(.text._ZNK4zbar6Symbol13get_type_nameEv[zbar::Symbol::get_type_name() const]+0x1c): undefined reference to `zbar_get_symbol_name'
/tmp/ccex0UN8.o: In function `zbar::Symbol::init(zbar::zbar_symbol_s const*)':
scan.cpp:(.text._ZN4zbar6Symbol4initEPKNS_13zbar_symbol_sE[zbar::Symbol::init(zbar::zbar_symbol_s const*)]+0x1c): undefined reference to `zbar_symbol_get_type'
scan.cpp:(.text._ZN4zbar6Symbol4initEPKNS_13zbar_symbol_sE[zbar::Symbol::init(zbar::zbar_symbol_s const*)]+0x3a): undefined reference to `zbar_symbol_get_data_length'
scan.cpp:(.text._ZN4zbar6Symbol4initEPKNS_13zbar_symbol_sE[zbar::Symbol::init(zbar::zbar_symbol_s const*)]+0x47): undefined reference to `zbar_symbol_get_data'
/tmp/ccex0UN8.o: In function `zbar::SymbolIterator::SymbolIterator(zbar::SymbolSet const&)':
scan.cpp:(.text._ZN4zbar14SymbolIteratorC2ERKNS_9SymbolSetE[_ZN4zbar14SymbolIteratorC5ERKNS_9SymbolSetE]+0x55): undefined reference to `zbar_symbol_set_first_symbol'
/tmp/ccex0UN8.o: In function `zbar::SymbolIterator::SymbolIterator(zbar::SymbolIterator const&)':
scan.cpp:(.text._ZN4zbar14SymbolIteratorC2ERKS0_[_ZN4zbar14SymbolIteratorC5ERKS0_]+0x55): undefined reference to `zbar_symbol_set_first_symbol'
/tmp/ccex0UN8.o: In function `zbar::SymbolIterator::operator++()':
scan.cpp:(.text._ZN4zbar14SymbolIteratorppEv[zbar::SymbolIterator::operator++()]+0x24): undefined reference to `zbar_symbol_next'
scan.cpp:(.text._ZN4zbar14SymbolIteratorppEv[zbar::SymbolIterator::operator++()]+0x57): undefined reference to `zbar_symbol_set_first_symbol'
/tmp/ccex0UN8.o: In function `zbar::Image::Handler::_cb(zbar::zbar_image_s*, void const*)':
scan.cpp:(.text._ZN4zbar5Image7Handler3_cbEPNS_12zbar_image_sEPKv[zbar::Image::Handler::_cb(zbar::zbar_image_s*, void const*)]+0x13): undefined reference to `zbar_image_get_userdata'
/tmp/ccex0UN8.o: In function `zbar::Image::get_symbols() const':
scan.cpp:(.text._ZNK4zbar5Image11get_symbolsEv[zbar::Image::get_symbols() const]+0xf): undefined reference to `zbar_image_get_symbols'
/tmp/ccex0UN8.o: In function `zbar::Processor::Processor(bool, char const*, bool)':
scan.cpp:(.text._ZN4zbar9ProcessorC2EbPKcb[_ZN4zbar9ProcessorC5EbPKcb]+0x1b): undefined reference to `zbar_processor_create'
/tmp/ccex0UN8.o: In function `zbar::Processor::~Processor()':
scan.cpp:(.text._ZN4zbar9ProcessorD2Ev[_ZN4zbar9ProcessorD5Ev]+0xf): undefined reference to `zbar_processor_destroy'
/tmp/ccex0UN8.o: In function `zbar::Processor::init(char const*, bool)':
scan.cpp:(.text._ZN4zbar9Processor4initEPKcb[zbar::Processor::init(char const*, bool)]+0x24): undefined reference to `zbar_processor_init'
/tmp/ccex0UN8.o: In function `zbar::Processor::set_handler(zbar::Image::Handler&)':
scan.cpp:(.text._ZN4zbar9Processor11set_handlerERNS_5Image7HandlerE[zbar::Processor::set_handler(zbar::Image::Handler&)]+0x25): undefined reference to `zbar_processor_set_data_handler'
/tmp/ccex0UN8.o: In function `zbar::Processor::set_config(zbar::zbar_symbol_type_e, zbar::zbar_config_e, int)':
scan.cpp:(.text._ZN4zbar9Processor10set_configENS_18zbar_symbol_type_eENS_13zbar_config_eEi[zbar::Processor::set_config(zbar::zbar_symbol_type_e, zbar::zbar_config_e, int)]+0x24): undefined reference to `zbar_processor_set_config'
/tmp/ccex0UN8.o: In function `zbar::Processor::set_visible(bool)':
scan.cpp:(.text._ZN4zbar9Processor11set_visibleEb[zbar::Processor::set_visible(bool)]+0x1d): undefined reference to `zbar_processor_set_visible'
/tmp/ccex0UN8.o: In function `zbar::Processor::set_active(bool)':
scan.cpp:(.text._ZN4zbar9Processor10set_activeEb[zbar::Processor::set_active(bool)]+0x1d): undefined reference to `zbar_processor_set_active'
/tmp/ccex0UN8.o: In function `zbar::Processor::user_wait(int)':
scan.cpp:(.text._ZN4zbar9Processor9user_waitEi[zbar::Processor::user_wait(int)]+0x16): undefined reference to `zbar_processor_user_wait'
collect2: ld returned 1 exit status
I'm using Ubuntu 12.04, installed build-essential and libzbar-dev
PS: I choosed ZBar over ZXing cause from the already compiled examples it detects much more QR-Codes (eg more inclinated, smaller, with more noise etc...)
You could try:
g++ -o processor processor.cpp -lzbar
I have been trying to build c++ boost to work with qt creator but until now all what i get is undefined reference to different things things so here is what I did so far:-
I build c++ boost by running bootstrap.bat then bjam
I include the path in my qt creator .pro project
like this
QT += core gui
TARGET = Heap
TEMPLATE = app
INCLUDEPATH += C:\boost\boost_1_48_0
LIBS += -L"C:/boost/boost_1_48_0/stage/lib"
SOURCES += \
main.cpp
HEADERS += \
clss.h \
inputstream.h \
outputstream.h \
myexception.h \
heaptest.h \
comparable.h \
heap.h
FORMS +=
here is my sample code I am testing on
#include <boost/regex.hpp>
#include <iostream>
#include <string>
int main()
{
std::string line;
boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );
while (std::cin)
{
std::getline(std::cin, line);
boost::smatch matches;
if (boost::regex_match(line, matches, pat))
std::cout << matches[2] << std::endl;
}
}
and here is the compilation error I get
debug/main.o: In function `cpp_regex_traits_char_layer':
C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/cpp_regex_traits.hpp:366: undefined reference to `boost::re_detail::cpp_regex_traits_char_layer<char>::init()'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/regex_raw_buffer.hpp:131: undefined reference to `boost::re_detail::raw_storage::resize(unsigned int)'
debug/main.o: In function `save_state_init':
C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/perl_matcher_non_recursive.hpp:107: undefined reference to `boost::re_detail::get_mem_block()'
debug/main.o: In function `~save_state_init':
C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/perl_matcher_non_recursive.hpp:115: undefined reference to `boost::re_detail::put_mem_block(void*)'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/perl_matcher_common.hpp:206: undefined reference to `boost::re_detail::verify_options(unsigned int, boost::regex_constants::_match_flags)'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/perl_matcher_non_recursive.hpp:1117: undefined reference to `boost::re_detail::put_mem_block(void*)'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/pattern_except.hpp:75: undefined reference to `boost::re_detail::raise_runtime_error(std::runtime_error const&)'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_parser.hpp:218: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_parser.hpp:219: undefined reference to `boost::regex_error::raise() const'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_parser.hpp:219: undefined reference to `boost::regex_error::~regex_error()'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_parser.hpp:219: undefined reference to `boost::regex_error::~regex_error()'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:798: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:799: undefined reference to `boost::regex_error::raise() const'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:799: undefined reference to `boost::regex_error::~regex_error()'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:799: undefined reference to `boost::regex_error::~regex_error()'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:880: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:881: undefined reference to `boost::regex_error::raise() const'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:881: undefined reference to `boost::regex_error::~regex_error()'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:881: undefined reference to `boost::regex_error::~regex_error()'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:945: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:946: undefined reference to `boost::regex_error::raise() const'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:946: undefined reference to `boost::regex_error::~regex_error()'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:946: undefined reference to `boost::regex_error::~regex_error()'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:1148: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:1149: undefined reference to `boost::regex_error::raise() const'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:1149: undefined reference to `boost::regex_error::~regex_error()'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:1149: undefined reference to `boost::regex_error::~regex_error()'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/perl_matcher_non_recursive.hpp:213: undefined reference to `boost::re_detail::get_mem_block()'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/cpp_regex_traits.hpp:442: undefined reference to `boost::re_detail::get_default_error_string(boost::regex_constants::error_type)'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/cpp_regex_traits.hpp:444: undefined reference to `boost::re_detail::get_default_error_string(boost::regex_constants::error_type)'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:321: undefined reference to `boost::re_detail::raw_storage::insert(unsigned int, unsigned int)'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/pending/object_cache.hpp:66: undefined reference to `boost::scoped_static_mutex_lock::scoped_static_mutex_lock(boost::static_mutex&, bool)'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/pending/object_cache.hpp:75: undefined reference to `boost::scoped_static_mutex_lock::~scoped_static_mutex_lock()'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/pending/object_cache.hpp:75: undefined reference to `boost::scoped_static_mutex_lock::~scoped_static_mutex_lock()'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/cpp_regex_traits.hpp:633: undefined reference to `boost::re_detail::lookup_default_collate_name(std::string const&)'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/cpp_regex_traits.hpp:675: undefined reference to `boost::re_detail::raise_runtime_error(std::runtime_error const&)'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/cpp_regex_traits.hpp:690: undefined reference to `boost::re_detail::get_default_error_string(boost::regex_constants::error_type)'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/cpp_regex_traits.hpp:1059: undefined reference to `boost::scoped_static_mutex_lock::scoped_static_mutex_lock(boost::static_mutex&, bool)'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/cpp_regex_traits.hpp:1062: undefined reference to `boost::scoped_static_mutex_lock::~scoped_static_mutex_lock()'
debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/cpp_regex_traits.hpp:1062: undefined reference to `boost::scoped_static_mutex_lock::~scoped_static_mutex_lock()'
collect2: ld returned 1 exit status
mingw32-make.exe[1]: *** [debug/Heap.exe] Error 1
mingw32-make.exe: *** [debug] Error 2
16:05:31: The process "C:\Qt\qtcreator-2.4.0\mingw\bin\mingw32-make.exe" exited with code 2.
Error while building project Heap (target: Desktop)
When executing build step 'Make'
How can I get this to build?
Try changing the LIBS += -L"C:/boost/boost_1_48_0/stage/lib" line to:
LIBS += -L"C:/boost/boost_1_48_0/stage/lib" -lboost_regex
(replace boost_regex with the actual name of the built library (which will probably be something like boost_regex-mgw44-mt-1_48))
I have written below code using C++ Object Interface provided by IBM. I am trying to compile that on RHEL (Linux):
#include <it.h>
#include <iostream.h>
int main() {
ITDBInfo db("dbname","user","pwd","system");
ITConnection conn(db);
conn.Open();
if ( conn.Error() ) {
cout << "Couldn't open connection" << endl;
return -1;
}
ITQuery query( conn );
ITRow *row;
if( !(row = query.ExecOneRow( "select lname from customer;" )) ) {
cout << "Couldn't select from table customer" << endl;
return -1;
}
while ((row = query.NextRow()) != NULL) {
cout << row->Printable() << endl;
}
row->Release();
conn.Close();
}
While compiling on Linux like this:
g++ -Wno-deprecated -I/opt/Informix/11.5FC8/incl/c++ \
-I/opt/Informix/11.5FC8/incl/public \
-L/opt/Informix/11.5FC8/lib/c++ -g -o test1 test1.cpp
I am getting the errors shown below:
/tmp/cchJkPb1.o: In function `main':
test1.cpp:(.text+0x82): undefined reference to `ITString::ITString(char const*)'
test1.cpp:(.text+0x90): undefined reference to `ITString::ITString(char const*)'
test1.cpp:(.text+0x9e): undefined reference to `ITString::ITString(char const*)'
test1.cpp:(.text+0xac): undefined reference to `ITString::ITString(char const*)'
test1.cpp:(.text+0xc8): undefined reference to `ITDBInfo::ITDBInfo(ITString const&, ITString const&, ITString const&, ITString const&)'
test1.cpp:(.text+0xd1): undefined reference to `ITString::~ITString()'
test1.cpp:(.text+0xea): undefined reference to `ITString::~ITString()'
test1.cpp:(.text+0xfc): undefined reference to `ITString::~ITString()'
test1.cpp:(.text+0x115): undefined reference to `ITString::~ITString()'
test1.cpp:(.text+0x127): undefined reference to `ITString::~ITString()'
/tmp/cchJkPb1.o:test1.cpp:(.text+0x140): more undefined references to `ITString::~ITString()' follow
/tmp/cchJkPb1.o: In function `main':
test1.cpp:(.text+0x15f): undefined reference to `ITConnection::ITConnection(ITDBInfo const&)'
test1.cpp:(.text+0x178): undefined reference to `ITString::~ITString()'
test1.cpp:(.text+0x194): undefined reference to `ITConnection::Open()'
test1.cpp:(.text+0x19d): undefined reference to `ITErrorManager::Error() const'
test1.cpp:(.text+0x1e6): undefined reference to `ITQuery::ITQuery(ITConnection const&)'
test1.cpp:(.text+0x1f4): undefined reference to `ITString::ITString(char const*)'
test1.cpp:(.text+0x209): undefined reference to `ITQuery::ExecOneRow(ITString const&, ITEssential**)'
test1.cpp:(.text+0x222): undefined reference to `ITString::~ITString()'
test1.cpp:(.text+0x23b): undefined reference to `ITString::~ITString()'
test1.cpp:(.text+0x2a6): undefined reference to `operator<<(std::basic_ostream<char, std::char_traits<char> >&, ITString const&)'
test1.cpp:(.text+0x2c4): undefined reference to `ITQuery::NextRow(ITEssential**)'
test1.cpp:(.text+0x2f1): undefined reference to `ITConnection::Close()'
test1.cpp:(.text+0x317): undefined reference to `ITQuery::~ITQuery()'
test1.cpp:(.text+0x32c): undefined reference to `ITQuery::~ITQuery()'
test1.cpp:(.text+0x366): undefined reference to `ITConnection::~ITConnection()'
test1.cpp:(.text+0x378): undefined reference to `ITConnection::~ITConnection()'
test1.cpp:(.text+0x3b2): undefined reference to `ITDBInfo::~ITDBInfo()'
test1.cpp:(.text+0x3ce): undefined reference to `ITDBInfo::~ITDBInfo()'
collect2: ld returned 1 exit status
The directory /opt/Informix/11.5FC8/lib/c++ is listed in LD_LIBRARY_PATH. Can anyone help me to get rid of these errors?
You are not actually linking with the library using the -l command line parameter. The -L command line parameter tells the linker where to look to find it, but you don't specify the actual library.
Also LD_LIBRARY_PATH is used during runtime, but a better way to configure a non-standard directory is to configure the dynamic linker using /etc/ld.so.conf or a file in /etc/ld.so.conf.d/.