davisking / dlib

A toolkit for making real world machine learning and data analysis applications in C++
http://dlib.net
Boost Software License 1.0
13.59k stars 3.38k forks source link

Compile with gcc(g++) + nvcc only (not cmake) #1803

Closed meloman-a closed 5 years ago

meloman-a commented 5 years ago

Hello, help me please please with compiling by gcc and nvcc, I can't use cmake because of using dlib in Golnang(cgo). There is the same problem explaned https://stackoverflow.com/questions/32589153/how-to-compile-cuda-source-with-go-languages-cgo. How could I understand, first I need to compile a shared library(so), but how? Maybe someone has already done something like that with dlib? It will be very usefull if someone can show how to do this on dnn_mmod_face_detection_ex.cpp example. I am trying to do this for a week.

Thank you in advance.

meloman-a commented 5 years ago

Maybe it can be combined with cmake compile results(with cuda) and gcc...

davisking commented 5 years ago

You can certainly build dlib as a shared library with cmake and then link to it using whatever you want.

On Jun 19, 2019, at 12:50 PM, meloman-a notifications@github.com wrote:

Maybe it can be combined with cmake compile results(with cuda) and gcc...

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

meloman-a commented 5 years ago

@davisking Thank you for your answer. Is using static library correct way? I am trying like that. g++ -std=c++11 -O3 -ljpeg -lgdi32 -lcomctl32 -luser32 -lwinmm -lws2_32 -limm32 -I.. dlib19.17.0_release_64bit_msvc1916.lib -lpthread dnn_mmod_face_detection_ex.cpp

but as a result get many error like that: undefined reference to dlib::tt::add(float, dlib::tensor&, float, dlib::tensor const&)' undefined reference todlib::tt::affine_transform_conv(dlib::tensor&, dlib::tensor const&, dlib::tensor const&, dlib::tensor const&)'

I was trying to compile a shared library, but failed with error: CMake Error at CMakeLists.txt:105 (message): Building dlib as a standalone dll is not supported when using Visual Studio. You are highly encouraged to use static linking instead. See https://github.com/davisking/dlib/issues/1483 for a discussion.

any advice? Thanks.

meloman-a commented 5 years ago

I've switched OS to Ubuntu 19.04 and all my problems have gone. Thank you @davisking very much for you replay "You can certainly build dlib as a shared library with cmake and then link to it using whatever you want." - it helped me!