while compiling my cpp program for pop os using 7-zip lzma sdk i encounter the following errors
/usr/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000001410
/usr/bin/ld: Aes.o: in function 'AesGenTables':
/home/hitesh/lzma2201/C/Aes.c:130: undefined reference to 'AesCbc_Decode_HW'
/usr/bin/ld: /home/hitesh/lzma2201/C/Aes.c:133: undefined reference to 'AesCbc_Encode_HW'
/usr/bin/ld: /home/hitesh/lzma2201/C/Aes.c:134: undefined reference to 'AesCtr_Code_HW'
/usr/bin/ld: /home/hitesh/lzma2201/C/Aes.c:142: undefined reference to 'AesCbc_Decode_HW_256'
/usr/bin/ld: /home/hitesh/lzma2201/C/Aes.c:144: undefined reference to 'AesCtr_Code_HW_256'
/usr/bin/ld: LzFindMt.o: in function 'BtGetMatches(_CMatchFinderMt*, unsigned int*)':
/home/hitesh/lzma2201/C/LzFindMt.c:686: undefined reference to 'GetMatchesSpecN_2(unsigned char const*, unsigned long, unsigned char const*, unsigned int*, unsigned int, unsigned int*, unsigned long, unsigned int const*, unsigned int const*, unsigned int const*, unsigned long, unsigned int, unsigned int*)'
/usr/bin/ld: Sha256.o: in function 'Sha256Prepare':
/home/hitesh/lzma2201/C/Sha256.c:481: undefined reference to 'Sha256_UpdateBlocks_HW(unsigned int*, unsigned char const*, unsigned long)'
collect2: error: ld returned 1 exit status
here is the script used to compile the program.
run2.sh
for FILE in $(ls "/home/hitesh/lzma2201/C" | egrep '\.c$');
do
g++ -Wall -std=c++14 -g -c -D_7ZIP_ST -I"/home/hitesh/lzma2201/C" "/home/hitesh/lzma2201/C/"$FILE ;
done
g++ -std=c++14 -Wall -nostartfiles -g 7zAlloc.o 7zArcIn.o 7zBuf.o 7zBuf2.o 7zCrc.o 7zCrcOpt.o 7zDec.o 7zFile.o 7zStream.o Aes.o AesOpt.o Alloc.o Bcj2.o Bcj2Enc.o Bra.o Bra86.o BraIA64.o CpuArch.o Delta.o DllSecur.o LzFind.o LzFindMt.o Lzma2Dec.o Lzma2DecMt.o Lzma2Enc.o Lzma86Dec.o Lzma86Enc.o LzmaDec.o LzmaEnc.o LzmaLib.o MtCoder.o MtDec.o Ppmd7.o Ppmd7Dec.o Ppmd7Enc.o Sha256.o Sort.o Threads.o Xz.o XzCrc64.o XzCrc64Opt.o XzDec.o XzEnc.o XzIn.o -o compress -L"/home/hitesh/lzma2201/C"
I have tried using another versions of lzma sdk but that was resulting in different errors. I expected the program to run as it was running when i originally wrote the script in .c file for windows
Related
I want to compile a simple server app using nghtt2_asio in C++.
It compiles perfectly under shared libraries:
g++ server.cpp -O2 -std=c++20 -Wall -Wextra -lnghttp2_asio -lboost_system -lssl -lcrypto -o server
But as I compile it statically:
g++ server.cpp -static -O2 -std=c++20 -Wall -Wextra -o server -lssl -ldl -pthread -lcrypto -ldl -pthread -lnghttp2_asio -lboost_system
the linker gives me these errors:
/usr/bin/ld: /usr/local/lib/libcrypto.a(dso_dlfcn.o): in function `dlfcn_globallookup':
(.text+0x14): attenzione: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/local/lib/libcrypto.a(b_addr.o): in function `BIO_lookup_ex':
(.text+0xd0b): attenzione: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/local/lib/libcrypto.a(b_sock.o): in function `BIO_gethostbyname':
(.text+0x72): attenzione: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/local/lib/libnghttp2_asio.a(libnghttp2_asio_la-asio_common.o): in function `nghttp2::asio_http2::nghttp2_category_impl::message[abi:cxx11](int) const':
/home/user/Downloads/nghttp2/src/asio_common.cc:40: undefined reference to `nghttp2_strerror'
/usr/bin/ld: /usr/local/lib/libnghttp2_asio.a(libnghttp2_asio_la-asio_server.o): in function `int nghttp2::asio_http2::server::http2_handler::on_read<8192ul>(boost::array<unsigned char, 8192ul> const&, unsigned long)':
/home/user/Downloads/nghttp2/src/asio_server_http2_handler.h:103: undefined reference to `nghttp2_session_mem_recv'
/usr/bin/ld: /usr/local/lib/libnghttp2_asio.a(libnghttp2_asio_la-asio_server.o): in function `boost::asio::ssl::detail::engine::engine(ssl_ctx_st*)':
/usr/include/boost/asio/ssl/detail/impl/engine.ipp:55: undefined reference to `BIO_new_bio_pair'
/usr/bin/ld: /usr/local/lib/libnghttp2_asio.a(libnghttp2_asio_la-asio_server.o): in function `int nghttp2::asio_http2::server::http2_handler::on_write<65536ul>(boost::array<unsigned char, 65536ul>&, unsigned long&)':
/home/user/Downloads/nghttp2/src/asio_server_http2_handler.h:129: undefined reference to `nghttp2_session_mem_send'
/usr/bin/ld: /usr/local/lib/libnghttp2_asio.a(libnghttp2_asio_la-asio_server.o): in function `int nghttp2::asio_http2::server::http2_handler::on_read<8192ul>(boost::array<unsigned char, 8192ul> const&, unsigned long)':
/home/user/Downloads/nghttp2/src/asio_server_http2_handler.h:103: undefined reference to `nghttp2_session_mem_recv'
/usr/bin/ld: /usr/local/lib/libnghttp2_asio.a(libnghttp2_asio_la-asio_server.o): in function `int nghttp2::asio_http2::server::http2_handler::on_write<65536ul>(boost::array<unsigned char, 65536ul>&, unsigned long&)':
/home/user/Downloads/nghttp2/src/asio_server_http2_handler.h:129: undefined reference to `nghttp2_session_mem_send'
/usr/bin/ld: /usr/local/lib/libnghttp2_asio.a(libnghttp2_asio_la-asio_server.o): in function `int nghttp2::asio_http2::server::http2_handler::on_read<8192ul>(boost::array<unsigned char, 8192ul> const&, unsigned long)':
/home/user/Downloads/nghttp2/src/asio_server_http2_handler.h:103: undefined reference to `nghttp2_session_mem_recv'
/usr/bin/ld: /usr/local/lib/libnghttp2_asio.a(libnghttp2_asio_la-asio_server_http2_handler.o): in function `nghttp2::asio_http2::server::(anonymous namespace)::on_frame_not_send_callback(nghttp2_session*, nghttp2_frame const*, int, void*)':
/home/user/Downloads/nghttp2/src/asio_server_http2_handler.cc:230: undefined reference to `nghttp2_submit_rst_stream'
/usr/bin/ld: /usr/local/lib/libnghttp2_asio.a(libnghttp2_asio_la-asio_server_http2_handler.o): in function `nghttp2::asio_http2::server::http2_handler::~http2_handler()':
/home/user/Downloads/nghttp2/src/asio_server_http2_handler.cc:258: undefined reference to `nghttp2_session_del'
/usr/bin/ld: /usr/local/lib/libnghttp2_asio.a(libnghttp2_asio_la-asio_server_http2_handler.o): in function `nghttp2::asio_http2::server::http2_handler::start()':
/home/user/Downloads/nghttp2/src/asio_server_http2_handler.cc:274: undefined reference to `nghttp2_session_callbacks_new'
/usr/bin/ld: /usr/local/lib/libnghttp2_asio.a(libnghttp2_asio_la-asio_server_http2_handler.o): in function `std::_Bind<void (*(nghttp2_session_callbacks*))(nghttp2_session_callbacks*)>::_Bind(std::_Bind<void (*(nghttp2_session_callbacks*))(nghttp2_session_callbacks*)>&&)':
/usr/include/c++/11.1.0/functional:494: undefined reference to `nghttp2_session_callbacks_del'
/usr/bin/ld: /usr/local/lib/libnghttp2_asio.a(libnghttp2_asio_la-asio_server_http2_handler.o): in function `nghttp2::asio_http2::server::http2_handler::start()':
/home/user/Downloads/nghttp2/src/asio_server_http2_handler.cc:281: undefined reference to `nghttp2_session_callbacks_set_on_begin_headers_callback'
/usr/bin/ld: /home/user/Downloads/nghttp2/src/asio_server_http2_handler.cc:283: undefined reference to `nghttp2_session_callbacks_set_on_header_callback'
/usr/bin/ld: /home/user/Downloads/nghttp2/src/asio_server_http2_handler.cc:285: undefined reference to `nghttp2_session_callbacks_set_on_frame_recv_callback'
/usr/bin/ld: /home/user/Downloads/nghttp2/src/asio_server_http2_handler.cc:287: undefined reference to `nghttp2_session_callbacks_set_on_data_chunk_recv_callback'
/usr/bin/ld: /home/user/Downloads/nghttp2/src/asio_server_http2_handler.cc:289: undefined reference to `nghttp2_session_callbacks_set_on_stream_close_callback'
/usr/bin/ld: /home/user/Downloads/nghttp2/src/asio_server_http2_handler.cc:291: undefined reference to `nghttp2_session_callbacks_set_on_frame_send_callback'
/usr/bin/ld: /home/user/Downloads/nghttp2/src/asio_server_http2_handler.cc:293: undefined reference to `nghttp2_session_callbacks_set_on_frame_not_send_callback'
/usr/bin/ld: /home/user/Downloads/nghttp2/src/asio_server_http2_handler.cc:296: undefined reference to `nghttp2_session_server_new'
/usr/bin/ld: /home/user/Downloads/nghttp2/src/asio_server_http2_handler.cc:302: undefined reference to `nghttp2_submit_settings'
/usr/bin/ld: /usr/local/lib/libnghttp2_asio.a(libnghttp2_asio_la-asio_server_http2_handler.o): in function `nghttp2::asio_http2::server::http2_handler::should_stop() const':
/home/user/Downloads/nghttp2/src/asio_server_http2_handler.cc:333: undefined reference to `nghttp2_session_want_read'
/usr/bin/ld: /home/user/Downloads/nghttp2/src/asio_server_http2_handler.cc:334: undefined reference to `nghttp2_session_want_write'
/usr/bin/ld: /usr/local/lib/libnghttp2_asio.a(libnghttp2_asio_la-asio_server_http2_handler.o): in function `nghttp2::asio_http2::server::http2_handler::stream_error(int, unsigned int)':
/home/user/Downloads/nghttp2/src/asio_server_http2_handler.cc:47: undefined reference to `nghttp2_submit_rst_stream'
/usr/bin/ld: /usr/local/lib/libnghttp2_asio.a(libnghttp2_asio_la-asio_server_http2_handler.o): in function `nghttp2::asio_http2::server::http2_handler::resume(nghttp2::asio_http2::server::stream&)':
/home/user/Downloads/nghttp2/src/asio_server_http2_handler.cc:428: undefined reference to `nghttp2_session_resume_data'
/usr/bin/ld: /usr/local/lib/libnghttp2_asio.a(libnghttp2_asio_la-asio_server_http2_handler.o): in function `nghttp2::asio_http2::server::(anonymous namespace)::on_header_callback(nghttp2_session*, nghttp2_frame const*, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char, void*)':
/home/user/Downloads/nghttp2/src/asio_server_http2_handler.cc:109: undefined reference to `nghttp2_submit_rst_stream'
/usr/bin/ld: /usr/local/lib/libnghttp2_asio.a(libnghttp2_asio_la-asio_server_http2_handler.o): in function `nghttp2::asio_http2::server::http2_handler::submit_trailer(nghttp2::asio_http2::server::stream&, std::multimap<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nghttp2::asio_http2::header_value, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, nghttp2::asio_http2::header_value> > >)':
/home/user/Downloads/nghttp2/src/asio_server_http2_handler.cc:387: undefined reference to `nghttp2_submit_trailer'
/usr/bin/ld: /usr/local/lib/libnghttp2_asio.a(libnghttp2_asio_la-asio_server_http2_handler.o): in function `nghttp2::asio_http2::server::http2_handler::start_response(nghttp2::asio_http2::server::stream&)':
/home/user/Downloads/nghttp2/src/asio_server_http2_handler.cc:366: undefined reference to `nghttp2_submit_response'
/usr/bin/ld: /usr/local/lib/libnghttp2_asio.a(libnghttp2_asio_la-asio_server_http2_handler.o): in function `nghttp2::asio_http2::server::http2_handler::push_promise(boost::system::error_code&, nghttp2::asio_http2::server::stream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::multimap<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nghttp2::asio_http2::header_value, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, nghttp2::asio_http2::header_value> > >)':
/home/user/Downloads/nghttp2/src/asio_server_http2_handler.cc:454: undefined reference to `nghttp2_submit_push_promise'
/usr/bin/ld: /usr/local/lib/libnghttp2_asio.a(libnghttp2_asio_la-http2.o): in function `nghttp2::http2::determine_window_update_transmission(nghttp2_session*, int)':
/home/user/Downloads/nghttp2/src/http2.cc:577: undefined reference to `nghttp2_session_get_effective_recv_data_length'
/usr/bin/ld: /home/user/Downloads/nghttp2/src/http2.cc:578: undefined reference to `nghttp2_session_get_effective_local_window_size'
/usr/bin/ld: /home/user/Downloads/nghttp2/src/http2.cc:580: undefined reference to `nghttp2_session_get_stream_effective_recv_data_length'
/usr/bin/ld: /home/user/Downloads/nghttp2/src/http2.cc:582: undefined reference to `nghttp2_session_get_stream_effective_local_window_size'
/usr/bin/ld: /usr/local/lib/libnghttp2_asio.a(libnghttp2_asio_la-http2.o): in function `nghttp2::http2::check_nv(unsigned char const*, unsigned long, unsigned char const*, unsigned long)':
/home/user/Downloads/nghttp2/src/http2.cc:698: undefined reference to `nghttp2_check_header_name'
/usr/bin/ld: /home/user/Downloads/nghttp2/src/http2.cc:701: undefined reference to `nghttp2_check_header_value'
collect2: error: ld returned 1 exit status
Can someone explain me what happens?
Can someone explain me what happens?
There are several problems here.
You have unresolved symbols. As n.m. said in a comment, you need to add -libnghttp2.
Your order of libraries on the link line is wrong. Lower-level libraries should follow higher-level libraries on the link line. The right order is something like:
-lnghttp2_asio -libnghttp2 -lboost_system -lssl -lcrypto -ldl
See this blog post for explanation.
You are linking a fully-static binary.
Contrary to popular belief, such binaries (at least on Linux) are significantly less portable than dynamically linked ones.
What the warning is telling you is that IF you try to run this binary on a system that has a different version of GLIBC installed (could be a different system from the one you built on, or even the same system but after an upgrade to a different version of GLIBC), then your binary may crash (and very likely will crash).
You will be much better off not doing a fully-static link.
Note: you don't have to link against libnghttp2_asio etc. dynamically, just against the libc and libdl and libcrypto.
I tried to use Jellyfish, a bioinformatics software. Everything went well in [make] and [make install]. The executable bin file also works. What I want is to compile my own code against the Jellyfish include files and the shared libraries.
I tried to compile the following simple code, which is very simple, with only one declaration of hash_counter.
#include <iostream>
#include <jellyfish/mer_dna.hpp>
#include <jellyfish/hash_counter.hpp>
typedef jellyfish::cooperative::hash_counter<jellyfish::mer_dna> mer_hash_type;
int main(int argc, char *argv[]) {
jellyfish::mer_dna::k(25); // Set length of mers (k=25)
const uint64_t hash_size = 10000000; // Initial size of hash.
const uint32_t num_reprobes = 126;
const uint32_t num_threads = 16; // Number of concurrent threads
const uint32_t counter_len = 7; // Minimum length of counting field
const bool canonical = true; // Use canonical representation
// create the hash
mer_hash_type mer_hash(hash_size, jellyfish::mer_dna::k()*2, counter_len, num_threads, num_reprobes);
return 0;
}
This code can be successfully compiled on Mac using the command below
$g++ -std=c++11 -I/home/jellyfish_lib/include/jellyfish-2.2.5 -L/home/jellyfish_lib/lib -lpthread -ljellyfish-2.0 test.c -o test
but failed when compiled on Ubuntu (with g++ 4.9), with the following error,
/tmp/ccKzjmVq.o: In function `main':
test.c:(.text+0x56): undefined reference to `jellyfish::quadratic_reprobes'
/tmp/ccKzjmVq.o: In function `jellyfish::random_bits()':
test.c:(.text._ZN9jellyfish11random_bitsEv[_ZN9jellyfish11random_bitsEv]+0xa): undefined reference to `jellyfish::random_bits(int)'
/tmp/ccKzjmVq.o: In function `allocators::mmap::~mmap()':
test.c:(.text._ZN10allocators4mmapD2Ev[_ZN10allocators4mmapD5Ev]+0x14): undefined reference to `allocators::mmap::free()'
/tmp/ccKzjmVq.o: In function `jellyfish::RectangularBinaryMatrix::RectangularBinaryMatrix(unsigned int, unsigned int)':
test.c:(.text._ZN9jellyfish23RectangularBinaryMatrixC2Ejj[_ZN9jellyfish23RectangularBinaryMatrixC5Ejj]+0x1d): undefined reference to `jellyfish::RectangularBinaryMatrix::alloc(unsigned int, unsigned int)'
/tmp/ccKzjmVq.o: In function `jellyfish::RectangularBinaryMatrix::RectangularBinaryMatrix(jellyfish::RectangularBinaryMatrix const&)':
test.c:(.text._ZN9jellyfish23RectangularBinaryMatrixC2ERKS0_[_ZN9jellyfish23RectangularBinaryMatrixC5ERKS0_]+0x23): undefined reference to `jellyfish::RectangularBinaryMatrix::alloc(unsigned int, unsigned int)'
/tmp/ccKzjmVq.o: In function `jellyfish::RectangularBinaryMatrix::randomize_pseudo_inverse()':
test.c:(.text._ZN9jellyfish23RectangularBinaryMatrix24randomize_pseudo_inverseEv[_ZN9jellyfish23RectangularBinaryMatrix24randomize_pseudo_inverseEv]+0x24): undefined reference to `jellyfish::RectangularBinaryMatrix::randomize_pseudo_inverse(unsigned long (*)())'
/tmp/ccKzjmVq.o: In function `jellyfish::locks::pthread::barrier::barrier(unsigned int)':
test.c:(.text._ZN9jellyfish5locks7pthread7barrierC2Ej[_ZN9jellyfish5locks7pthread7barrierC5Ej]+0x1f): undefined reference to `pthread_barrier_init'
/tmp/ccKzjmVq.o: In function `jellyfish::locks::pthread::barrier::~barrier()':
test.c:(.text._ZN9jellyfish5locks7pthread7barrierD2Ev[_ZN9jellyfish5locks7pthread7barrierD5Ev]+0x14): undefined reference to `pthread_barrier_destroy'
/tmp/ccKzjmVq.o: In function `jellyfish::large_hash::array_base<jellyfish::mer_dna_ns::mer_base_static<unsigned long, 0>, unsigned long, atomic::gcc, jellyfish::large_hash::array<jellyfish::mer_dna_ns::mer_base_static<unsigned long, 0>, unsigned long, atomic::gcc, allocators::mmap> >::array_base(unsigned long, unsigned short, unsigned short, unsigned short, jellyfish::RectangularBinaryMatrix, unsigned long const*)':
test.c:(.text._ZN9jellyfish10large_hash10array_baseINS_10mer_dna_ns15mer_base_staticImLi0EEEmN6atomic3gccENS0_5arrayIS4_mS6_N10allocators4mmapEEEEC2EmtttNS_23RectangularBinaryMatrixEPKm[_ZN9jellyfish10large_hash10array_baseINS_10mer_dna_ns15mer_base_staticImLi0EEEmN6atomic3gccENS0_5arrayIS4_mS6_N10allocators4mmapEEEEC5EmtttNS_23RectangularBinaryMatrixEPKm]+0x269): undefined reference to `jellyfish::RectangularBinaryMatrix::pseudo_inverse() const'
/tmp/ccKzjmVq.o: In function `jellyfish::large_hash::array<jellyfish::mer_dna_ns::mer_base_static<unsigned long, 0>, unsigned long, atomic::gcc, allocators::mmap>::alloc_data(unsigned long)':
test.c:(.text._ZN9jellyfish10large_hash5arrayINS_10mer_dna_ns15mer_base_staticImLi0EEEmN6atomic3gccEN10allocators4mmapEE10alloc_dataEm[_ZN9jellyfish10large_hash5arrayINS_10mer_dna_ns15mer_base_staticImLi0EEEmN6atomic3gccEN10allocators4mmapEE10alloc_dataEm]+0x1f): undefined reference to `allocators::mmap::realloc(unsigned long)'
collect2: error: ld returned 1 exit status
It seems something went wrong during linking. Does anyone have experience about this?
I've used the already compiled version of openCV for Raspberry Pi. link for anyone who is interested
After trying to compile using this command line
g++ test3.cpp -o test3 -I/usr/local/include/ -lraspicam -lraspicam_cv -L/opt/vc/lib -lmmal -lmmal_core -lmmal_util -I/usr/include -lopencv_core -lopencv_highgui -lopencv_imgproc -lwiringPi -lpthread
I get the following error lines.
//usr/local/lib/libopencv_stitching.so.2.4: undefined reference to `cv::gpu::ensureSizeIsEnough(int, int, int, cv::gpu::GpuMat&)'
//usr/local/lib/libopencv_calib3d.so.2.4: undefined reference to `cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double)'
//usr/local/lib/libopencv_calib3d.so.2.4: undefined reference to `typeinfo for cv::ParallelLoopBody'
//usr/local/lib/libopencv_calib3d.so.2.4: undefined reference to `cv::Mutex::unlock()'
//usr/local/lib/libopencv_calib3d.so.2.4: undefined reference to `cv::Mutex::lock()'
//usr/local/lib/libopencv_ocl.so.2.4: undefined reference to cv::TLSDataContainer::getData() const
//usr/local/lib/libopencv_features2d.so.2.4: undefined reference to cv::AlgorithmInfo::addParam(cv::Algorithm&, char const*, unsigned char&, bool, unsigned char (cv::Algorithm::)(), void (cv::Algorithm::)(unsigned char), std::basic_string, std::allocator > const&)
//usr/local/lib/libopencv_features2d.so.2.4: undefined reference to `cv::AlgorithmInfo::addParam(cv::Algorithm&, char const*, float&, bool, float (cv::Algorithm::)(), void (cv::Algorithm::)(float), std::basic_string, std::allocator > const&)'
//usr/local/lib/libopencv_features2d.so.2.4: undefined reference to `cv::AlgorithmInfo::addParam(cv::Algorithm&, char const*, short&, bool, int (cv::Algorithm::)(), void (cv::Algorithm::)(int), std::basic_string, std::allocator > const&)'
//usr/local/lib/libopencv_calib3d.so.2.4: undefined reference to `cv::Mutex::Mutex()'
//usr/local/lib/libopencv_ocl.so.2.4: undefined reference to `cv::TLSDataContainer::TLSDataContainer()'
//usr/local/lib/libopencv_calib3d.so.2.4: undefined reference to `cv::ParallelLoopBody::~ParallelLoopBody()'
//usr/local/lib/libopencv_calib3d.so.2.4: undefined reference to `cv::Mutex::~Mutex()'
//usr/local/lib/libopencv_ocl.so.2.4: undefined reference to `cv::TLSDataContainer::~TLSDataContainer()'
collect2: ld returned 1 exit status
You have not linked the executable against several libraries that are required by the program
Try using this:
g++ -lpthread `pkg-config opencv --libs` -I/usr/local/include/ -lraspicam -lraspicam_cv -L/opt/vc/lib -lmmal -lmmal_core -lmmal_util -I/usr/include -lwiringPi test3.cpp -o test3
I am trying to compile The example of Blocking TCP echo client: using the Boost.build b2 command as following:
b2 linkflags=-lpthread toolset=gcc threading=multi link=static
But I am getting the following errors:
gcc.link ../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/lte_sim
../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/Simulator_main.o: In function `boost::asio::detail::socket_ops::getaddrinfo(char const*, char const*, addrinfo const&, addrinfo**, boost::system::error_code&)':
/home/ha/MIH/boost_1_49_0/boost/asio/detail/impl/socket_ops.ipp:2899: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/Simulator_main.o: In function `__static_initialization_and_destruction_0(int, int)':
Simulator_main.cpp:(.text+0x68f): undefined reference to `boost::system::generic_category()'
Simulator_main.cpp:(.text+0x69b): undefined reference to `boost::system::generic_category()'
Simulator_main.cpp:(.text+0x6a7): undefined reference to `boost::system::system_category()'
../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/Simulator_main.o: In function `boost::system::error_code::error_code()':
Simulator_main.cpp:(.text._ZN5boost6system10error_codeC2Ev[_ZN5boost6system10error_codeC5Ev]+0x17): undefined reference to `boost::system::system_category()'
../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/Simulator_main.o: In function `boost::asio::error::get_system_category()':
Simulator_main.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[boost::asio::error::get_system_category()]+0x5): undefined reference to `boost::system::system_category()'
../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/Simulator_main.o: In function `void boost::asio::detail::posix_event::clear<boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex> >(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&)':
Simulator_main.cpp:(.text._ZN5boost4asio6detail11posix_event5clearINS1_11scoped_lockINS1_11posix_mutexEEEEEvRT_[void boost::asio::detail::posix_event::clear<boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex> >(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&)]+0x47): undefined reference to `odtone::crash(odtone::bug, char const*, char const*, unsigned int, char const*)'
../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/Simulator_main.o: In function `void boost::asio::detail::posix_event::wait<boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex> >(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&)':
Simulator_main.cpp:(.text._ZN5boost4asio6detail11posix_event4waitINS1_11scoped_lockINS1_11posix_mutexEEEEEvRT_[void boost::asio::detail::posix_event::wait<boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex> >(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&)]+0x47): undefined reference to `odtone::crash(odtone::bug, char const*, char const*, unsigned int, char const*)'
../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/Simulator_main.o: In function `void boost::asio::detail::posix_event::signal<boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex> >(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&)':
Simulator_main.cpp:(.text._ZN5boost4asio6detail11posix_event6signalINS1_11scoped_lockINS1_11posix_mutexEEEEEvRT_[void boost::asio::detail::posix_event::signal<boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex> >(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&)]+0x47): undefined reference to `odtone::crash(odtone::bug, char const*, char const*, unsigned int, char const*)'
../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/Simulator_main.o: In function `void boost::asio::detail::posix_event::signal_and_unlock<boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex> >(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&)':
Simulator_main.cpp:(.text._ZN5boost4asio6detail11posix_event17signal_and_unlockINS1_11scoped_lockINS1_11posix_mutexEEEEEvRT_[void boost::asio::detail::posix_event::signal_and_unlock<boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex> >(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&)]+0x47): undefined reference to `odtone::crash(odtone::bug, char const*, char const*, unsigned int, char const*)'
collect2: ld returned 1 exit status
"g++" -o "../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/lte_sim" -Wl,--start-group "../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/Simulator_main.o" "/home/ha/MIH/boost_1_49_0/bin.v2/libs/program_options/build/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/libboost_program_options.a" -lrt -Wl,--end-group -g -static -pthread -lpthread
...failed gcc.link ../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/lte_sim...
...skipped <p../../dist>lte_sim for lack of <p../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi>lte_sim...
...failed updating 1 target...
...skipped 1 target..
I already have a JamFile with the contents:
install install
: lte_sim
: <location>../../dist
;
project lte_sim
;
exe lte_sim
: Simulator_main.cpp
/boost//program_options
;
So what is the solution for the problem?
Thanks a lot.
I tried "b2 linkflags=-lboost_system toolset=gcc" and I got the following errors
gcc.link ../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/lte_sim
/usr/bin/ld: cannot find -lboost_system
../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/Simulator_main.o: In function `boost::asio::detail::socket_ops::getaddrinfo(char const*, char const*, addrinfo const&, addrinfo**, boost::system::error_code&)':
/home/ha/MIH/boost_1_49_0/boost/asio/detail/impl/socket_ops.ipp:2899: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: ld returned 1 exit status
"g++" -o "../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/lte_sim" -Wl,--start-group "../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/Simulator_main.o" "/home/ha/MIH/boost_1_49_0/bin.v2/libs/program_options/build/gcc-4.6/debug/link-static/runtime-link-static/libboost_program_options.a" -Wl,--end-group -g -static -lboost_system
...failed gcc.link ../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/lte_sim...
...skipped lte_sim for lack of lte_sim...
...failed updating 1 target...
...skipped 1 target...
So any suggestions?
I am absolutely horrible with compiling/linking.
I have tried everything i could find, nothing works.
websockserver.h:516: undefined reference to `qfs_init'
websockserver.h:527: undefined reference to `qfs_read'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Rmdir(char const*)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Remove(char const*)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Open(char const*, int, int, int, int, int, int, unsigned short, signed char, signed char)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Write(int, char const*, unsigned long)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Read(int, char*, unsigned long)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Rename(char const*, char const*, bool)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Tell(int)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Seek(int, long, int)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Stat(char const*, KFS::KfsFileAttr&, bool)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Close(int)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Create(char const*, int, bool, int, int, int, int, bool, unsigned short, signed char, signed char)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Sync(int)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::IsDirectory(char const*)'
./cqfs//libcqfs.so: undefined reference to `KFS::ErrorCodeToStr(int)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::IsFile(char const*)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Exists(char const*)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Mkdir(char const*, unsigned short)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Readdir(char const*, std::vector<std::string, std::allocator<std::string> >&)'
./cqfs//libcqfs.so: undefined reference to `KFS::Connect(std::string const&, int)'
collect2: error: ld returned 1 exit status
make: *** [w] Error 1
websockserver.h:514 to 530
long numbytes;
struct cqfs *qfs;
if(!qfs_init(&qfs, "127.0.0.1", 20000))
printf("Failed to init qfs connection\n");
int fd = qfs_open(qfs, "APP.js", O_RDONLY);
if(fd < 0)
printf("Error opening file: %s\n", qfs_error(qfs));
numbytes = (long)qfs_seek(qfs, fd, 0L, SEEK_END);
qfs_seek(qfs, fd, 0L, SEEK_SET);
ret = calloc(numbytes + 1, sizeof(char));
if(qfs_read(qfs, fd, ret, numbytes) < 0)
printf("Error reading file: %s\n", qfs_error(qfs));
qfs_close(qfs, fd);
QFS provides .so and .a of
libqfs_client
libqfs_qcdio
libqfs_io
libqfs_common
libqfs_qcrs
How do i build my wrapper (cqfs.cpp, cqfs.h)?
This is my current command:
g++ -Wall -DBOOST_SP_USE_QUICK_ALLOCATOR -shared -o libcqfs.so cqfs.cpp cqfs.h -fPIC -L./libqfs_client.so -L./libqfs_qcdio.so -lpthread -lrt -L./libqfs_io.so -L./libqfs_common.so -L./libqfs_qcdio.so -lpthread -lz -lrt -lboost_regex-mt -lcrypto -L./libqfs_qcrs.so -lc
based on the example application(not library) provided by Quantcast:
c++ -Wall -DBOOST_SP_USE_QUICK_ALLOCATOR -g CMakeFiles/qfssample.dir/qfssample_main.o -o qfssample -rdynamic ../../src/cc/libclient/libqfs_client.a ../../src/cc/qcdio/libqfs_qcdio.a -lpthread -lrt ../../src/cc/kfsio/libqfs_io.a ../../src/cc/common/libqfs_common.a ../../src/cc/qcdio/libqfs_qcdio.a -lpthread -lz -lrt -lboost_regex-mt -lcrypto ../../src/cc/qcrs/libqfs_qcrs.a
.a or .so did not make a difference
It looks like you are incorrectly using the -L argument to g++. The argument of -L should refer to the directory that contains the libraries, rather than directly referencing them.
To demonstrate, I created a simple example with a Connect and Readdir (I've omitted it for brevity, but let me know if you want to see it). Here is the c++ command I crafted to get it to compile and link correctly:
c++ -Wall -o t -I./build/release/include -L./build/release/lib t.cc -lqfs_client -lqfs_common -lqfs_io -lqfs_qcdio -lqfs_qcrs -lpthread -lboost_regex-mt -lz -lcrypto
One can then run it by specifying the LD_LIBRARY_PATH (DYLD_LIBRARY_PATH on Max OS X):
DYLD_LIBRARY_PATH=$PWD/build/release/lib ./t
.
..
dumpster
test
test2
test3
user
Note that you'll have to LD_LIBRARY_PATH instead of DYLD_LIBRARY_PATH on Linux.
We are actually working on building C bindings for QFS in the main project. Here is the pull request. If you're not comfortable with working directly from the fork (they are very experimental), you can check it out and build with make VERBOSE=1 to see the commands that are actually used to build the components and apply that to build your own bindings.
UPDATE: The C bindings for the QFS API are now available in the master branch.
For example, here is the line that is output to build the shared library on my mac:
/usr/bin/c++ -I/opt/local/include -Wall -DBOOST_SP_USE_QUICK_ALLOCATOR -O2 -g -shared -o libqfsc.dylib -install_name /Users/sday/c/qfs/build/release/src/cc/qfsc/libqfsc.dylib CMakeFiles/qfsc-shared.dir/qfsc.o ../libclient/libqfs_client.dylib ../kfsio/libqfs_io.dylib ../common/libqfs_common.dylib -lpthread -lz ../qcdio/libqfs_qcdio.dylib /usr/local/lib/libboost_regex-mt.dylib /usr/local/lib/libboost_system-mt.dylib ../qcrs/libqfs_qcrs.dylib -lcrypto
Disclaimer: I work for Quantcast.