I have installed OpenCv with Homebrew on my MacOs. I have added libopencv 4.0.1.dylib in Xcode. When I try to build, Xcode cannot find the files. Any suggestions?
I changed my path but still have problems.
Main code:
#include <iostream>
#include <opencv4/opencv2/opencv.hpp>
int main(int argc, const char * argv[]) {
// insert code here...
std::cout << "Hello, World!\n";
return 0;
}
Build settings including path:
Error messages:
Related
I run KDE Neon 20.04 and whenever i try to run this command block in Sublime Text i get this error.
#include "SDL2.h"
#include "SDL2_image"
#include <iostream.h>
int main(int argc, char* args[])
{
std::cout << "Yay" << std::endl;
return 0;
}
SDL2.h there is no such file or directory
You have to install SDL development libraries first. You can install it using the command sudo apt-get install libsdl2-dev.
You are also including sdl headers wrong.
This is the correct way.
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
I am writing a custom CMake find module to use a 3rd party library and would like to extract its version string to use with:
find_package_handle_standard_args(MySDK
REQUIRED_VARS LIBRARY INCLUDE
VERSION_VAR VERSION
)
However its version number is not available as text in the header so I have to build a small c++ program to print it to stdout:
#include <MySDK.h>
int main(int argc, const char * argv[]) {
MySDK::Version version = MySDK::getVersion();
std::cout << version.text << "\n";
return 0;
}
I have tried adding to my custom FindMySDK.cmake something like this:
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/version.cpp"
"
#include <MySDK.h>
int main(int argc, const char * argv[]) {
MySDK::Version version = MySDK::getVersion();
std::cout << version.text << \"\\n\";
return 0;
}
"
)
add_executable(MySDKVersion
EXCLUDE_FROM_ALL
"${CMAKE_CURRENT_BINARY_DIR}/version.cpp"
)
target_include_directories(MySDKVersion SYSTEM PRIVATE ${MYSDK_INCLUDE_DIRS})
target_link_libraries(MySDKVersion ${MYSDK_LIBRARIES})
execute_process(COMMAND "$<TARGET_FILE:MySDKVersion>")
But it outputs an empty string. Is there a better way to do this kind of thing?
You need to use the try_run command.
Note, that this won't work when cross-compiling, because when cross-compiling any built binaries are not runnable on the host. However when it's your last option, that's what you use.
Here is link for png++ :http://savannah.nongnu.org/projects/pngpp/
What I'm doing wrong?
I installed opencv for OS X by command in terminal:"brew install opencv" and I have problems with using library png++.
#include <iostream>
#include "png++/png.hpp"
using namespace std;
int main(int argc, const char * argv[])
{
png::image< png::rgb_pixel > image("74");
for(int i=0;i<image.get_width();i++)
{
for(int j=0;j<image.get_height();j++)
{
image[i][j]=png::rgb_pixel(255-image[i][j].red, 255-image[i][j].green, 255-image[i][j].blue);
}
}
image.write("output.png");
return 0;
}
And I have next errors:
error messages
Problem was, that I install opencv with brew, which I installed on Yosemite. When I updated brew on ElCapitan and reinstalled opencv, errors disappeared.
Has anybody experience compiling/linking with Grantlee on Ubuntu?
libgrantlee-dev is installed and auto-completion in QtCreator works fine, however I do not manage to get the example to build:
#include <grantlee_core.h>
#include <grantlee_templates.h>
#include <grantlee/engine.h>
#include <grantlee/template.h>
#include <grantlee/context.h>
#include <grantlee/variable.h>
int main(int argc, char *argv[])
{
Grantlee::Engine *engine = new Grantlee::Engine( 0 );
Grantlee::Template t = engine->newTemplate("My name is {{ name }}.", "my_template_name");
QVariantHash mapping;
mapping.insert("name", "Grainne");
Grantlee::Context c(mapping);
t->render(&c); // Returns "My name is Grainne."
mapping.insert("name", "Henry");
c = Grantlee::Context(mapping);
qDebug() << t->render(&c); // Returns "My name is Henry."
qmake && make results in:
undefined reference to `Grantlee::Engine::Engine(QObject*)'
and many other undefined-reference-errors, as I've missed some includes.
Any ideas?
Thanks in advance
Let's take a look at my project.
I'm using Visual Studio 2008, Python 2.7 and numpy 1.8.1 (but I have tried several versions and none worked). My project is being compiled on debug mode.
It's a very simple code:
/* = Main.cpp file = */
#include "stdafx.h"
#include "Python.h"
int _tmain(int argc, _TCHAR* argv[])
{
PyObject *pName, *main;
Py_Initialize();
pName = PyUnicode_FromString("main");
main = PyImport_Import(pName);
Py_XDECREF(pName);
if (main != NULL)
{
printf("Python Module Loaded!!\n");
}
else
{
printf("Unable to load Python Module!!\n");
}
return 0;
}
And
""" = Main.py file = """
print 'Hello World!'
If I execute this code, I get:
As it is expected.
My problem arises as soon as I change main.py into:
""" = Main.py file = """
import numpy
print 'Hello World!'
Then I get the:
I have tried to run main.py separately on a python interpreter (not embedding it into C++) and then everything works just fine:
I have also tried a modification on the main.cpp as follows:
#include "stdafx.h"
#include "Python.h"
int _tmain(int argc, _TCHAR* argv[])
{
PyObject *pName, *main;
Py_Initialize();
PyRun_SimpleString("import numpy");
return 0;
}
From this code the output is:
Finally I also tried compiling original version of main.cpp code in release mode and then the output is:
So, my question here is: What can I do to get numpy working under debug compilations using an embedded interpreter on Visual Studio 2008?
You know you have to have use a python debug version built don't you? That is probably your problem. (I would leave a comment but no rep ): )