Open Rutvik21 opened 4 years ago
I encountered the same error (MSVC2017 + CUDA10.2).
The issue is that CMake generates MSVC project files without properly defining the LIB_API preprocessor variable. That is why the functions are not exported from the darknet.dll.
Quick workaround it open the Darknet.sln in MSVC and add LIB_API=__declspec(dllexport) to the "C/C++->Preprocessor Definitions" in "dark" and "darknet" project properties. Then recompile everything in the MSVC.
But, of course, this must be fixed in the repository.
CMakeLists.txt correctly set the LIB_EXPORT preprocessor variable during library build. It does not define LIB_API by design, since the code logic requires it.
Can you please confirm you are using latest darknet version (and vcpkg too, in the meantime)?
Just run a git pull in both folders (darknet and vcpkg). If any file is downloaded, please act accordingly. To update vcpkg you need to run
cd vcpkg
git pull
.\bootstrap-vcpkg.bat
.\vcpkg upgrade --no-dry-run
To update darknet you need to run
cd darknet
git pull
rm -r build_win_release
.\build.ps1
I am using latest version of both darknet and vcpkg.
please copy/paste output from .\vcpkg.exe list
and also versions of vs compiler and cmake
Currently I am again trying with reinstalling darknet and vcpkg using latest git. Will update as soon as it completes.
I build and run with GPU Successfully with below Environment: https://github.com/AlexeyAB/darknet/issues/6501#issuecomment-695024305
I am still getting the same error. Windows 10 Visual Studio 2017 The C compiler identification is MSVC 19.15.26726.0 Cuda 10.1
Output of .\vcpkg.exe list : cuda:x64-windows 10.1#2 A parallel computing platform and programming model cudnn:x64-windows 7.6#2 NVIDIA's cuDNN deep neural network acceleration ... darknet:x64-windows 2020-08-30 Darknet is an open source neural network framewo... darknet[cuda]:x64-windows Build darknet with support for CUDA darknet[cudnn]:x64-windows Build darknet with support for CUDNN darknet[full]:x64-windows Build darknet fully-featured darknet[opencv-cuda]:x64-windows Build darknet with support for a CUDA-enabled Op... darknet[weights-train]:x64-windows Download pre-built weights for training darknet[weights]:x64-windows Download pre-built weights for test ffmpeg:x64-windows 4.2#24 a library to decode, encode, transcode, mux, dem... ffmpeg[avcodec]:x64-windows Codec support in ffmpeg ffmpeg[avdevice]:x64-windows Device support in ffmpeg ffmpeg[avfilter]:x64-windows Filter support in ffmpeg ffmpeg[avformat]:x64-windows Format support in ffmpeg ffmpeg[avresample]:x64-windows Libav audio resampling library support in ffmpeg ffmpeg[postproc]:x64-windows Postproc support in ffmpeg ffmpeg[swresample]:x64-windows Swresample support in ffmpeg ffmpeg[swscale]:x64-windows Swscale support in ffmpeg giflib:x64-windows 5.1.4-6 A library for reading and writing gif images. hdf5:x64-windows 1.12.0 HDF5 is a data model, library, and file format f... hdf5[szip]:x64-windows Build with szip hdf5[zlib]:x64-windows Build with zlib leptonica:x64-windows 1.78.0-1 An open source library containing software that ... libjpeg-turbo:x64-windows 2.0.5 libjpeg-turbo is a JPEG image codec that uses SI... liblzma:x64-windows 5.2.5#1 Compression library with an API similar to that ... libpng:x64-windows 1.6.37#11 libpng is a library implementing an interface fo... libwebp:x64-windows 1.1.0#1 WebP codec: library to encode and decode images ... libwebp[nearlossless]:x64-windows Enable near-lossless encoding libwebp[simd]:x64-windows Enable any SIMD optimization. libwebp[unicode]:x64-windows Build Unicode executables. (Adds definition UNIC... opencv4:x64-windows 4.3.0#1 computer vision library opencv4[contrib]:x64-windows opencv_contrib module opencv4[cuda]:x64-windows CUDA support for opencv opencv4[dnn]:x64-windows Enable dnn module opencv4[ffmpeg]:x64-windows ffmpeg support for opencv opencv4[jpeg]:x64-windows JPEG support for opencv opencv4[opengl]:x64-windows opengl support for opencv opencv4[png]:x64-windows PNG support for opencv opencv4[tiff]:x64-windows TIFF support for opencv opencv4[webp]:x64-windows WebP support for opencv opencv:x64-windows 4.3.0 Computer vision library opencv[cuda]:x64-windows CUDA support for opencv opencv[dnn]:x64-windows Enable dnn module opencv[ffmpeg]:x64-windows ffmpeg support for opencv opencv[jpeg]:x64-windows JPEG support for opencv opencv[opengl]:x64-windows opengl support for opencv opencv[png]:x64-windows PNG support for opencv opencv[tiff]:x64-windows TIFF support for opencv opencv[webp]:x64-windows WebP support for opencv opengl:x64-windows 0.0-7 Open Graphics Library (OpenGL)[3][4][5] is a cro... protobuf:x64-windows 3.13.0#1 Protocol Buffers - Google's data interchange format pthreads:x64-windows 3.0.0-6 pthreads for windows stb:x64-windows 2020-02-08-1 public domain header-only libraries szip:x64-windows 2.1.1-6 Szip compression software, providing lossless co... tesseract:x64-windows 4.1.1#1 An OCR Engine that was developed at HP Labs betw... tiff:x64-windows 4.1.0 A library that supports the manipulation of TIFF... zlib:x64-windows 1.2.11#9 A compression library
Can you please attach the CMakeCache.txt you should have in your Darknet/build_win_release folder?
The environment where LIB_API is not being set properly is:
MSVC 2017 15.9.27 CUDA 10.2 Windows 10
To reproduce, just follow the exact instructions: https://github.com/AlexeyAB/darknet#how-to-compile-on-windows-using-cmake So, I use everything new, fresh from the repositories.
CMakeCache.txt attached: CMakeCache.txt
After reading the comments, I think the issue happens only with MSVC 2017 with the latest updates installed. By any chance, do you check the Visual Studio version by preprocessor macro MSVC_VER somewhere in the code? Microsoft (in its infinite wisdom) sets this macro to a new value with each update of MSVC. This breaks a lot of codes out there, and this might be the reason.
@advanpix not only VS 2017, VC 2019 also have the same problem.
I try with completely new computer, and the problem gone. the main different is the Window 10 OS build version:
Fail : Window Insider Program Dev Channel (always update), Success: Normal Window 10 Pro version 2004 OS build 19041.508
The quick way to taste darknet is reinstall window 10 machine or use Linux. Of course, the better way is fix the root cause.
@cenit Here I have attached the Cmakecache.txt file. CMakeCache.txt
@Rutvik21 Try this PR https://github.com/AlexeyAB/darknet/pull/5969.
I am getting the following error while running ./build.ps1. Please help anyone, how to fix that error. Here is that list of error I am getting:
yolo_console_dll.obj : error LNK2019: unresolved external symbol send_json_custom referenced in funct ion "public: bool _cdecl Detector::send_json_http(class std::vector<struct bbox_t,class std::allocat or >,class std::vector<class std::basic_string<char,struct std::char_traits,clas s std::allocator >,class std::allocator<class std::basic_string<char,struct std::char_traits,class std::allocator > > >,int,class std::basic_string<char,struct std::char_traits,c lass std::allocator >,int,int)" (?send_json_http@Detector@@QEAA_NV?$vector@Ubbox_t@@v?$allocato r@Ubbox_t@@@std@@@std@@v?$vector@V?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@v?$all ocator@V?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@@2@@3@HV?$basic_string@DU?$char traits@D@std@@v?$allocator@D@2@@3@HH@Z) [F:\Computer_Vision\Yolov4_Ear_Detection\darknet\build_win_re lease\uselib.vcxproj] yolo_console_dll.obj : error LNK2019: unresolved external symbol "public: cdecl Detector::Detector( class std::basic_string<char,struct std::char_traits,class std::allocator >,class std::ba sic_string<char,struct std::char_traits,class std::allocator >,int)" (??0Detector@@QEAA@V ?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@0h@Z) referenced in function main [F:\Co mputer_Vision\Yolov4_Ear_Detection\darknet\build_win_release\uselib.vcxproj] yolo_console_dll.obj : error LNK2019: unresolved external symbol "public: cdecl Detector::~Detector (void)" (??1Detector@@QEAA@XZ) referenced in function main [F:\Computer_Vision\Yolov4_Ear_Detection\d arknet\build_win_release\uselib.vcxproj] yolo_console_dll.obj : error LNK2019: unresolved external symbol "public: class std::vector<struct bb ox_t,class std::allocator > cdecl Detector::detect(struct image_t,float,bool)" (?det ect@Detector@@QEAA?AV?$vector@Ubbox_t@@v?$allocator@Ubbox_t@@@std@@@std@@Uimage_t@@M_N@Z) referenced in function "public: void cdecl::operator()(void)const "
(??R@@QEBAXXZ) [F:\Computer_Vision\Yolov4_Ear_Detection\dark
net\build_win_release\uselib.vcxproj]
yolo_console_dll.obj : error LNK2019: unresolved external symbol "public: static void cdecl Detecto
r::free_image(struct image_t)" (?free_image@Detector@@SAXUimage_t@@@z) referenced in function "public
: void cdecl ::operator()(struct image_t )const " (??R@@QEBAXPEAUimage_t@@@z) [F:\Computer_Vision\Yolov4_Ear_Detectio
n\darknet\build_win_release\uselib.vcxproj]
yolo_console_dll.obj : error LNK2019: unresolved external symbol "public: int cdecl Detector::get_n
et_width(void)const " (?get_net_width@Detector@@QEBAHXZ) referenced in function "public: class std::s
hared_ptr _cdecl Detector::mat_to_image_resize(class cv::Mat)const " (?mat_to_image
resize@Detector@@qeba?AV?$shared_ptr@Uimage_t@@@std@@VMat@cv@@@z) [F:\Computer_Vision\Yolov4_Ear_Dete
ction\darknet\build_win_release\uselib.vcxproj]
yolo_console_dll.obj : error LNK2019: unresolved external symbol "public: int cdecl Detector::get_n
et_height(void)const " (?get_net_height@Detector@@QEBAHXZ) referenced in function "public: class std:
:shared_ptr cdecl Detector::mat_to_image_resize(class cv::Mat)const " (?mat_to_imag
e_resize@Detector@@qeba?AV?$shared_ptr@Uimage_t@@@std@@VMat@cv@@@z) [F:\Computer_Vision\Yolov4_Ear_De
tection\darknet\build_win_release\uselib.vcxproj]
yolo_console_dll.obj : error LNK2019: unresolved external symbol "public: class std::vector<struct bb
ox_t,class std::allocator > cdecl Detector::tracking_id(class std::vector<struct bbo
x_t,class std::allocator >,bool,int,int)" (?tracking_id@Detector@@QEAA?AV?$vector@Ubbo
x_t@@v?$allocator@Ubbox_t@@@std@@@std@@v23@_NHH@Z) referenced in function "public: void cdecl ::operator()(void)const " (??R<lambda_ec00cba381fb570bb1b420e2b4c
90901>@@QEBAXXZ) [F:\Computer_Vision\Yolov4_Ear_Detection\darknet\build_win_release\uselib.vcxproj]
F:\Computer_Vision\Yolov4_Ear_Detection\darknet\build_win_release\Release\uselib.exe : fatal error LN
K1120: 8 unresolved externals [F:\Computer_Vision\Yolov4_Ear_Detection\darknet\build_win_release\usel
ib.vcxproj]
yolo_console_dll.obj : error LNK2019: unresolved external symbol send_json_custom referenced in funct
ion "public: bool _cdecl Detector::send_json_http(class std::vector<struct bbox_t,class std::allocat
or >,class std::vector<class std::basic_string<char,struct std::char_traits,clas
s std::allocator >,class std::allocator<class std::basic_string<char,struct std::char_traits,class std::allocator > > >,int,class std::basic_string<char,struct std::char_traits,c
lass std::allocator >,int,int)" (?send_json_http@Detector@@QEAA_NV?$vector@Ubbox_t@@v?$allocato
r@Ubbox_t@@@std@@@std@@v?$vector@V?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@v?$all
ocator@V?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@@2@@3@HV?$basic_string@DU?$char
traits@D@std@@v?$allocator@D@2@@3@HH@Z) [F:\Computer_Vision\Yolov4_Ear_Detection\darknet\build_win_re
lease\uselib_track.vcxproj]
yolo_console_dll.obj : error LNK2019: unresolved external symbol "public: cdecl Detector::Detector(
class std::basic_string<char,struct std::char_traits,class std::allocator >,class std::ba
sic_string<char,struct std::char_traits,class std::allocator >,int)" (??0Detector@@QEAA@V
?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@0h@Z) referenced in function main [F:\Co
mputer_Vision\Yolov4_Ear_Detection\darknet\build_win_release\uselib_track.vcxproj]
yolo_console_dll.obj : error LNK2019: unresolved external symbol "public: cdecl Detector::~Detector
(void)" (??1Detector@@QEAA@XZ) referenced in function main [F:\Computer_Vision\Yolov4_Ear_Detection\d
arknet\build_win_release\uselib_track.vcxproj]
yolo_console_dll.obj : error LNK2019: unresolved external symbol "public: class std::vector<struct bb
ox_t,class std::allocator > __cdecl Detector::detect(struct image_t,float,bool)" (?det
ect@Detector@@QEAA?AV?$vector@Ubbox_t@@v?$allocator@Ubbox_t@@@std@@@std@@Uimage_t@@M_N@Z) referenced
in function "public: void cdecl ::operator()(void)const "
(??R@@QEBAXXZ) [F:\Computer_Vision\Yolov4_Ear_Detection\dark
net\build_win_release\uselib_track.vcxproj]
yolo_console_dll.obj : error LNK2019: unresolved external symbol "public: static void cdecl Detecto
r::free_image(struct image_t)" (?free_image@Detector@@SAXUimage_t@@@z) referenced in function "public
: void cdecl ::operator()(struct image_t )const " (??R@@QEBAXPEAUimage_t@@@z) [F:\Computer_Vision\Yolov4_Ear_Detectio
n\darknet\build_win_release\uselib_track.vcxproj]
yolo_console_dll.obj : error LNK2019: unresolved external symbol "public: int cdecl Detector::get_n
et_width(void)const " (?get_net_width@Detector@@QEBAHXZ) referenced in function "public: class std::s
hared_ptr _cdecl Detector::mat_to_image_resize(class cv::Mat)const " (?mat_to_image
resize@Detector@@qeba?AV?$shared_ptr@Uimage_t@@@std@@VMat@cv@@@z) [F:\Computer_Vision\Yolov4_Ear_Dete
ction\darknet\build_win_release\uselib_track.vcxproj]
yolo_console_dll.obj : error LNK2019: unresolved external symbol "public: int __cdecl Detector::get_n
et_height(void)const " (?get_net_height@Detector@@QEBAHXZ) referenced in function "public: class std:
:shared_ptr cdecl Detector::mat_to_image_resize(class cv::Mat)const " (?mat_to_imag
e_resize@Detector@@qeba?AV?$shared_ptr@Uimage_t@@@std@@VMat@cv@@@z) [F:\Computer_Vision\Yolov4_Ear_De
tection\darknet\build_win_release\uselib_track.vcxproj]
yolo_console_dll.obj : error LNK2019: unresolved external symbol "public: class std::vector<struct bb
ox_t,class std::allocator > cdecl Detector::tracking_id(class std::vector<struct bbo
x_t,class std::allocator >,bool,int,int)" (?tracking_id@Detector@@QEAA?AV?$vector@Ubbo
x_t@@v?$allocator@Ubbox_t@@@std@@@std@@v23@_NHH@Z) referenced in function "public: void cdecl ::operator()(void)const " (??R<lambda_ec00cba381fb570bb1b420e2b4c
90901>@@QEBAXXZ) [F:\Computer_Vision\Yolov4_Ear_Detection\darknet\build_win_release\uselib_track.vcxp
roj]
F:\Computer_Vision\Yolov4_Ear_Detection\darknet\build_win_release\Release\uselib_track.exe : fatal er
ror LNK1120: 8 unresolved externals [F:\Computer_Vision\Yolov4_Ear_Detection\darknet\build_win_releas
e\uselib_track.vcxproj]
Copy-Item : Could not find a part of the path
'F:\Computer_Vision\Yolov4_Ear_Detection\darknet\share\darknet'.
At F:\Computer_Vision\Yolov4_Ear_Detection\darknet\build.ps1:205 char:3
Copy-Item cmake\Modules*.cmake share\darknet\