Previously I had made a Card.IO binding manually. It was compiling, so was the project that used it, but it would crash too often.
Now I'm trying to recreate the binding using ObjectiveSharpie from scratch. The binding project compiles but when I reference it from another project I get compiler errors shown below.
It was showing AVFoundation framework items as "Undefined symbols..." so under IOS Build options in Xamarin I have "-cxx" option. I tried various combinations of ways to add frameworks to the project:
- modified [assembly: LinkWith(..., Frameworks="...")] in CardIO binding project. This results in unrecognized CardIO namespace in my main project
- added -gcc_flags "-framework ...". This results in "framework not found" message from the compiler
I finally resolved the AVFoundation by including a using AVFoundation, then requesting the type name of one if its classes so the linker doesn't optimize it away - ugly hack in my book.
In the error below it looks like there are more frameworks missing, on top of that I believe the std::... ones should have been resolved by using the "-cxx" parameter
I'm out of ideas how to make this binding compile and work properly.
Undefined symbols for architecture armv7:
"_AudioServicesPlayAlertSound", referenced from:
-[CardIOCameraViewController vibrate] in libCardIO.a(CardIOCameraViewController.o)
"_CMGetAttachment", referenced from:
-[CardIOVideoStream captureOutput:didOutputSampleBuffer:fromConnection:] in libCardIO.a(CardIOVideoStream.o)
"_CMSampleBufferGetImageBuffer", referenced from:
-[CardIOVideoFrame process] in libCardIO.a(CardIOVideoFrame.o)
"_CVPixelBufferGetBaseAddressOfPlane", referenced from:
+[CardIOIplImage imageFromYCbCrBuffer:plane:] in libCardIO.a(CardIOIplImage.o)
"_CVPixelBufferGetBytesPerRowOfPlane", referenced from:
+[CardIOIplImage imageFromYCbCrBuffer:plane:] in libCardIO.a(CardIOIplImage.o)
"_CVPixelBufferGetHeightOfPlane", referenced from:
+[CardIOIplImage imageFromYCbCrBuffer:plane:] in libCardIO.a(CardIOIplImage.o)
"_CVPixelBufferGetWidthOfPlane", referenced from:
+[CardIOIplImage imageFromYCbCrBuffer:plane:] in libCardIO.a(CardIOIplImage.o)
"_CVPixelBufferLockBaseAddress", referenced from:
-[CardIOVideoFrame process] in libCardIO.a(CardIOVideoFrame.o)
"_CVPixelBufferUnlockBaseAddress", referenced from:
-[CardIOVideoFrame process] in libCardIO.a(CardIOVideoFrame.o)
"_OBJC_CLASS_$_EAGLContext", referenced from:
objc-class-ref in libCardIO.a(CardIOGPURenderer.o)
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::find(char const*, unsigned long, unsigned long) const", referenced from:
cv::CommandLineParser::CommandLineParser(int, char const* const*, char const*)in libCardIO.a(cmdparser.o)
(anonymous namespace)::split_string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)in libCardIO.a(cmdparser.o)
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::find(char, unsigned long) const", referenced from:
cv::CommandLineParser::CommandLineParser(int, char const* const*, char const*)in libCardIO.a(cmdparser.o)
(anonymous namespace)::del_space(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)in libCardIO.a(cmdparser.o)
cv::CommandLineParser::printParams() in libCardIO.a(cmdparser.o)
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::rfind(char, unsigned long) const", referenced from:
(anonymous namespace)::del_space(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)in libCardIO.a(cmdparser.o)
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::compare(char const*) const", referenced from:
cv::CommandLineParser::CommandLineParser(int, char const* const*, char const*)in libCardIO.a(cmdparser.o)
cv::CommandLineParser::printParams() in libCardIO.a(cmdparser.o)
bool cv::CommandLineParser::get<bool>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)in libCardIO.a(cmdparser.o)
"std::__1::__vector_base_common<true>::__throw_length_error() const", referenced from:
This was an ugly one, but an easy fix in the end. In the target's build settings, in "Other Linker Flags," I have the following:
-lstdc++ -ObjC -lc++
That is, libCardIO is requiring both -lstdc++ and -lc++.
Also, make sure you have set "Link With Standard Libraries" to "Yes".
After a lot of guesswork, trial-error and searching for each particular error in the output I came up with a solution that works, add this attribute to the .linkwith.cs file in the binding project:
[assembly: LinkWith ("libCardIO.a", IsCxx=true, LinkTarget= LinkTarget.ArmV7 | LinkTarget.ArmV7s | LinkTarget.Simulator, ForceLoad = true
,Frameworks = "AVFoundation AudioToolbox CoreMedia CoreVideo OpenGLES MobileCoreServices"
,LinkerFlags = "-ObjC -lc++")]
I had assumed that adding
-cxx -gcc_flags "-lstdc++"
to the main project's iOS build should do the same thing but that wasn't the case, with or without these additional compiler parameters the binding wasn't building.
If you need a copy of the binding project just ask.
Related
I want to use Luacpp in an SGX application. For example, in the SampleEnclave application, I want to send some Lua codes to be executed securely in SGX.
I have updated the Enclave's MakeFile to make the SampleEnclave app Lua compatible. But getting below error:
/usr/local/bin/ld: Enclave/Enclave.o: warning: relocation against `_ZTVN6LuaCpp6Engine10LuaTStringE' in read-only section `.text._ZN6LuaCpp6Engine10LuaTStringD2Ev[_ZN6LuaCpp6Engine10LuaTStringD5Ev]'
/usr/local/bin/ld: /usr/local/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x55ebb vs 0x40078)
/usr/local/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x55ebb vs 0x40078)
/usr/local/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x55ebb vs 0x40078)
/usr/local/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x55ebb vs 0x40078)
/usr/local/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x55ebb vs 0x40078)
/usr/local/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x55ebb vs 0x40078)
/usr/local/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x55ebb vs 0x40078)
Enclave/Enclave.o:/usr/local/include/LuaCpp/Engine/LuaTString.hpp:62: undefined reference to `LuaCpp::Engine::LuaType::LuaType()'
/usr/local/bin/ld: Enclave/Enclave.o:/usr/local/include/LuaCpp/Engine/LuaTString.hpp:62: undefined reference to `vtable for LuaCpp::Engine::LuaTString'
/usr/local/bin/ld: Enclave/Enclave.o:/usr/local/include/LuaCpp/Engine/LuaTString.hpp:67: undefined reference to `vtable for LuaCpp::Engine::LuaTString'
/usr/local/bin/ld: Enclave/Enclave.o:/usr/local/include/LuaCpp/Engine/LuaTString.hpp:67: undefined reference to `LuaCpp::Engine::LuaType::~LuaType()'
/usr/local/bin/ld: Enclave/Enclave.o: in function `ecall_test':
/home/alam/practice/LuaEnclave/Enclave/Enclave.cpp:55: undefined reference to `LuaCpp::LuaContext::AddGlobalVariable(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::shared_ptr<LuaCpp::Engine::LuaType>)'
/usr/local/bin/ld: /home/alam/practice/LuaEnclave/Enclave/Enclave.cpp:56: undefined reference to `LuaCpp::LuaContext::CompileString(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)'
/usr/local/bin/ld: /home/alam/practice/LuaEnclave/Enclave/Enclave.cpp:62: undefined reference to `LuaCpp::LuaContext::Run(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)'
/usr/local/bin/ld: /home/alam/practice/LuaEnclave/Enclave/Enclave.cpp:69: undefined reference to `LuaCpp::Engine::LuaTString::getValue() const'
/usr/local/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:256: enclave.so] Error 1
make[1]: Leaving directory '/home/alam/practice/LuaEnclave'
make: *** [Makefile:181: all] Error 2
Can I get rid of the dynamic library dependency from LUA? Because SGX does not support dynamic libraries in Enclave.
I'm trying to install the libpca package.
I've already have Armadillo set up.
The libpca package is unzipped to /my/dir/. And I set the CPLUS_INCLUDE_PATH and other variables to the place Armadillo installed. (export CPLUS_INCLUDE_PATH=/my/dir/arma_install/include/:$CPLUS_INCLUDE_PATH)
I run the following command to install libpca:
/my/dir/libpca-1.3.3$ ./configure --prefix=/my/dir/libpca-1.3.3
/my/dir/libpca-1.3.3$ make
which has warnings but no error. And the command:
/my/dir/libpca-1.3.3$ make install prefix=/my/dir/libpca-1.3.3
It seems good and no error is reported.
Then I try to compile and run the example file in /my/dir/libpca-1.3.3/examples/simple/pca_example.cpp. In dir examples, I run
/my/dir/libpca-1.3.3/examples$ make
It returns
make[1]: Nothing to be done for 'all'
make[1]: Nothing to be done for 'all-am'
And no new file is created. Then I cd into examples/simple, and run
/my/dir/libpca-1.3.3/examples/simple$ make
It returns:
make: Nothing to be done for 'all'
And no new file is created. Then I run
/my/dir/libpca-1.3.3/examples/simple$ make check
It returns the following errors:
The variables wrapper_dsyev_, wrapper_dgemv_, wrapper_dgemm_, etc. in the errors above, exist in the following binaries:
/my/dir/arma_install/lib64/libarmadillo.so.8.500.0
/my/dir/arma_downloaded/CMakeFiles/armadillo.dir/src/wrapper.cpp.o
/my/dir/arma_downloaded/CMakeFiles/CMakeRelink.dir/libarmadillo.so.8.500.0
After I export them into LD_LIBRARY_PATH, the same errors are still returned.
I think there should be something wrong with the include path, and environment variables. How do I solve it?
Moreover, if I need to write code in /my/dir/working_dir/, how can I set the path?
----------------------------------edited below--------------------
When I made the update described below, at step 3:
/my/dir/libpca-1.3.3$ LD_LIBRARY_PATH=/my/dir/arma_install/lib64 make check
It returns the following errors:
LD_LIBRARY_PATH=/my/dir/arma_install/lib64/ make check
Making check in src/lib
make[1]: Entering directory `/my/dir/libpca-1.3.3/src/lib'
make[1]: Leaving directory `/my/dir/libpca-1.3.3/src/lib'
Making check in test
make[1]: Entering directory `/my/dir/libpca-1.3.3/test'
make unittest
make[2]: Entering directory `/my/dir/libpca-1.3.3/test'
/bin/sh ../libtool --tag=CXX --mode=link g++ -I../src/lib
-pthread -O2 -o unittest main.o testcases.o test_pca.o test_utils.o ../src/lib/.libs/libpca.a -L/my/dir/source_scripts/lib64
libtool: link: g++ -I../src/lib -pthread -O2 -o unittest main.o
testcases.o test_pca.o test_utils.o ../src/lib/.libs/libpca.a
-L/my/dir/arma_install/lib64 -pthread
test_utils.o: In function `void arma::glue_times::apply, arma::Mat
(arma::Mat&, arma::Mat const&, arma::Mat const&, double)':
test_utils.cpp:(.text.hot._ZN4arma10glue_times5applyIdLb1ELb0ELb1ENS_3MatIdEES3_EEvRNS2_IT_EERKT3_RKT4_S4_[_ZN4arma10glue_times5applyIdLb1ELb0ELb1ENS_3MatIdEES3_EEvRNS2_IT_EERKT3_RKT4_S4_]+0x169):
undefined reference to `wrapper_dgemm_'
test_utils.cpp:(.text.hot._ZN4arma10glue_times5applyIdLb1ELb0ELb1ENS_3MatIdEES3_EEvRNS2_IT_EERKT3_RKT4_S4_[_ZN4arma10glue_times5applyIdLb1ELb0ELb1ENS_3MatIdEES3_EEvRNS2_IT_EERKT3_RKT4_S4_]+0x363):
undefined reference to `wrapper_dgemv_'
test_utils.cpp:(.text.hot._ZN4arma10glue_times5applyIdLb1ELb0ELb1ENS_3MatIdEES3_EEvRNS2_IT_EERKT3_RKT4_S4_[_ZN4arma10glue_times5applyIdLb1ELb0ELb1ENS_3MatIdEES3_EEvRNS2_IT_EERKT3_RKT4_S4_]+0x45c):
undefined reference to `wrapper_dsyrk_'
../src/lib/.libs/libpca.a(pca.o): In function
`stats::pca::bootstrap_eigenvalues_()':
pca.cpp:(.text+0x454d): undefined reference to `wrapper_dsyev_'
pca.cpp:(.text+0x4953): undefined reference to `wrapper_dsyevd_'
../src/lib/.libs/libpca.a(pca.o): In function `bool
arma::auxlib::eig_sym_dc
(arma::Col&, arma::Mat&, arma::Base > const&)':
pca.cpp:(.text._ZN4arma6auxlib10eig_sym_dcIdNS_3MatIdEEEEbRNS_3ColIT_EERNS2_IS5_EERKNS_4BaseIS5_T0_EE[_ZN4arma6auxlib10eig_sym_dcIdNS_3MatIdEEEEbRNS_3ColIT_EERNS2_IS5_EERKNS_4BaseIS5_T0_EE]+0x13a):
undefined reference to `wrapper_dsyevd_'
../src/lib/.libs/libpca.a(pca.o): In function `bool
arma::eig_sym
(arma::Col::pod_type>&, arma::Mat::elem_type>&,
arma::Base::elem_type, arma::Mat > const&,
char const*,
arma::arma_blas_type_only::elem_type>::result
const*)':
pca.cpp:(.text._ZN4arma7eig_symINS_3MatIdEEEEbRNS_3ColINT_8pod_typeEEERNS1_INS4_9elem_typeEEERKNS_4BaseIS8_S4_EEPKcPKNS_19arma_blas_type_onlyIS8_E6resultE[_ZN4arma7eig_symINS_3MatIdEEEEbRNS_3ColINT_8pod_typeEEERNS1_INS4_9elem_typeEEERKNS_4BaseIS8_S4_EEPKcPKNS_19arma_blas_type_onlyIS8_E6resultE]+0x1a0):
undefined reference to `wrapper_dsyev_'
../src/lib/.libs/libpca.a(pca.o): In function `double
arma::auxlib::det_lapack(arma::Mat const&, bool)':
pca.cpp:(.text._ZN4arma6auxlib10det_lapackIdEET_RKNS_3MatIS2_EEb[_ZN4arma6auxlib10det_lapackIdEET_RKNS_3MatIS2_EEb]+0x117):
undefined reference to `wrapper_dgetrf_'
../src/lib/.libs/libpca.a(pca.o): In function `void arma::gemv::apply_blas_type >(double*,
arma::Mat const&, double const*, double, double)':
pca.cpp:(.text._ZN4arma4gemvILb1ELb0ELb0EE15apply_blas_typeIdNS_3MatIdEEEEvPT_RKT0_PKS5_S5_S5_[_ZN4arma4gemvILb1ELb0ELb0EE15apply_blas_typeIdNS_3MatIdEEEEvPT_RKT0_PKS5_S5_S5_]+0x86):
undefined reference to `wrapper_dgemv_'
../src/lib/.libs/libpca.a(pca.o): In function `void arma::gemv::apply_blas_type >(double*,
arma::Mat const&, double const*, double, double)':
pca.cpp:(.text._ZN4arma4gemvILb0ELb0ELb0EE15apply_blas_typeIdNS_3MatIdEEEEvPT_RKT0_PKS5_S5_S5_[_ZN4arma4gemvILb0ELb0ELb0EE15apply_blas_typeIdNS_3MatIdEEEEvPT_RKT0_PKS5_S5_S5_]+0x86):
undefined reference to `wrapper_dgemv_'
../src/lib/.libs/libpca.a(pca.o): In function `void
arma::glue_times::apply, arma::Mat >(arma::Mat&,
arma::Mat const&, arma::Mat const&, double)':
pca.cpp:(.text.hot._ZN4arma10glue_times5applyIdLb0ELb0ELb0ENS_3MatIdEES3_EEvRNS2_IT_EERKT3_RKT4_S4_[_ZN4arma10glue_times5applyIdLb0ELb0ELb0ENS_3MatIdEES3_EEvRNS2_IT_EERKT3_RKT4_S4_]+0x129):
undefined reference to `wrapper_dgemm_'
pca.cpp:(.text.hot._ZN4arma10glue_times5applyIdLb0ELb0ELb0ENS_3MatIdEES3_EEvRNS2_IT_EERKT3_RKT4_S4_[_ZN4arma10glue_times5applyIdLb0ELb0ELb0ENS_3MatIdEES3_EEvRNS2_IT_EERKT3_RKT4_S4_]+0x334):
undefined reference to `wrapper_dgemv_'
../src/lib/.libs/libpca.a(pca.o): In function `void
arma::glue_times::apply,
arma::Mat >(arma::Mat&, arma::Mat const&,
arma::Mat const&, double)':
pca.cpp:(.text.hot._ZN4arma10glue_times5applyIdLb0ELb1ELb0ENS_3MatIdEES3_EEvRNS2_IT_EERKT3_RKT4_S4_[_ZN4arma10glue_times5applyIdLb0ELb1ELb0ENS_3MatIdEES3_EEvRNS2_IT_EERKT3_RKT4_S4_]+0x14a):
undefined reference to `wrapper_dgemm_'
pca.cpp:(.text.hot._ZN4arma10glue_times5applyIdLb0ELb1ELb0ENS_3MatIdEES3_EEvRNS2_IT_EERKT3_RKT4_S4_[_ZN4arma10glue_times5applyIdLb0ELb1ELb0ENS_3MatIdEES3_EEvRNS2_IT_EERKT3_RKT4_S4_]+0x33c):
undefined reference to `wrapper_dsyrk_'
../src/lib/.libs/libpca.a(utils.o): In function
`stats::utils::compute_column_rms(arma::Mat const&)':
utils.cpp:(.text+0xe95): undefined reference to `wrapper_ddot_'
../src/lib/.libs/libpca.a(utils.o): In function `void
arma::glue_times::apply,
arma::Mat >(arma::Mat&, arma::Mat const&,
arma::Mat const&, double)':
utils.cpp:(.text.hot._ZN4arma10glue_times5applyIdLb1ELb0ELb0ENS_3MatIdEES3_EEvRNS2_IT_EERKT3_RKT4_S4_[_ZN4arma10glue_times5applyIdLb1ELb0ELb0ENS_3MatIdEES3_EEvRNS2_IT_EERKT3_RKT4_S4_]+0x353):
undefined reference to `wrapper_dgemm_'
utils.cpp:(.text.hot._ZN4arma10glue_times5applyIdLb1ELb0ELb0ENS_3MatIdEES3_EEvRNS2_IT_EERKT3_RKT4_S4_[_ZN4arma10glue_times5applyIdLb1ELb0ELb0ENS_3MatIdEES3_EEvRNS2_IT_EERKT3_RKT4_S4_]+0x8a4):
undefined reference to `wrapper_dgemv_'
utils.cpp:(.text.hot._ZN4arma10glue_times5applyIdLb1ELb0ELb0ENS_3MatIdEES3_EEvRNS2_IT_EERKT3_RKT4_S4_[_ZN4arma10glue_times5applyIdLb1ELb0ELb0ENS_3MatIdEES3_EEvRNS2_IT_EERKT3_RKT4_S4_]+0x9ab):
undefined reference to `wrapper_dsyrk_'
collect2: error: ld returned 1 exit status
make[2]: *** [unittest] Error 1
make[2]: Leaving directory `/my/dir/libpca-1.3.3/test'
make[1]: *** [check-am] Error 2
make[1]: Leaving directory `/my/dir/libpca-1.3.3/test'
make: *** [check-recursive] Error 1
What should I do next?
You need to tell the linker of the location of your armadillo library. You can achieve this in two ways:
Through environment variable: export LIBRARY_PATH=/arma/lib:$LIBRARY_PATH
Passing armadillo include and library path to configure directly:
./configure --with-armadillo-incdir=/arma/include --with-armadillo-libdir=/arma/lib
I would recommend using option 2 as it prevents settings up extra environment variables which may pollute, well, your environment.
Note that --prefix denotes the directory in which libpca is being installed to. This should be different from the source directory!
After configure you can run make, make check, and make install. For make check to succeed the linux library loader needs to know the location of the armadillo shared library. So one option is to run like so: LD_LIBRARY_PATH=/arma/lib make check
To summarize the commands you need to run:
./configure --prefix=/libpca/install --with-armadillo-incdir=/arma/include --with-armadillo-libdir=/arma/lib
make
LD_LIBRARY_PATH=/arma/lib make check
make install
Obviously, you need to adjust the paths to your situation.
Caveat: On some platforms you need to explicitly link with lapack and blas. So if you run into further linker errors then try configuring like this:
LIBS='-llapack -lblas' ./configure --prefix=/libpca/install --with-armadillo-incdir=/arma/include --with-armadillo-libdir=/arma/lib
I'm having an error when I'm using parallel_for of the TBB library. I can't understand why..
I have been able to use tbb::atomic so i'm guessing this in not a linking problem.
Here is the part of my code where i use tbb :
auto values = std::vector<double>(10);
tbb::parallel_for( tbb::blocked_range<int>(0,values.size()),
[&](tbb::blocked_range<int> r)
{
for (int i=r.begin(); i<r.end(); ++i)
{
values[i] = std::sin(i * 0.001);
}
});
double total = 0;
for (double value : values)
{
total += value;
}
std::cout << total << std::endl;
I took some example on the Internet, to debug more easily.
Here is my includes, i tried to add tbb::task but it didn't worked.
#include "interval_map_estimator.h"
#include "interval_map_estimation.h"
#include <stdlib.h>
#include <boost/numeric/ublas/matrix.hpp>
//Antoine
#include <chrono>
#include <boost/thread/thread.hpp>
#include <tbb/parallel_for.h>
#include <tbb/task.h>
#include <iostream>
And here on of the two errors i get (they are the same)
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o): In function `tbb::interface9::internal::start_for<tbb::blocked_range<int>, IntervalMapEstimation::IntervalMapEstimator::extract_relevant_points_multithread(std::vector<IntervalMapEstimation::Point3D, std::allocator<IntervalMapEstimation::Point3D> >&, std::vector<IntervalMapEstimation::Point3D, std::allocator<IntervalMapEstimation::Point3D> >&, double, double)::{lambda(tbb::blocked_range<int>)#1}, tbb::auto_partitioner const>::run(tbb::blocked_range<int> const&, {lambda(tbb::blocked_range<int>)#1} const&, tbb::auto_partitioner&)':
/usr/include/tbb/parallel_for.h:87: undefined reference to `tbb::task_group_context::~task_group_context()'
/usr/include/tbb/parallel_for.h:87: undefined reference to `tbb::task_group_context::~task_group_context()'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o):(.data.rel.ro+0x18): undefined reference to `typeinfo for tbb::task'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o): In function `tbb::task_group_context::task_group_context(tbb::task_group_context::kind_type, unsigned long)':
/usr/include/tbb/task.h:450: undefined reference to `tbb::task_group_context::init()'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o): In function `tbb::task::task()':
/usr/include/tbb/task.h:556: undefined reference to `vtable for tbb::task'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o): In function `tbb::task::~task()':
/usr/include/tbb/task.h:560: undefined reference to `vtable for tbb::task'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o): In function `tbb::task::is_cancelled() const':
/usr/include/tbb/task.h:862: undefined reference to `tbb::task_group_context::is_group_execution_cancelled() const'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o): In function `operator new(unsigned long, tbb::internal::allocate_root_with_context_proxy const&)':
/usr/include/tbb/task.h:1005: undefined reference to `tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o): In function `operator delete(void*, tbb::internal::allocate_root_with_context_proxy const&)':
/usr/include/tbb/task.h:1009: undefined reference to `tbb::internal::allocate_root_with_context_proxy::free(tbb::task&) const'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o): In function `operator new(unsigned long, tbb::internal::allocate_continuation_proxy const&)':
/usr/include/tbb/task.h:1014: undefined reference to `tbb::internal::allocate_continuation_proxy::allocate(unsigned long) const'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o): In function `operator delete(void*, tbb::internal::allocate_continuation_proxy const&)':
/usr/include/tbb/task.h:1018: undefined reference to `tbb::internal::allocate_continuation_proxy::free(tbb::task&) const'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o): In function `tbb::interface9::internal::allocate_sibling(tbb::task*, unsigned long)':
/usr/include/tbb/parallel_for.h:120: undefined reference to `tbb::internal::allocate_child_proxy::allocate(unsigned long) const'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o): In function `tbb::interface9::internal::adaptive_mode<tbb::interface9::internal::auto_partition_type>::adaptive_mode()':
/usr/include/tbb/partitioner.h:272: undefined reference to `tbb::internal::get_initial_auto_partitioner_divisor()'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o):(.data.rel.ro._ZTVN3tbb10interface98internal9flag_taskE[_ZTVN3tbb10interface98internal9flag_taskE]+0x28): undefined reference to `tbb::task::note_affinity(unsigned short)'
/home/catkin_ws/SWC_INTERVAL_MAP/devel/lib/libinterval_map_logic.a(interval_map_estimator.cpp.o):(.data.rel.ro._ZTIN3tbb10interface98internal9flag_taskE[_ZTIN3tbb10interface98internal9flag_taskE]+0x10): undefined reference to `typeinfo for tbb::task'
collect2: error: ld returned 1 exit status
If you have any suggestions it would be very welcomed :)
if i have an ELF file, how can i get each functions imported from a library file ".so" , displaying that shared library associated with the function ?
This works nicely for me:
nm -uC test
E.g. on the code from this other answer I just wrote:
g++ -O0 -I ~/custom/boost/ test.cpp -o test
nm -uC test
The output is
w _Jv_RegisterClasses
U _Unwind_Resume##GCC_3.0
U std::string::compare(std::string const&) const##GLIBCXX_3.4
U std::allocator<char>::allocator()##GLIBCXX_3.4
U std::allocator<char>::~allocator()##GLIBCXX_3.4
U std::ostream::operator<<(std::ostream& (*)(std::ostream&))##GLIBCXX_3.4
U std::ostream::operator<<(int)##GLIBCXX_3.4
U std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)##GLIBCXX_3.4
U std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)##GLIBCXX_3.4
U std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()##GLIBCXX_3.4
U std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()##GLIBCXX_3.4
U std::ios_base::Init::Init()##GLIBCXX_3.4
U std::ios_base::Init::~Init()##GLIBCXX_3.4
U std::__throw_bad_alloc()##GLIBCXX_3.4
U std::_Rb_tree_decrement(std::_Rb_tree_node_base const*)##GLIBCXX_3.4
U std::_Rb_tree_decrement(std::_Rb_tree_node_base*)##GLIBCXX_3.4
U std::_Rb_tree_increment(std::_Rb_tree_node_base const*)##GLIBCXX_3.4
U std::_Rb_tree_increment(std::_Rb_tree_node_base*)##GLIBCXX_3.4
U std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)##GLIBCXX_3.4
U std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)##GLIBCXX_3.4
U std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)##GLIBCXX_3.4
U operator delete(void*)##GLIBCXX_3.4
U operator new(unsigned long)##GLIBCXX_3.4
U __cxa_atexit##GLIBC_2.2.5
U __cxa_begin_catch##CXXABI_1.3
U __cxa_end_catch##CXXABI_1.3
U __cxa_rethrow##CXXABI_1.3
w __gmon_start__
U __gxx_personality_v0##CXXABI_1.3
U __libc_start_main##GLIBC_2.2.5
U memmove##GLIBC_2.2.5
w pthread_cancel
I'm somewhat aware of the deficiency that this doesn't say which shared object should fulfil the dependency, but I guess a little join on the output of nm for those libraries should take you a long way.
Drop the -C flag to prevent name demangling. This could be highly effective if you intend to do a crossreference on the data. Use c++filt to demangle names later, in case you want to present the names in user-friendly fashion
I am getting the following memory leak.Its being probably caused by std::string.
how can i avoid it?
PLK: 23 bytes potentially leaked at 0xeb68278
* Suppressed in /vobs/ubtssw_brrm/test/testcases/.purify [line 3]
* This memory was allocated from:
malloc [/vobs/ubtssw_brrm/test/test_build/linux-x86/rtlib.o]
operator new(unsigned) [/vobs/MontaVista/Linux/montavista/pro/devkit/x86/586/target/usr/lib/libstdc++.so.6]
operator new(unsigned) [/vobs/ubtssw_brrm/test/test_build/linux-x86/rtlib.o]
std::string<char, std::char_traits<char>, std::allocator<char>>::_Rep::_S_create(unsigned, unsigned, std::allocator<char> const&) [/vobs/MontaVista/Linux/montavista/pro/devkit/
x86/586/target/usr/lib/libstdc++.so.6]
std::string<char, std::char_traits<char>, std::allocator<char>>::_Rep::_M_clone(std::allocator<char> const&, unsigned) [/vobs/MontaVista/Linux/montavista/pro/devkit/x86/586/tar
get/usr/lib/libstdc++.so.6]
std::string<char, std::char_traits<char>, std::allocator<char>>::string<char, std::char_traits<char>, std::allocator<char>>(std::string<char, std::char_traits<char>, std::alloc
ator<char>> const&) [/vobs/MontaVista/Linux/montavista/pro/devkit/x86/586/target/usr/lib/libstdc++.so.6]
uec_UEDir::getEntryToUpdateAfterInsertion(rcapi_ImsiGsmMap const&, rcapi_ImsiGsmMap&, std::_Rb_tree_iterator<std::pair<std::string<char, std::char_traits<char>, std::allocator<
char>> const, UEDirData >>&) [/vobs/ubtssw_brrm/uectrl/linux-x86/../src/uec_UEDir.cc:2278]
uec_UEDir::addUpdate(rcapi_ImsiGsmMap const&, LocalUEDirInfo&, rcapi_ImsiGsmMap&, int, unsigned char) [/vobs/ubtssw_brrm/uectrl/linux-x86/../src/uec_UEDir.cc:282]
ucx_UEDirHandler::addUpdateUEDir(rcapi_ImsiGsmMap, UEDirUpdateType, acap_PresenceEvent) [/vobs/ubtssw_brrm/ucx/linux-x86/../src/ucx_UEDirHandler.cc:374]
I once had a case where Valgrind indicated I had leaks in std::string, but I couldn't see how. It turned out that I was leaking another object that held strings by value, but Valgrind correctly also caught the leaked string memory (which was the vast majority being leaked). I suspect that uec_UEDir isn't managing its strings correctly or is being leaked itself. I actually ended up finding my problem by very careful code inspection.