schwittlick / ofxDarknet

darknet neural network addon for openFrameworks
MIT License
496 stars 89 forks source link

Can't run in Linux (Ubuntu 16.04) #32

Open kidapu opened 6 years ago

kidapu commented 6 years ago

I cloned genekogan/linux branch, and I edited addon.config for my local path, and run example-yolo2 by following command, then I encountered error...

$ make clean
$ make 
$ make run

.
.
.

g++ -c -O3 -DNDEBUG -march=native -mtune=native -Wall -std=c++14 -DGCC_HAS_REGEX -DOF_USING_GTK -DOF_USING_GTK -DOF_USING_MPG123  -pthread -I/usr/local/include/opencv -I/usr/local/include -I/usr/include/gstreamer-1.0 -I/usr/lib/x86_64-linux-gnu/gstreamer-1.0/include -I/usr/include/AL -I/usr/include/libdrm -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/mirclient -I/usr/include/mircommon -I/usr/include/mircookie -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/home/kida/openFrameworks_098/libs/fmodex/include -I/home/kida/openFrameworks_098/libs/glfw/include -I/home/kida/openFrameworks_098/libs/glfw/include/GLFW -I/home/kida/openFrameworks_098/libs/glm/include -I/home/kida/openFrameworks_098/libs/glm/include/glm -I/home/kida/openFrameworks_098/libs/glm/include/glm/detail -I/home/kida/openFrameworks_098/libs/glm/include/glm/gtx -I/home/kida/openFrameworks_098/libs/glm/include/glm/gtc -I/home/kida/openFrameworks_098/libs/json/include -I/home/kida/openFrameworks_098/libs/kiss/include -I/home/kida/openFrameworks_098/libs/libxml2/include -I/home/kida/openFrameworks_098/libs/libxml2/include/libxml -I/home/kida/openFrameworks_098/libs/poco/include -I/home/kida/openFrameworks_098/libs/svgtiny/include -I/home/kida/openFrameworks_098/libs/tess2/include -I/home/kida/openFrameworks_098/libs/utf8/include -I/home/kida/openFrameworks_098/libs/utf8/include/utf8 -I/home/kida/openFrameworks_098/libs/utf8cpp/include -I/home/kida/openFrameworks_098/libs/utf8cpp/include/utf8 -I/home/kida/openFrameworks_098/libs/openFrameworks -I/home/kida/openFrameworks_098/libs/openFrameworks/gl -I/home/kida/openFrameworks_098/libs/openFrameworks/events -I/home/kida/openFrameworks_098/libs/openFrameworks/3d -I/home/kida/openFrameworks_098/libs/openFrameworks/app -I/home/kida/openFrameworks_098/libs/openFrameworks/types -I/home/kida/openFrameworks_098/libs/openFrameworks/math -I/home/kida/openFrameworks_098/libs/openFrameworks/communication -I/home/kida/openFrameworks_098/libs/openFrameworks/graphics -I/home/kida/openFrameworks_098/libs/openFrameworks/video -I/home/kida/openFrameworks_098/libs/openFrameworks/utils -I/home/kida/openFrameworks_098/libs/openFrameworks/sound -pthread -I/usr/local/include/opencv -I/usr/local/include -I/usr/include/gstreamer-1.0 -I/usr/lib/x86_64-linux-gnu/gstreamer-1.0/include -I/usr/include/AL -I/usr/include/libdrm -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/mirclient -I/usr/include/mircommon -I/usr/include/mircookie -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/home/kida/openFrameworks_098/addons/ofxDarknet/libs -I/home/kida/openFrameworks_098/addons/ofxDarknet/src -Isrc -I/home/kida/openFrameworks_098/addons/ofxDarknet/libs/darknet/include -I/usr/local/cuda/include -I/home/kida/openFrameworks_098/addons/ofxOpenCv/src -I/home/kida/openFrameworks_098/addons/ofxOpenCv/libs -MMD -MP -MF /home/kida/openFrameworks_098/addons/obj/linux64/Release/ofxOpenCv/src/ofxCvGrayscaleImage.d -MT /home/kida/openFrameworks_098/addons/obj/linux64/Release/ofxOpenCv/src/ofxCvGrayscaleImage.o -o /home/kida/openFrameworks_098/addons/obj/linux64/Release/ofxOpenCv/src/ofxCvGrayscaleImage.o -c /home/kida/openFrameworks_098/addons/ofxOpenCv/src/ofxCvGrayscaleImage.cpp

                             ^
/home/kida/openFrameworks_098/addons/ofxDarknet/src/ofxDarknet.cpp: In member function ‘void ofxDarknet::init(std::__cxx11::string, std::__cxx11::string, std::__cxx11::string)’:
/home/kida/openFrameworks_098/addons/ofxDarknet/src/ofxDarknet.cpp:18:43: error: ‘parse_network_cfg’ was not declared in this scope
  net = parse_network_cfg( cfgfile.c_str() );
                                           ^
/home/kida/openFrameworks_098/addons/ofxDarknet/src/ofxDarknet.cpp:20:41: error: ‘load_weights’ was not declared in this scope
  load_weights( &net, weightfile.c_str() );

/home/kida/openFrameworks_098/addons/ofxDarknet/src/ofxDarknet.cpp: In member function ‘void ofxDarknet::train_rnn(std::__cxx11::string, std::__cxx11::string)’:
/home/kida/openFrameworks_098/addons/ofxDarknet/src/ofxDarknet.cpp:346:51: error: ‘parse_network_cfg’ was not declared in this scope
  network net = parse_network_cfg( cfgfile.c_str() );
                                                   ^
/home/kida/openFrameworks_098/addons/ofxDarknet/src/ofxDarknet.cpp:389:28: error: ‘save_weights’ was not declared in this scope
    save_weights( net, buff );
                            ^
/home/kida/openFrameworks_098/addons/ofxDarknet/src/ofxDarknet.cpp:394:28: error: ‘save_weights’ was not declared in this scope
    save_weights( net, buff );
                            ^
/home/kida/openFrameworks_098/addons/ofxDarknet/src/ofxDarknet.cpp:399:26: error: ‘save_weights’ was not declared in this scope
  save_weights( net, buff );

/home/kida/openFrameworks_098/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:336: recipe for target '/home/kida/openFrameworks_098/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o' failed
make[1]: *** [/home/kida/openFrameworks_098/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/kida/openFrameworks_098/addons/ofxDarknet/example-yolo2'
/home/kida/openFrameworks_098/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:125: recipe for target 'Release' failed
make: *** [Release] Error 2
HOST_OS=Linux
checking pkg-config libraries:   cairo zlib gstreamer-app-1.0 gstreamer-1.0 gstreamer-video-1.0 gstreamer-base-1.0 libudev freetype2 fontconfig sndfile openal openssl glfw3 gl glu glew gtk+-3.0 libmpg123 
/bin/sh: 1: ./example-yolo2: not found
/home/kida/openFrameworks_098/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:169: recipe for target 'run' failed
make: *** [run] Error 127

I can find load_weights and save_weights functions in libs/darknet/include/parser.h.

Why do xxx was not declared in this scope errors happen?

My enviroment is below.

genekogan commented 6 years ago

yes, sorry, i have the same problems on my side as well. have to rebuild darknet for linux, the library we have now is giving these linker errors. if you manage to get it built on your side, a PR would be very welcome.

kidapu commented 6 years ago

@genekogan I cloned latest darknet repository, and build it, and replace ofxDarknet in forked my repository.

https://github.com/kidapu/ofxDarknet/commit/4434d9a3c4199f6e5ae9de42c52ac8eb48e30b52

I encountered many errors, I fixed it as much as possible.

However, I can't understand how to solve the last error.

/home/kida/openFrameworks_098/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o: In function `void std::__insertion_sort<__gnu_cxx::__normal_iterator<unsigned long*, std::vector<unsigned long, std::allocator<unsigned long> > >, __gnu_cxx::__ops::_Iter_comp_iter<ofxDarknet::yolo(ofPixels_<unsigned char>&, float, float)::{lambda(int, int)#1}> >(__gnu_cxx::__normal_iterator<unsigned long*, std::vector<unsigned long, std::allocator<unsigned long> > >, __gnu_cxx::__ops::_Iter_comp_iter<ofxDarknet::yolo(ofPixels_<unsigned char>&, float, float)::{lambda(int, int)#1}>, __gnu_cxx::__ops::_Iter_comp_iter<ofxDarknet::yolo(ofPixels_<unsigned char>&, float, float)::{lambda(int, int)#1}>)':
ofxDarknet.cpp:(.text+0xae): undefined reference to `max_index(float*, int)'
ofxDarknet.cpp:(.text+0xcd): undefined reference to `max_index(float*, int)'
ofxDarknet.cpp:(.text+0x13d): undefined reference to `max_index(float*, int)'
ofxDarknet.cpp:(.text+0x164): undefined reference to `max_index(float*, int)'
/home/kida/openFrameworks_098/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o: In function `void std::__adjust_heap<__gnu_cxx::__normal_iterator<unsigned long*, std::vector<unsigned long, std::allocator<unsigned long> > >, long, unsigned long, __gnu_cxx::__ops::_Iter_comp_iter<ofxDarknet::yolo(ofPixels_<unsigned char>&, float, float)::{lambda(int, int)#1}> >(__gnu_cxx::__normal_iterator<unsigned long*, std::vector<unsigned long, std::allocator<unsigned long> > >, long, __gnu_cxx::__normal_iterator<unsigned long*, std::vector<unsigned long, std::allocator<unsigned long> > >, unsigned long, __gnu_cxx::__ops::_Iter_comp_iter<ofxDarknet::yolo(ofPixels_<unsigned char>&, float, float)::{lambda(int, int)#1}>)':
ofxDarknet.cpp:(.text+0x247): undefined reference to `max_index(float*, int)'
/home/kida/openFrameworks_098/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o:ofxDarknet.cpp:(.text+0x270): more undefined references to `max_index(float*, int)' follow
/home/kida/openFrameworks_098/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o: In function `ofxDarknet::get_network_output_layer_gpu(int)':
ofxDarknet.cpp:(.text+0x9a5): undefined reference to `cuda_pull_array(float*, float*, unsigned long)'
/home/kida/openFrameworks_098/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o: In function `ofxDarknet::nightmare(ofPixels_<unsigned char>&, int, int, int, int, int, int, float, float)':
ofxDarknet.cpp:(.text+0xa54): undefined reference to `make_image(int, int, int)'
/home/kida/openFrameworks_098/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o: In function `ofxDarknet::convert(ofPixels_<unsigned char>&)':
ofxDarknet.cpp:(.text+0xe93): undefined reference to `make_image(int, int, int)'
/home/kida/openFrameworks_098/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o: In function `ofxDarknet::classify(ofPixels_<unsigned char>&, int)':
ofxDarknet.cpp:(.text+0x116a): undefined reference to `make_image(int, int, int)'
ofxDarknet.cpp:(.text+0x125b): undefined reference to `network_predict(network, float*)'
ofxDarknet.cpp:(.text+0x1284): undefined reference to `top_k(float*, int, int, int*)'
ofxDarknet.cpp:(.text+0x14c8): undefined reference to `free_image(image)'
/home/kida/openFrameworks_098/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o: In function `ofxDarknet::getFeatureMaps(int)':
ofxDarknet.cpp:(.text+0x1c41): undefined reference to `cuda_pull_array(float*, float*, unsigned long)'
/home/kida/openFrameworks_098/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o: In function `ofxDarknet::init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
ofxDarknet.cpp:(.text+0x1fb8): undefined reference to `parse_network_cfg(char*)'
ofxDarknet.cpp:(.text+0x1fd7): undefined reference to `load_weights(network*, char*)'
ofxDarknet.cpp:(.text+0x1fe4): undefined reference to `set_batch_network(network*, int)'
ofxDarknet.cpp:(.text+0x2cce): undefined reference to `get_labels(char*)'
/home/kida/openFrameworks_098/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o: In function `ofxDarknet::yolo(ofPixels_<unsigned char>&, float, float)':
ofxDarknet.cpp:(.text+0x305c): undefined reference to `make_image(int, int, int)'
ofxDarknet.cpp:(.text+0x31e3): undefined reference to `network_predict(network, float*)'
ofxDarknet.cpp:(.text+0x3259): undefined reference to `get_region_boxes(layer, int, int, int, int, float, float**, box*, float**, int, int*, float, int)'
ofxDarknet.cpp:(.text+0x3295): undefined reference to `do_nms_sort(box*, float**, int, int, float)'
ofxDarknet.cpp:(.text+0x32b0): undefined reference to `free_image(image)'
ofxDarknet.cpp:(.text+0x3355): undefined reference to `cuda_pull_array(float*, float*, unsigned long)'
ofxDarknet.cpp:(.text+0x3673): undefined reference to `max_index(float*, int)'
ofxDarknet.cpp:(.text+0x3696): undefined reference to `max_index(float*, int)'
ofxDarknet.cpp:(.text+0x3780): undefined reference to `max_index(float*, int)'
ofxDarknet.cpp:(.text+0x37d4): undefined reference to `get_color(int, int, int)'
ofxDarknet.cpp:(.text+0x37ef): undefined reference to `get_color(int, int, int)'
ofxDarknet.cpp:(.text+0x3807): undefined reference to `get_color(int, int, int)'
ofxDarknet.cpp:(.text+0x4030): undefined reference to `free_ptrs(void**, int)'
collect2: error: ld returned 1 exit status
/home/kida/openFrameworks_098/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:382: recipe for target 'bin/example-yolo2' failed
make[1]: *** [bin/example-yolo2] Error 1
make[1]: Leaving directory '/home/kida/openFrameworks_098/addons/ofxDarknet/example-yolo2'
/home/kida/openFrameworks_098/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:125: recipe for target 'Release' failed
make: *** [Release] Error 2
HOST_OS=Linux
checking pkg-config libraries:   cairo zlib gstreamer-app-1.0 gstreamer-1.0 gstreamer-video-1.0 gstreamer-base-1.0 libudev freetype2 fontconfig sndfile openal openssl glfw3 gl glu glew gtk+-3.0 libmpg123 
/bin/sh: 1: ./example-yolo2: not found
/home/kida/openFrameworks_098/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:169: recipe for target 'run' failed
make: *** [run] Error 127

Please tell me if you have a solution.

sivagnanamn commented 6 years ago

@kidapu Does this issue still exists? Were you able to get it working in Linux?

schwittlick commented 6 years ago

I'm very sorry for being quiet on this issue, I have not had time figure this out. I'll probably update ofxDarknet with the latest darknet repository soon and figure out a way to make this addon work on linux as well. I will check your fork @kidapu along the way, thanks for struggling <3

ghost commented 6 years ago

Hello, Was this resolved? Are there instructions for running on Linux? Thanks,

timonsku commented 5 years ago

It seems development for this on hold at the moment? No updates for 1.5 years. I would be very much interested in a Linux version as well. Compiling darknet for linux is no problem for me. Is there anything I have to take care of when compiling it for this addon? Is the newest version compatible with the addon? Doesnt look like the function calls changed but it got restructured quite a bit.