Using xmlXPathDistinct in xmllib - xml-libxml

I don't understand how to use xmlXPathDistinct for xmllib2
// xmlNodeSetPtr xmlXPathDistinct (xmlNodeSetPtr nodes)
xmlXPathObjectPtr result;
...
if(result) {
xmlNodeSetPtr nodeset = xmlXPathDistinct(result->nodesetval);
--> warning: initialization makes pointer from integer without a cast
Could someone provide me an example?
Riccardo
edit:
gcc -o test2 test2.c -L/usr/local/lib xml2-config --cflags --libs -lpthread -m64
Linux mymachine 2.6.32-358.23.2.el6.x86_64 #1 SMP Wed Oct 16 18:37:12 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Ok, found. All these headers must be included
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/valid.h>
#include <libxml/hash.h>
#include <libxml/xmlerror.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include <libxml/parserInternals.h>
#include <libxml/uri.h>
#include <libxml/xpointer.h>

Related

OpenCV linking error by using `cv::cvtColor`

I am getting this error:
usr/bin/ld: CMakeFiles/stereo_img.dir/stereo_img.cpp.o: undefined reference to symbol '_ZN2cv8cvtColorERKNS_11_InputArrayERKNS_12_OutputArrayEii'
//usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.2.4: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
In my CmakeLists.txt I added:
add_definitions(-lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_nonfree -lopencv_objdetect -lopencv_features2d )
I am using these includes:
#include "opencv2/opencv.hpp"
#include "opencv2/gpu/gpu.hpp"
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
I can use other types from opencv, such as cv::Mat.

Compile error: libicui18n.so.54 needed by libQt5Core.so.5 not found

#include <opencv2/opencv.hpp> //头文件
using namespace cv; //包含cv命名空间
int main()
{
Mat img=imread("cornea.jpg");
imshow("src",img);
waitKey(0);
return 0;
}
And I compile it with:
g++ test.cpp -o test pkg-config opencv --cflags --libs opencv
Which gives me:
/usr/bin/ld: warning: libicui18n.so.54, needed by //home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5, not found (try using -rpath or -rpath-link)<br/>
/usr/bin/ld: warning: libicuuc.so.54, needed by //home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5, not found (try using -rpath or -rpath-link)<br/>
/usr/bin/ld: warning: libicudata.so.54, needed by //home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5, not found (try using -rpath or -rpath-link)<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_clone_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘uenum_next_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘u_strToLower_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_getStandardName_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucol_setAttribute_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_setMillis_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucol_strcoll_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_setSubstChars_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_getTimeZoneDisplayName_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_openCountryTimeZones_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_fromUnicode_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_open_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_getDefaultName_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucol_open_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucol_close_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_inDaylightTime_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucol_getSortKey_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_getAvailableName_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_close_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_get_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_openTimeZoneIDEnumeration_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_getDSTSavings_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_open_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_openTimeZones_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_toUnicode_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘u_strToUpper_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘u_errorName_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_close_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘uenum_close_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_countAvailable_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_getMaxCharSize_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_getAlias_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_getDefaultTimeZone_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_compareNames_54’未定义的引用<br/>
collect2: error: ld returned 1 exit status
The backticks in command line pkg-config opencv --cflags --libs opencv is invisible. I have not got the reason now.
Indeed,in early days, I have installed Qt. But now, I do not want my program have something to do with Qt. In order that my program is not affected by the Qt library function, I shielded the path variables of Qt in the /etc/bash.bashrc file and installed a new gcc of 5.3.0. But the same error is still existing!
I'm using Ubuntu 14.04
Download ICU-54.1 from here
http://www.linuxfromscratch.org/blfs/view/7.7/general/icu.html
and install manually.
For me this solved the problem.

Problematic clang code generation with -O0

The following snippet:
#include <string>
#include <iostream>
int main()
{
std::string s = std::to_string(5);
std::cout << s << std::endl;
return 0;
}
Fails to link with Clang 3.6 on windows (accompanied with gcc 4.8.2 headers and libraries) when given the following options:
clang++ -std=c++11 -static -O0 bug.cpp
Please note that with -O2 the snippet compiles and links fine, so i suspect it may be some kind of clang bug.
EDIT 1:
I forgot to put the link error:
F:/Programs/LLVM/bin/../lib/gcc/i686-w64-mingw32/4.8.2\libstdc++.a(string-inst.o):(.text$_ZNSs12_S_constructIPcEES0_T_S1_RKSaIcESt20forward_iterator_tag[__ZNSs12_S_constructIPcEES0_T_S1_RKSaIcESt20forward_iterator_tag]+0x0): multiple definition of
`char* std::string::_S_construct<char*>(char*, char*, std::allocator<char> const&, std::forward_iterator_tag)'
C:\Users\THEART~1\AppData\Local\Temp\bug-b5df09.o:(.text[__ZNSs12_S_constructIPcEES0_T_S1_RKSaIcESt20forward_iterator_tag]+0x0): first defined here
F:/Programs/LLVM/bin/../lib/gcc/i686-w64-mingw32/4.8.2\libstdc++.a(string-inst.o):(.text$_ZNSsC2IPcEET_S1_RKSaIcE[__ZNSsC2IPcEET_S1_RKSaIcE]+0x0): multiple definition of `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string<char*>(char*, char*, std::allocator<char> const&)'
C:\Users\THEART~1\AppData\Local\Temp\bug-b5df09.o:(.text[__ZNSsC2IPcEET_S1_RKSaIcE]+0x0): first defined here
F:/Programs/LLVM/bin/../lib/gcc/i686-w64-mingw32/4.8.2/../../../../i686-w64-mingw32/bin/ld.exe: C:\Users\THEART~1\AppData\Local\Temp\bug-b5df09.o: bad reloc address 0x10 in section `.text[__ZSt9to_stringi]'
collect2.exe: error: ld returned 1 exit status
clang++.exe: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
EDIT 2:
I've been asked why i added the static flag in the compilation flags.
My purpose was to generate full static linked executables without the need of some gcc dlls (libstdc++6.dll libwinpthread.dll etc) so i have mostly been compiling with this command:
clang++ -std=c++11 -static -static-libstdc++ -static-libgcc -O0 bug.cpp
that i've been using with gcc too to generate full static executables.
After some experimenting i noticed that the combination of -static and -O0 flags is the problematic one so i omitted the others to not create any confusion.

Simple CPP file failed to compile with Clang

#include "clang/AST/ASTConsumer.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetOptions.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Parse/ParseAST.h"
#include "clang/Rewrite/Rewriter.h"
#include "clang/Rewrite/Rewriters.h"
#include "llvm/Support/Host.h"
int main()
{
return 0;
}
I am compiling it as
clang++ -I/home/pc/llvm-3.3.src/tools/clang/include -I/home/pc/llvm-3.3-build/tools/clang/include -I/usr/local/include -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-uninitialized -Wnon-virtual-dtor -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-rtti -c -o simple.o simple.cpp
I am getting error as 'clang/Rewrite/Rewriter.h' file not found
About a year ago (before the release of llvm 3.2), ClangRewrite was split into 2 libraries: ClangRewriteCore and ClangRewriteFrontend.
This means that:
clang/Rewrite/Rewriter.h is now clang/Rewrite/Core/Rewriter.h.
clang/Rewrite/Rewriters.h is now clang/Rewrite/Frontend/Rewriters.h.
libclangRewrite.a is now libclangRewriteCore.a and libclangRewriteFrontend.a.
You can see the change in the LLVM repository here.

Compiling in OpenCV

Every time I try to compile this code in OpenCV, I keep getting this error. All I want to do is create a window:
//#include <iostream>
//#include <stdio.h>
#include "highgui.h"
int main() {
int cvNamedWindow(const char* name, int flags = CV_WINDOW_AUTOSIZE);
{
cvNamedWindow("sample");
}
cvDestroyWindow("sample");
}
However I'm getting this error:
window.cpp:4:21: fatal error: highgui.h: No such file or directory
I have checked in the necessary folder and highgui.h is very much installed.
Any help?
Include files as following
#include "opencv2/highgui/highgui.hpp"
And compile the file
g++ -ggdb `pkg-config --cflags opencv` filename `pkg-config --libs opencv`
If you have the OpenCV include as part of the include path, it should be
#include "opencv/highgui.h"
or
#include "opencv2/highgui/highgui.hpp"
depending on you using the c or c++

Resources