Problems linking to POCO libraries in ARM Linux crosscompile environment - linux

I have a problem porting POCO 1.4.6p2 to ARM based platform. I have successfully maked all the POCO libraries and installed those using cross-compiling and a ToolChain from Karo Electronics for their TX28 board (http://www.karo-electronics.com/tx28.html).
However when I try to link to any of the dynamic release POCO libraries, f. ex. libPocoFoundation.so I get link errors like this:
Linking CXX executable hellodingo
/home/armsdk/projects/poco/install/lib/libPocoFoundation.so: undefined reference to Poco::Channel::setProperty(std::string const&, std::string const&)'
/home/armsdk/projects/poco/install/lib/libPocoFoundation.so: undefined reference toPoco::LoggingRegistry::channelForName(stlp_std::basic_string, stlp_std::allocator > const&) const'
/home/armsdk/projects/poco/install/lib/libPocoFoundation.so: undefined reference to Poco::SystemException::SystemException(std::string const&, int)'
/home/armsdk/projects/poco/install/lib/libPocoFoundation.so: undefined reference toPoco::RegularExpressionException::RegularExpressionException(std::string const&, int)'
...
However if I link instead to the dynamic debug version of the POCO libraries, f.ex. libPocoFoundationd.so, everything links without a problem.
This is also true if I try to build the POCO libraries and do not omit PageCompiler,PageCompiler/File2Page which are executables needing PocoFoundation and more POCO libraries.
I'm using version gcc and g++ version 4.7.2 (the cross compiler).
I'm using the STLport v. 5.2.1 when building the POCO libraries.
What can be causing this link-difference between the release and debug version of the POCO libraries?
PS: Even when using the debug version of the POCO libs when I add more libraries than just the foundation (for example the PocoZip library) , I start getting the same errors from PocoZip complaining about undefined reference from PocoZip to items in PocoFoundatoin.
Below is a CMAkeLists.txt that I use for building:
cmake_minimum_required(VERSION 2.8)
set(CMAKE_TOOLCHAIN_FILE /home/armsdk/projects/Toolchain-TX28.cmake)
project(hellodingo)
add_executable(hellodingo SmoDeviceI2C.cpp tca6424a.cpp main.cpp)
include_directories(/home/armsdk/projects/poco/install/include)
add_library(STLport SHARED IMPORTED)
add_library(PocoFoundation SHARED IMPORTED)
set_target_properties(STLport PROPERTIES IMPORTED_LOCATION "/home/armsdk/projects/STLport/install/arm-926ejs-linux-gnueabi-lib/libstlport_arm-linux-gcc.so")
set_target_properties(PocoFoundation PROPERTIES IMPORTED_LOCATION "/home/armsdk/projects/poco/install/lib/libPocoFoundationd.so")
set_target_properties(PocoUtil PROPERTIES IMPORTED_LOCATION "/home/armsdk/projects/poco/install/lib/libPocoUtild.so")
target_link_libraries(hellodingo STLport PocoFoundation PocoUtil)
install(TARGETS hellodingo RUNTIME DESTINATION bin)

Related

CMake: How to use an imported .so.1.2.3 in transitive dependencies

I have to import a libft4222.so.1.2.3 into a CMake project on Linux. There are no symlinks without version information like a plain libmyimportedlibrary.so. I am writing a FindLibFT4222.cmake to make the library usable in my project.
In my project, a shared library uses libft4222 like this:
if (LIBFT4222_FOUND)
if (NOT TARGET LibFT4222::LibFT4222)
add_library(LibFT4222::LibFT4222 UNKNOWN IMPORTED)
set_target_properties(LibFT4222::LibFT4222
PROPERTIES IMPORTED_LOCATION ${LibFT4222_LIBS})
target_include_directories(LibFT4222::LibFT4222
INTERFACE
${LibFT4222_INCLUDE_DIR})
endif()
endif()
LibFT4222_LIBS points to the imported location of the libft4222.so.1.2.3:
/path/to/libft4222.so.1.2.3
I am adding this library as a dependency to a shared library A in my project.
Finally, I have an executable depending on A.
When I link the executable, the linker reports an error that it cannot find libft4222.so
When I add libft4222 directly to the executable, it works.
The error message I get:
/usr/lib/gcc-cross/arm-linux-gnueabihf/9/../../../../arm-linux-gnueabihf/bin/ld: warning: libft4222.so, needed by libSomeOtherLib.so, not found (try using -rpath or -rpath-link)
How do I tell CMake to correctly handle libft4222.so.1.2.3 and not to omit .1.2.3?
Update 1: I looked at the SONAME property of libft4222.so.1.2.3:
$ arm-linux-gnueabihf-objdump -p libft4222.so.1.4.4.44 | grep SONAME
SONAME libft4222.so
So I guess creating the symlinks is unavoidable.

Getting "undefined reference to" when using the lib for ARM, but not when compiling it

For one of my Qt Embedded projects I'm using a external Qt lib called SMTPEmail. This lib needs to be compiled before being included into a project, something that I managed to do successfully both for Qt 4.8 ARM and for Desktop.
The problem I'm getting is that when I include the headers into my project and include the library in the .pro, the linker gives me
(path_to_libs)/libSMTPEmail.so: undefined reference to `QSslSocket::connectToHostEncrypted(QString const&, unsigned short, QFlags<QIODevice::OpenModeFlag>)'
(path_to_libs)/libSMTPEmail.so: undefined reference to `QSslSocket::QSslSocket(QObject*)'
collect2: ld returned 1 exit status
make: *** [re8k_interface-tgt] Error 1
but only for compiling for ARM. IOW compiling the lib for both ARM and Desktop goes OK, compiling the project for Desktop using the lib goes OK but compiling it for ARM using the lib goes wrong.
Following this forum thread I suspected this could be due to missing the link to the library file of openssl (the project points to different lib folders when compiling for different environments). So I searched for all "openssl" related files inside the compiler for ARM (arm-arago-linux-gnueabi) and included in the same folder where the .so is located; same error. I then suspected the lib itself had other dependencies which were not in the path_to_libs, so I did a readelf -d libSMTPEmail.so and later in the .so.1 and readelf did return some lib dependencies that were not inside the same folder of the library. I then copied all such dependencies to the folder and got no success either.
So what could be happening? All dependencies known by me were put in place and I still get the error only for the situation where the lib is included by another project compiled for ARM.
You need to point your QMake where your libs and header file is in your .pro file;
So find where your library is assume /usr/local/include then ;
INCLUDEPATH += /usr/local/include
Add which libs you will use;
LIBS += -lSMTPEmail
You can check my answer here;
Two things stand out for me in your question:
1.
undefined reference to
This error message means that there was an error in the linking step of compilation. This occurs when you include a header to a function/class/variable but don't have the definition included in your own sources, or you do not link in a static library that does.
Searching for dependencies in libraries that are already compiled (.dll or .so) is too late, the compiler is looking for a static link, not a dynamic link.
2.
compiling the lib for both ARM and Desktop goes OK, compiling the
project for Desktop using the lib goes OK but compiling it for ARM
using the lib goes wrong.
This suggests that you are using conditional compilation in your .pro file that does a "both" compilation, a "desktop only" compilation and a "ARM only" compilation. If this is correct, you need to examine your compilation instructions for your "ARM only" compilation.
The error message itself refers to you using two functions from the QSslStock class. These are part of the QtNetwork module so you should have the following in your .pro file in order for the necessary links to be formed.
Qt += network

how to install xerces on linux as static library

I am using xerces for parsing the xml files.I want to make it static and use it directly in my project.so I downloaded the source and built it.which gave me all .o files and built all those .o files with my project .o files using a makefile and g++ as linker but when i did compilation i am getting liking errors like the following
/home/harsha/Desktop/xerces-c-3.1.1/src/xercesc/util/PlatformUtils.cpp:523: undefined reference to `_cxa_allocate_exception'
/home/harsha/Desktop/xerces-c-3.1.1/src/xercesc/util/PlatformUtils.cpp:523: undefined reference to `_cxa_throw'
/home/harsha/Desktop/xerces-c-3.1.1/src/xercesc/util/PlatformUtils.cpp:523: undefined reference to `_cxa_free_exception'
How can i clear these errors ?
and is -lnsl is required ?
how to install it ?

Can't include OpenCV functions in Matlab in Linux

I have a .cpp that I'm trying to mex using MATLAB R2011a in Ubuntu 14.04. The file uses some OpenCV functions and imports the correponding library:
#include <opencv/cv.h>
I'm mexing using the following command in Matlab:
mex -I/usr/local/include FaceDetect.cpp
As the opencv libraries are installed in /usr/local/include/opencv. The crash result is as follows:
Warning: You are using gcc version "4.8.2-19ubuntu1)". The version
currently supported with MEX is "4.3.4".
For a list of currently supported compilers see:
http://www.mathworks.com/support/compilers/current_release/
FaceDetect.o: In function `mexFunction':
FaceDetect.cpp:(.text+0xc6): undefined reference to `cvLoad'
FaceDetect.cpp:(.text+0x132): undefined reference to `cvCreateMemStorage'
FaceDetect.cpp:(.text+0x155): undefined reference to `cvCreateImage'
FaceDetect.cpp:(.text+0x23a): undefined reference to `cvHaarDetectObjects'
FaceDetect.cpp:(.text+0x285): undefined reference to `cvGetSeqElem'
FaceDetect.cpp:(.text+0x354): undefined reference to `cvReleaseImage'
FaceDetect.cpp:(.text+0x393): undefined reference to `cvClearMemStorage'
FaceDetect.cpp:(.text+0x39f): undefined reference to `cvReleaseHaarClassifierCascade'
collect2: error: ld returned 1 exit status
mex: link of ' "FaceDetect.mexa64"' failed.
??? Error using ==> mex at 208
Unable to complete successfully
I have tried compiling with -L and -lcv and it still crashes. What I am doing wrong?
The Computer Vision System Toolbox now includes a support package for OpenCV interface. It includes a library of conversion routines between MATLAB and OpenCV data types, and an easy way to compile mex functions, which use OpenCV.

How to link to VTK library on Windows using g++

I want to use the command line to compile a simple program using the VTK library:
g++ -IC:\VTK\Install\includes\vtk-5.10 SimpleTest.cpp -LC:\VTK\Install\lib
\vtk_5.10 -lvtkCommon -lvtkGraphics
SimpleTest.cpp
#include "vtkConeSource.h"
int main()
{
vtkConeSource* cone = vtkConeSource::New();
cone->SetHeight(5.0);
return 1;
}
but I always get many errors about "undefined references". For example:
C:\VTK\Install\lib\vtk_5.10/libvtkGraphics.a(vtkConeSource.cxx.obj):vtkConeSource.cxx:(.text+0x1c): undefined reference to `vtkInformationVector::GetInformationObject(int)'
C:\VTK\Install\lib\vtk_5.10/libvtkGraphics.a(vtkConeSource.cxx.obj):vtkConeSource.cxx:(.text+0x24): undefined reference to `vtkStreamingDemandDrivenPipeline::MAXIMUM_NUMBER_OF_PIECES()'
C:\VTK\Install\lib\vtk_5.10/libvtkGraphics.a(vtkConeSource.cxx.obj):vtkConeSource.cxx:(.text+0x36): undefined reference to `vtkInformation::Set(vtkInformationIntegerKey*, int)'
C:\VTK\Install\lib\vtk_5.10/libvtkGraphics.a(vtkConeSource.cxx.obj):vtkConeSource.cxx:(.text+0x85): undefined reference to `vtkPolyDataAlgorithm::PrintSelf(std::ostream&, vtkIndent)'
C:\VTK\Install\lib\vtk_5.10/libvtkGraphics.a(vtkConeSource.cxx.obj):vtkConeSource.cxx:(.text+0x9f): undefined reference to `operator<<(std::ostream&, vtkIndent const&)'
and many more ...
I can't tell if I am using wrong syntax for g++ or if there is something wrong with my VTK library.
I am using:
VTK 5.10.1
minGW 4.7.2, 32 bit
VTK was compiled from source with minGW using CMake 2.8.11.2
update:
I did find this tutorial http://vtkblog.blogspot.com/2008/05/build-vtk-from-source-using-mingwmsys.html about this. However I used minGW32-make instead of installing MSYS and using it's "make". Could this be part of the problem?
As a very first test, try explicitly including all vtk libraries contained in Install\lib\vtk_5.10 - to ensure those undefined references are not coming from those missing libraries.

Resources