I am developing software where I need to use the OpenCV libraries under NetBeans. Took 2 days to be able to run correctly a C++ Application with OpenCV.
In a C++ Application I needed to add C:/OpenCV245/build/include in project properties->Build->C++ compiler-> Include Directories and Headers. Also, Under the Linker properties-> Additional Library Directories I had to add the following directories
C:/OpenCV245/release/lib
C:/OpenCV245/build/x64/mingw/lib
and add the .dll files I specifically needed in the linker->libraries
Now when I try to create a C++ Qt application, I add the proper include directories and headers but I can't add the path to my "additional libraries"...
I tried building to see what errors would pop:
cannot find -lopencv_core245.dll
cannot find -lopencv_highgui245.dll
How do we add .dll.a files to a C++ Qt application under Netbeans?
Programming environment:
NetBeans 7.4
MinGW 3.2 Compiler c++ compiler, msys make command and qt5.1.1 qmake for Qmake Command
Qt5.1.1
OpenCV2.4.5
Windows 8 64 bit
It appears as if you are trying to link with the *.DLL files instead of *.LIB files. The right way to go is to:
In the linker->libraries settings link to the *.LIB files you need instead of the *.DLL files.
Compile your program so you get an *.EXE
Put the relevant *.DLL-files in the same folder as the *.EXE
The program is now runnable if you double-click its icon in the file browser.
It the program refuses to run from Netbeans but it works from the file browser, then that is because you need to tell Netbeans what the "current working directory" is when you launch the program in debug mode. This setting should be available in some settings dialog.
+Under Project Properties-> Build -> Qt go to Expert Custom Definitions add add the path to the appropriate .dll.a files with the LIBS +=
+Under Project Properties-> Build -> C++ Compiler in Include Directories and Headers add the appropriate path for the includes. ex: C:\OpenCV\build\include
+Under Project Properties-> Build -> Linker click on Libraries then Add Library File... ( NOT ADD LIBRARY) and add the appropriate .dll.a files that were included in the first point.
Related
I'm working on a c++ project on my Raspberry Pi. I'm using Visual Studio 2017 to cross-compile the project to my Raspberry.
But when I try to compile the project, I get the error"cannot open source file" in lots of header files.
I already managed to compile simple projects, but now I need to Include Directories and I don't know the proper syntax to set, on Visual Studio's project properties page, the Include Directories to tell the compile where the header files are stored.
For the PCL library, e.g., I was able to include directories using '$(INCLUDE_PCL)'.
But when I try to include pi's directory '/usr/Include/ni' I can't correctly set the absolute path. Here's an screenshot of my properties page (https://ibb.co/G2dszrx). I haven't set the Linker directories yet, since I'm currently getting errors on the compiling phase.
Does anyone knows how to set absolute path to include directories correctly?
EDITED:
Trying to figure this out, I created a new project (Proj) in which I include the file 'try.cpp' stored in the raspberry's "home/pi/projects" folder. This project is in the "/home/pi/projects/Proj" folder.
In the project property page, I have:
Configuration Properties>General>Remote Build Root Directory --> ~/projects
Configuration Properties>General>Remote Build Project Directory --> $(RemoteRootDir)/$(ProjectName)
C/C++>General>Additional Include Directories --> $(RemoteRootDir)
When I compile the project this path gets created correctly, and the project is saved at the correct place, even if go further into more folders in the remote build project directory, but it can't find the include file "try.h".
How can Visual Studio know where to save the project using '$(RemoteRootDir)', but is not able to add that path include directory?
After some searching I managed to correctly add the Additional Include Directories, and Additional Libraries.
Firstly I was also using OpenNI, to work with the PCL. After many tries, I discovered that OpenNI was not correctly installed. So I managed to install it with apt-get.
Secondly, If you want to include the "/home/pi/someDIR" directory at the Raspberry device, just add "/home/pi/someDIR" to Visual Studio's additional include directories.
For you still trying to achieve this, Merlyn Oppenheim, from visual studio, set up a sample project using VS 2019 and Raspberry PI template -> https://github.com/merlynoppenheim/sample-rasp-inc-headers
For this sample project the Visual Studio properties page should have:
C/C++ -> General -> Additional Include Directories = '/home/pi/projects/vcpkg/packages/sqlite3_x64-linux/include;%(AdditionalIncludeDirectories)'
C/C++ -> Linker -> General -> Additional Library Directories = '/home/pi/projects/vcpkg/packages/sqlite3_x64-linux/debug/lib;%(AdditionalLibraryDirectories)'
C/C++ -> Linker -> Input -> Library Dependencies = 'wiringPi;sqlite3;pthread;dl'
I generate an Xcode project from CMake that builds a static library and test executable.
After the library is built, there is a file copy operation that moves the headers to a central directory (an include folder next to the built library).
This directory is not listed in the header search paths for either project (I have verified this inside the Xcode project and CMakeLists files).
When I am working in the generated Xcode project, the Issue Navigator will open the files in the central directory instead of the files used to build the project.
Can anyone tell me why this happens and how I can fix it?
Thanks for your help.
Use a separate build directory. Create a new directory. Navigate to that in terminal and say :
cmake -G Xcode <path_to_source>
I'm trying to compile a VS2008 C++ project on a 64bit platform. In this project I use boost threads. I can correctly compile the project on a 32bit platform.
On the 64bit platform I downloaded a pre-compiled boost libreries (for 64bit). I added the path to the compiled libs directory in C/C++ -> General -> Additional Include Directories. I'm sure the path is the correct.
When i try to compile I get the error:
Error 34 fatal error LNK1104: cannot open file 'libboost_thread-vc90-mt-1_49.lib' BioCpp BioCpp
I'm sure I actually have this file on my computer, and that i correctly set the C/C++ -> General -> Additional Include Directories path.
Maybe I'm missing something else...can someone provide some help?
PS: I'm working on a shared server, I cannot build the libraries.
This is a library, not an include file, so the "Additional Include Directories" setting is irrelevant. Add the path to the "Additional Library Directories" setting under "Linker" in the project configuration.
I'm pretty dump :) So could anybody help and write step-by-step manual, how to install "cairo", "glut" and use it in VS 2010 project (C++) on Windows 7?
PS: the most fun thing that i managed to do that without any problem in Linux.
I don't know cairo, but setting up GLUT is rather straightforward.
Download FreeGLUT
Unpack the downloaded archive
Go the directory unpack-dir/freeglut-x.x.x/VisualStudio2008
Open the visual studio project
Rebuild the project for each target (release, debug) you want to create
This should create a DLL file and a lib file with the same name. Now if you want to create a new project that uses GLUT, just configure the project correctly:
Create new project
Create a main C/C++ file (otherwise, you won't be able to set the include settings)
Go to project settings (right click project -> Configuration properties)
C/C++ -> General: add the freeglut include directory to Additional Include Directories
Linker -> General: add the path to the built .lib (freeglut) file under Additional Library Directories
Under Linker (input) settings: add the name of the .lib file under Additional Dependencies
If you follow this setup, you should be able to use GLUT (#include <GL/glut.h>) in your code and it should compile nicely. Not sure how you can also add cairo, but it will probably be a very similar process.
I'm trying to get the Boost library working in my C++ projects in Eclipse. I can successfully build when using header-only libraries in Boost such as the example simple program in the "Getting Started" guide using the lambda header.
I cannot get my project to successfully link to the regex Boost library as shown later in the guide. Under my project properties -> c/c++ build -> settings -> tool settings tab -> libraries, I have added "libboost_regex" to the Libraries box, and "C:\Program Files\boost\boost_1_42_0\bin.v2\libs" to the Library search path box since this is where all the .lib files are. I've even tried adding "libboost_regex-mgw34-mt-d-1_42.lib" to the libraries box instead of "libboost_regex" since that is the exact file name, but this did not work either.
I keep getting an error that says "cannot find -llibboost_regex" when I try to build my project. Any ideas as to how I can fix this?
Edit: on Windows XP, using mingw, and I have tried "boost_regex" as well..
I just went through the whole process of installing MinGW, compiling boost and installing Eclipse CDT and I'm able to compile simple programs using boost:regex. I'll write down all the steps. I hope that can be of help.
I've installed MinGW and MSYS in their default location.
Here are the step I took to build boost:
Download boost-jam-3.1.18-1-ntx86.zip from http://sourceforge.net/projects/boost/files/boost-jam
Put bjam.exe somewhere in your PATH
Unpack boost in C:\mingw\boost_1_42_0
Open an msys terminal window and cd /c/mingw/boost_1_42_0
In the boost directory run bjam --build-dir=build toolset=gcc stage
To configure Eclipse:
Add CDT to Eclipse 3.5 from the update site
Create a new C++ project
Under the Project menu select properties
Make sure the configuration is Debug [Active]
In "C/C++ General" > "Paths and Symbols"
Under the Includes tab select the GNU C++ language and add C:\MinGW\boost_1_42_0
Under the Library Paths tab add C:\MinGW\boost_1_42_0\stage\lib
In "C/C++ Build" > "Settings"
Select MinGW C++ Linker > Libraries
Click on the add button for Libraries (-l)
Type libboost_regex-mgw34-mt-d (without the .lib)
You can then go through the same steps for the Release configuration but use libboost_regex-mgw34-mt instead. Also make sure your source files include <boost/regex.hpp>
To link to boost library in eclipse you need to set both the eclipse's project library path(the one with the -L) and the name of the library(the one with the -l).
The prefix 'lib' and the extension of the library's name must be removed:-
eg: libboost_regex.a should be specified as boost_regex.
I believe your lib path is pointing to the wrong place. The libs will be installed to:
boost_install_dir\boost_1_42\lib
I think the default boost_install_dir is "C:\Program Files\Boost" (not sure because I don't use the default install directory).