Skip to content

undefined symbol: _ZN4dlib6base64D1Ev #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
artemklevtsov opened this issue Jan 19, 2019 · 8 comments
Open

undefined symbol: _ZN4dlib6base64D1Ev #3

artemklevtsov opened this issue Jan 19, 2019 · 8 comments

Comments

@artemklevtsov
Copy link

artemklevtsov commented Jan 19, 2019

Hello,

Thanks for the package.

I tried to use this package to face detection, but it does not works as expected:

I use very simple example:

// [[Rcpp::plugins(cpp11)]]
// [[Rcpp::depends(dlib)]]


#include <Rcpp.h>
#include <iostream>
#include <dlib/image_processing/frontal_face_detector.h>
#include <dlib/image_io.h>


using namespace Rcpp;

//' @title Detect face
//'
//' @param file Path to image file
//'
//' @export
//'
// [[Rcpp::export]]
void face_detect(std::string file) {
    dlib::frontal_face_detector detector = dlib::get_frontal_face_detector();

    dlib::array2d<unsigned char> img;
    dlib::load_image(img, file);

    std::vector<dlib::rectangle> dets = detector(img);

    std::cout << "Number of faces detected: " << dets.size() << std::endl;
}

And Makevars:

CXX_STD = CXX11 
PKG_CPPFLAGS = -DENABLE_ASSERTS
PKG_LIBS = -lpthread -lX11

My installation output below:

> devtools::install()
✔  checking for file/home/xxx/projects/R/packages/RFace/DESCRIPTION...preparingRFace:checking DESCRIPTION meta-information ...cleaning srcchecking for LF line-endings in source and make files and shell scriptschecking for empty or unneeded directories
   Removed empty directoryRFace/inst/extdataRemoved empty directoryRFace/instRemoved empty directoryRFace/man’
─  buildingRFace_0.1.0.tar.gzRunning /usr/lib64/R/bin/R CMD INSTALL /tmp/Rtmp7mY9II/RFace_0.1.0.tar.gz --install-tests 
* installing to library/home/xxx/R/x86_64-pc-linux-gnu-library/3.5* installing *source* packageRFace...
** libs
clang++ -std=gnu++11 -I"/usr/include/R/" -DNDEBUG -DENABLE_ASSERTS -I"/home/xxx/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -I"/home/xxx/R/x86_64-pc-linux-gnu-library/3.5/dlib/include" -D_FORTIFY_SOURCE=2   -fpic  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -c RcppExports.cpp -o RcppExports.o
clang++ -std=gnu++11 -I"/usr/include/R/" -DNDEBUG -DENABLE_ASSERTS -I"/home/xxx/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -I"/home/xxx/R/x86_64-pc-linux-gnu-library/3.5/dlib/include" -D_FORTIFY_SOURCE=2   -fpic  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -c face_detection.cpp -o face_detection.o
clang++ -std=gnu++11 -shared -L/usr/lib64/R/lib -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -o RFace.so RcppExports.o face_detection.o -lpthread -lX11 -L/usr/lib64/R/lib -lR
installing to /home/xxx/R/x86_64-pc-linux-gnu-library/3.5/RFace/libs
** R
** byte-compile and prepare package for lazy loading
** help
No man pages found in packageRFace*** installing help indices
** building package indices
** testing if installed package can be loaded
Error: package or namespace load failed forRFacein dyn.load(file, DLLpath = DLLpath, ...):
 не могу загрузить разделяемый объект '/home/xxx/R/x86_64-pc-linux-gnu-library/3.5/RFace/libs/RFace.so':
  /home/xxx/R/x86_64-pc-linux-gnu-library/3.5/RFace/libs/RFace.so: undefined symbol: _ZN4dlib6base64D1Ev
Ошибка: загрузка не удалась
Выполнение остановлено
ERROR: loading failed
* removing/home/xxx/R/x86_64-pc-linux-gnu-library/3.5/RFace

Should I compile dlib and link with it? How can I do it using this package?

@artemklevtsov
Copy link
Author

Tried to install dlib to my OS and use the following Makevars:

CXX_STD = CXX11 
PKG_CPPFLAGS = -I /usr/include -DDLIB_NO_GUI_SUPPORT -DENABLE_ASSERTS
PKG_LIBS = -lpthread -ldlib -ljpeg -lpng -ltiff -lgif

Now example works but I want to do it with the dlib from CRAN.

@jwijffels
Copy link
Contributor

Have you looked at the example at https://github.com/bnosac/image/tree/master/image.dlib
There it is used to get the HOG and SURF descriptors of points in the image.
The dlib on CRAN is dlib 19.2
I think you need to add PKG_CPPFLAGS = -DSTRICT_R_HEADERS and also make sure you don't copy-paste code from an example of a newer version of dlib. The error seems to be indicating it hasn't find some functionality from dlib.

@artemklevtsov
Copy link
Author

Thank you for the reply. I'll try your suggestion. Can you compile the above code?

@artemklevtsov
Copy link
Author

Dlib 19.2 is out in oct 2016. Do you plan upgrade it in the CRAN package?

@jwijffels
Copy link
Contributor

I'll start working back again on some image recognition software in February. It's on my list.

@jeffreyhanson
Copy link

Hi, I was just wondering if you were still planning on updating the version of dlib on CRAN?

@jwijffels
Copy link
Contributor

Last time I tried to push to CRAN with an update, I had to include all authors of dlib sources in the DESCRIPTION/LICENSE.note/COPYRIGHT. That was a bit too much to inspect all the headers / cpp files manually and one by one add these. Feel free to make a pull request if you want to do this.

If you want to try out dlib. I suggest you take package at https://github.com/bnosac/image/tree/master/image.dlib, remove the https://github.com/bnosac/image/blob/master/image.dlib/.Rbuildignore file and put your code in the src folder. That package is now using dlib-19.20 (released on june 6, 2020). It also shows how to pass images directly to the dlib format from R (if you are working on images). Good luck.

@jeffreyhanson
Copy link

Thank you very much for the fast response @jwijffels! Yeah, that would be a pain. I'm looking to do some box-constrained non-linear optimization, so I think I'll use the nloptr R package instead of playing around with dlib sources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants