Node symbol lookup error opencv - c++

I am currently writing a C++ module for node that uses open cv, and I encountered an issue that I do not quite understand. Basically this is the method that I am trying to add
void GetPuzzle(const Nan::FunctionCallbackInfo<v8::Value>& args) {
v8::String::Utf8Value parameter(args[0]->ToString());
std::string filePath = std::string(*parameter);
Mat puzzle = imread("sudoku.jpg", 0);
}
Just to make sure that the included open cv is working properly. node-gyp build works, exits with an ok , however when I am actually running the server.js file I get the following exception :
node: symbol lookup error: /home/dave/Projects/puzzlesolver/build/Release/sudokuGrabber.node: undefined symbol: _ZN2cv6imreadERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi
This is the include of the opencv :
#include <opencv2/opencv.hpp>
I guess this info is important for solving the issue - I am working on linux (ubuntu). Any suggestion of what is wrong with my code and what could I do to fix it ?

Related

Fatal Error: comdef.h: No such file or directory

I installed Aspose.Cells and tried to write a simple C++ file that includes Aspose.Cells.h. I soon realized that I had to install two other external libraries, boost and icu4c as without these libraries my compiler would throw errors saying some h or hpp files can not be found.
My problem is: even after I installed these libraries, I still couldn’t compile my code, as I received a new error saying “Fatal ERROR: comdef.h: No such file or directory.”
And the error persisted even after I installed the latest version for SDK for Win 10.
My simple file can run if I remove the line "#include Aspose.Cells.h" .
Can someone please enlighten me as to how to solve this error?
Also I noticed there is a folder called “Publish” under “include” folder for Aspose.Cells. This folder is besides boost and icu. Could this mean Publish is the third external library to be installed? But I couldn’t find any library called Public on the web. Pls see the screenshot below.
directory of include folder that comes with the installed Aspose.Cells package
Thanks a lot!
My code is as follows:
#include <iostream>
#include <Aspose.Cells.h>
using namespace std;
int main() {
cout << "hello!!!" << endl;
return 0;
}
Regards
Hillary

Why am I getting "no such file or directory" for an opencv file that exists when compiling in Ubuntu?

I'm trying to use the OpenCV library in C++ (VSCode), so I have the statement #include <opencv4/opencv2/imgproc/imgproc.hpp>. When I try to compile using gcc in Ubuntu, however, I get the following error message:
/usr/local/include/opencv4/opencv2/imgproc/imgproc.hpp:48:10: fatal error: opencv2/imgproc.hpp: No such file or directory
#include "opencv2/imgproc.hpp"
I'm fairly new to C++ and Ubuntu in general so I have no idea why this is happening, as I double checked and the file absolutely exists. In fact, even though it's apparently skipped the imgproc folder in finding the file, imgproc.hpp exists both in opencv2 and in the folder imgproc inside opencv2 anyway. How do I get this to work?
Did you try using #include "opencv4/opencv2/imgproc/imgproc.hpp" instead?

Using Caffe in C++; Unable to pass caffe::SolverParameter to function without error

I am attempting to compile the "Hello World XOR" C++ example given by:
https://medium.com/#shiyan/caffe-c-helloworld-example-with-memorydata-input-20c692a82a22
Hardware:
EX50-UD3R Motherboard
GT-640 NVidia cards (2 Cards)
Intel 980 (6 core)
16Gig (4x4) DDR3 RAM
Environment:
Ubuntu 16.04.2 LTS Kernel: 4.4.0-78-generic
Eclipse Neon3 R4.6.3
CUDA 8.0
Caffe: whatever ver I downloaded from Berkley on 06/04/2017
I followed the installation instructions for installing Caffe in Ubuntu 16.04: https://github.com/BVLC/caffe/wiki/Ubuntu-16.04-or-15.10-Installation-Guide
and all the make commands succeeded.
However when I try to use the libraries in a simple cpp program:
#include <memory>
#include <cstdlib> // Provides NULL, rand, size_t;
#include <stdio.h> // For printf
#include <cstring> // For string
#include "/home/caffe-master/include/caffe/layers/memory_data_layer.hpp"
#include "/home/caffe-master-path>/include/caffe/caffe.hpp"
void blah( caffe::SolverParameter *sp);
int main()
{
... standard c++ code to generate random data deleted for brevity...
caffe::SolverParameter solver_param; // No errors given here for this declaration
blah( solver_param); // Simple function created to test error, same error appears here
caffe::ReadSolverParamsFromTextFileOrDie( path, &solver_param); // Actual function from XOR example, same error
caffe::ReadSolverParamsFromTextFileOrDie("./solver.prototxt", &solver_param); // This also gives same error
boost::shared_ptr<caffe::Solver<float> > solver(caffe::SolverRegistry<float>::CreateSolver(solver_param)); // Same error here
... code that would of passed random data to caffe deleted ...
return 0;
}
void blah( caffe::SolverParameter *sp)
{
std::cout << "BLAH: " << sp->rms_decay_;
return;
}
In Eclipse Neon I get the following error for any line that includes the variable solver_param including the lines that where I created the simple function blah which takes one argument of type caffe::SolverParameter *
Invalid arguments 'Candidates are:
void ReadSolverParamsFromTextFileOrDie(const std::__cxx11::basic_string,std::allocator> &, ? *)' caffe_hellow.cpp /caffe line 47 Semantic Error
I tried setting the full paths in the include path and that got rid of some errors, I added the libpath in eclipse to include caffe and boost and that got rid of more errors leaving only this one for now. I've been searching for a solution, looking at the .hpp caffe files to try to understand them and trying different settings in eclipse to get rid of this error but nothing works. Casting did not work either.
For some reason it does not recognize any variable declared as type SolverParameter as a compatible argument to a function that requires it. The error message gives "? *" as the argument type. What does that mean? Can you help? Thank you.
You need to include
#include "caffe/proto/caffe.pb.h"
For all caffe.proto related declarations
I am able to compile now. It is a consequence of being a noob at using IDE.
I had to add the libraries in Project->Properties->GCC C++ Linker-> Libraries (-l):
caffe
boost_system
glog
... and this may not be needed ... cuda
I also needed to add -L paths for the above. Then I needed to update either /etc/environment or .bashrc to include the paths for caffe and cuda in the LD_LIBRARY_PATH variable otherwise I would get an unable t link binary error. Again cuda may not be needed to solve this error the other three sure are. I plan to use Cuda-C to access the GPU processors. Thank you Shai for your response on the protoc item it lead me to the other comments on including libraries.

C++: Why does libtiff break the console-output?

So finally I’m not able to help myself out by researching anymore. Hopefully you can help me.
I recently decided to learn C++ in the context of my bachelor-thesis: My first aim is to read the pixel-values of a tiff-image with the libtiff-library. Yet, every call of a function of the library seems to break parts of my program.
Here’s the simple “HelloWorld”-Program, it works as it should:
#include "tiffio.h"
#include <iostream>
using namespace std;
int main() {
cout << "Hello" << endl;
// TIFF* tif = TIFFOpen("path to .tif", "r");
return 0;
}
When I uncomment the second line in main(), the code still does compile without errors (except the warning that ‘tif’ isn’t used) and I can start the program as usual. Yet nothing gets printed into the console anymore. Not “Hello” nor any errors.
Any suggestions where the error could be? The code should be alright, I guess I messed something up during the setup of the library or so. Here’s what I did:
I managed to set up eclipse (Mars, 32bit) for C++ and MinGW (32bit) on my 64bit Win7, then downloaded libtiff 4.0.4 and built it following this instruction.
I created a new C++-project with the mentioned code and did the following adjustments in the project-properties:
Project->Properties->C/C++ General->Paths and Symbols->Library
Paths-> Added “D:/… /tiff-4.0.4/libtiff/.libs”
Project->Properties->C/C++ Build->MinGW C++
Linker->Miscellaneous->Set Linkerflags to “-static-libgcc
-static-libstdc++”
Project->Properties->C/C++ Build->MinGW C++ Linker->Libraries-> Set
(-L) to “D:/… /tiff-4.0.4/libtiff/.libs” and (-l) to “libtiff”
I know the .tif is a valid file as I implemented parts of my program in C#, using the LibTiff.NET library by BitMiracle.
Thank you in advance!
Edit 1: The same error occures, even if TIFF* tif = TIFFOpen("path to .tif", "r"); is never called but written down in a dead part of the code. Debugging does not work either, the program seems to be terminated (exit value 0) before a single line is executed, without any error-reports.
I had the same issue and managed to get rid of it.
I set up eclipse (Mars) for C++ and MinGW on my 64bit Win7, then downloaded libtiff 4.0.4 and built it following this instruction.
After the build, I got two directories containing files:
include
tiff.h
tiffconf.h
tiffio.h
tiffio.hxx
tiffvers.h
lib
libtiff.a
libtiff.dll.a
libtiff.la
libtiffxx.a
libtiffxx.dll.a
libtiffxx.la
I also linked all include files and only the libtiff.a to my project and that solved it, ie, the other lines are now executed.
I hope, I helped with this post.

Assimp's aiImportFile() identifier not found

Here I have my headers:
// ASSIMP
#include <assimp\Importer.hpp>
#include <assimp\scene.h>
#include <assimp\postprocess.h>
It compiles and there's no unresolved externals so my library file should be correct.
But further down:
/* load file with assimp and print some stats */
const aiScene* scene = aiImportFile(file_name, aiProcess_Triangulate);
if (!scene) {
fprintf(stderr, "ERROR: reading mesh %s\n", file_name);
return false;
}
I get an error with aiImportFile that its identifier isn't found. Which is baffling as pretty much everything else from assimp works.
How do I fix this? At the moment compiling the source code of assimp doesn't work, I don't get any library files so I'm stuck with whats available under "full".
After much work on finding a solution, I'm pretty sure the problem was compiling the library in debug mode. I believe it only works in Release mode.
Unfortunately this was a while back and don't have the code currently on my computer so I'm not 100% sure, but I am 90% sure.