I installed opencv 2.3.1 with macports and the newest Eclipse CDT. Now I'm trying to compile this code:
> #include <iostream.h>
> #include <cv.h> // or opencv.hpp, no difference
>
> int main(int argc, char **argv) {
>
>
> }
I have done all the steps of http://opencv.itseez.com/doc/tutorials/introduction/linux_eclipse/linux_eclipse.html but the output of the compiler is:
> make all Building file: ../main.cpp Invoking: GCC C++ Compiler g++
> -I/opt/local/include/opencv -I/opt/local/include/opencv2 -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp" In file included from
> /usr/include/c++/4.2.1/backward/iostream.h:31,
> from ../main.cpp:8: /usr/include/c++/4.2.1/backward/backward_warning.h:32:2: warning:
> #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section
> 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of
> the deprecated header <iostream.h>. To disable this warning use
> -Wno-deprecated. In file included from ../main.cpp:9: /opt/local/include/opencv2/opencv.hpp:46:33: error:
> opencv2/core/core_c.h: No such file or directory
> /opt/local/include/opencv2/opencv.hpp:47:33: error:
> opencv2/core/core.hpp: No such file or directory
> /opt/local/include/opencv2/opencv.hpp:48:39: error:
> opencv2/flann/miniflann.hpp: No such file or directory
> /opt/local/include/opencv2/opencv.hpp:49:39: error:
> opencv2/imgproc/imgproc_c.h: No such file or directory
> /opt/local/include/opencv2/opencv.hpp:50:39: error:
> opencv2/imgproc/imgproc.hpp: No such file or directory
> /opt/local/include/opencv2/opencv.hpp:51:35: error:
> opencv2/video/video.hpp: No such file or directory
> /opt/local/include/opencv2/opencv.hpp:52:45: error:
> opencv2/features2d/features2d.hpp: No such file or directory
> /opt/local/include/opencv2/opencv.hpp:53:43: error:
> opencv2/objdetect/objdetect.hpp: No such file or directory
> /opt/local/include/opencv2/opencv.hpp:54:39: error:
> opencv2/calib3d/calib3d.hpp: No such file or directory
> /opt/local/include/opencv2/opencv.hpp:55:29: error: opencv2/ml/ml.hpp:
> No such file or directory /opt/local/include/opencv2/opencv.hpp:56:39:
> error: opencv2/highgui/highgui_c.h: No such file or directory
> /opt/local/include/opencv2/opencv.hpp:57:39: error:
> opencv2/highgui/highgui.hpp: No such file or directory
> /opt/local/include/opencv2/opencv.hpp:58:39: error:
> opencv2/contrib/contrib.hpp: No such file or directory make: ***
> [main.o] Error 1
>
> **** Build Finished ****
What am I doing wrong?
okay.. I have had a lot of trouble in this myself.
You need to look int the opencv folder structure that you installed for these header files yourself. Sometimes they're not in the place the install guide tells you they are.
In my computer for example, most of the header files I needed are in:
[INSTALL DIRECTORY]/include/opencv
[INSTALL DIRECTORY]/include/opencv2
but SOME were in:
[INSTALL DIRECTORY]/modules/core/include/opencv2
[INSTALL DIRECTORY]/modules/highgui/include/opencv2 etc
you need to find those include files. Then go to your IDE (eclipse). In eclopse there should be a setting for the "include directories"
Set your IDE to look for include files in the directories where you know the include files are.
Then make sure you add the libraries. Ask if you need help with that.
The errors listed above shows that you have not specified the paths of include directories.first you search for the include directories in your installation folder.Generally they are in /home/usr/include/opencv and /home/usr/local/include/opencv
After locating these files you open project properties in Eclipse CDT. Select GCC C++ compiler -- directories and add the include directories there. Select GCC C++ Linker option and give the library path generally it is /usr/local/lib
Specify the libraries in quotes too e.g. "cv" , "highgui" etc.This will complete the configuration.
Hope it helps.
Related
I have installed Boost Python in C:\boost in which the installation was run from C:\Program Files\boost_1_65_1 as the root directory.
|C:\
|--|boost
|--|--|bin
|--|--|share
|C:\
|--|Program Files
|--|--|boost_1_65_1
C:\MinGW\bin has been added to system's PATH. In Eclipse, the #include <boost/python.hpp> or anything relating to <boost\[directory]> keeps returning 'Unresolved inclusion' error.
I have added C:\MinGW\bin to system's 'Path'. In Eclipse I added the following to GNU C++ 'Include directories' in 'Paths and Symbols':
C:\boost
C:\Program Files\boost\boost_1_65_1\libs
C:\Program Files\boost\boost_!_65_1\boost
C:\MinGW\lib\gcc\mingw32\5.3.0\include\c++
What are the settings that need to be edited?
bjam --debug-configuration has to be run from the root folder
C:\Program Files\boost\boost_1_65_1
At the end of the compilation, go to
Project Properties > C/C+ Build
and add the links to the compiler include paths (in my case it was Cross G++ Compiler > Include). The boost library should now be accessible from #include <boost/whatever>.
I have successfully generated Objc .m and .h files from my simplistic Dagger-2 code.
https://gist.github.com/OscarRyz/ffd976fcae9acf87dbe1
Now I'm trying to compile those file using j2objcc but the error message says it can't find .h for the the Dagger-2 classes:
j2objcc -c -I. `find app -name *.m`
In file included from app/DaggerSearchComponent.m:10:
./app/SearchInPage_Factory.h:10:10: fatal error: 'dagger/internal/Factory.h' file not found
#include "dagger/internal/Factory.h"
^
1 error generated.
app/SearchComponent.m:11:10: fatal error: 'dagger/Component.h' file not found
#include "dagger/Component.h"
^
1 error generated.
In file included from app/SearchInPage_Factory.m:8:
./app/SearchInPage_Factory.h:10:10: fatal error: 'dagger/internal/Factory.h' file not found
#include "dagger/internal/Factory.h"
^
1 error generated.
In file included from app/SearchInPage_MembersInjector.m:9:
./app/SearchInPage_MembersInjector.h:10:10: fatal error: 'dagger/MembersInjector.h' file not found
#include "dagger/MembersInjector.h"
^
1 error generated.
app/SearchModule.m:10:10: fatal error: 'dagger/Module.h' file not found
#include "dagger/Module.h"
^
1 error generated.
In file included from app/SearchModule_ProvideHostFactory.m:8:
./app/SearchModule_ProvideHostFactory.h:10:10: fatal error: 'dagger/internal/Factory.h' file not found
#include "dagger/internal/Factory.h"
^
1 error generated.
In file included from app/SearchModule_ProvideHttpClientFactory.m:9:
./app/SearchModule_ProvideHttpClientFactory.h:10:10: fatal error: 'dagger/internal/Factory.h' file not found
#include "dagger/internal/Factory.h"
^
1 error generated.
Question: Does this means that I need to have the library source code while generating the ObjC code so the .h for those could be generated as well?
Original answer from #tabll
Dagger isn't distributed with j2objc, so you have to build it yourself. To do so (requires Maven, described in the Building J2ObjC wiki):
git clone https://github.com/google/dagger.git
cd dagger
mvn install
j2objc -d build -classpath $J2OBJC_HOME/lib/javax-inject.jar -sourcepath core/src/main/java `find core/src/main/java -name *.java`
cd build
j2objcc -c -I. `find dagger -name *.m`
ar -r libdagger.a *.o
Notes:
Specify J2OBJC_HOME either where your j2objc distribution was unzipped, or if you built j2objc, its dist directory. To test, "ls $J2OBJC_HOME/j2objc" should list the j2objc script.
These instructions generate the macosx architecture, useful when testing. The files need to be recompiled for each architecture you want to use -- the easiest way to do so is to create a static library project in Xcode, add the translated files, then include this project in your app and add it as a dependency of your app.
ar will warn that "libdagger.a(package-info.o) has no symbols", which can be ignored since it doesn't have any symbols.
I want to use Armadillo with Eclipse. However all the instructions to link Armadillo is given for Visual Studio. Now I followed the instructions outlined in the ReadMe file of the Armadillo library. I added the Armadillo include folder in project(right click)->properties->C/C++ Build->Settings->Cross G++ Compiler->Includes->Inlcude paths(-I) and then I added the libraries folder (The library folder contain lapack and blas .lib and .dll files) in project(right click)->properties->C/C++ Build->Settings->Cross G++ Linker->Libraries->Library search path (-L).
However when I compile the code in the Eclipse I get the error
.....armadillo_bits/lapack_wrapper.hpp:37: undefined reference to `dgetrf_'.
Shouldn't it simply search for .lib files in the library folder and include them during compiling? I would appreciate any help regarding this matter.
Regards,
TM
Linking the Armadillo library to an Eclipse project can be done and you were about to do it ! It's pretty much the same as for any other library.
In the properties of the project :
GCC C++ Compiler -> Includes : add the path to the file armadillo (where namespace arma is declared) to the include search path (option -I). Example : /home/alpha/soft/armadillo-4.400.1/include
GCC C++ Linker -> Libraries : add the path to the file libarmadillo.so... in the library search path (option -L) Example : /home/alpha/soft/armadillo-4.400.1 . Add armadillo, lapack, blas and m as libraries (option -l). m is for math.
Here are the calls to the compiler and the linker as produced by eclipse :
make all
Building file: ../src/armaeclip.cpp
Invoking: GCC C++ Compiler
g++ -I/home/alpha/soft/armadillo-4.100.1/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/armaeclip.d" -MT"src/armaeclip.d" -o "src/armaeclip.o" "../src/armaeclip.cpp"
Finished building: ../src/armaeclip.cpp
Building target: armaeclip
Invoking: GCC C++ Linker
g++ -L/home/alpha/soft/armadillo-4.100.1 -o "armaeclip" ./src/armaeclip.o -larmadillo -lblas -lm -llapack
Finished building target: armaeclip
**** Build Finished ****
As you run the code, you might get something like :
error: det(): use of ATLAS or LAPACK needs to be enabled
terminate called after throwing an instance of 'std::logic_error'
what(): det(): use of ATLAS or LAPACK needs to be enabled
Abandon (core dumped)
To avoid this problem, follow the advise of the faq of Armadillo : uncomment #define ARMA_USE_LAPACK in file /home/alpha/soft/armadillo-4.100.1/include/config.hpp and rebuild your project.
You can also create GNU Autotools projects and add following line:
bin_PROGRAMS=armadillo_example
armadillo_example_SOURCES=armadillo_example.cpp
armadillo_example_LDADD=-larmadillo
To Makefile.am file where your source code exist.
If you don't require optimized BLAS libraries, you can use the BLAS and LAPACK libraries that come with Armadillo.
Project properties > C/C++ Build > Settings > GCC C++ Compiler >
Includes > Include paths (-l): C:\armadillo-x.xxx.x\include
Then in Environment Variables > System variables, modify the Path
variable and add: C:\armadillo-x.xxx.x\examples\lib_win64\
Project properties > C/C++ General > Paths and Symbols > Libraries:
blas_win64_MT and lapack_win64_MT (it is important to add them
this way, with no path or .lib/.dll)
Then in Environment Variables > System variables, modify the Path
variable and add: C:\armadillo-x.xxx.x\examples\lib_win64\
And your Armadillo library in Eclipse is good to go.
I've used Eclipse 4.14.0 and Armadillo 9.850.1.
I use Eclipse CDT develop a C project in Windows.When i build the project, it throws some errors said the c file invoke .h files these file can't find. But actually, these files are available, it looks like the Eclipse CDT can't add them path? why not CDT add them to path automatically, like java? The make file is generated by Eclipse, i'm just begin to use Eclipse CDT, who can help me?
No, you need to add the paths as follows (covering a little bit more than what was asked) :
See gcc man page :
-L : Add a directory to the list of directories to be searched for -l
-l : The name of the library to be searched (without lib* prefix and extension)
For example: libmylib.a would be linked using linker option -lmylib
and :
-I : Add a directory to the list of directories to be searched for header files.
Each of those options can be repeated several times when passed to the compiler.
In CDT :
To configure includes : "Project > Properties > C/C++ Build > Settings > GCC Compiler > Includes"
To configure libraries : "Project > Properties > C/C++ Build > Settings > GCC Linker > Libraries"
Those configurations are also available in "Project > Properties > C/C++ General > Paths and Symbols > Includes/Libraries". Same rules as above.
I am trying to compile a project but I'm getting an error right away that it's not seeing the header files that are in some packages inside the project. Here is a picture, notice that it is not finding the AwarenessMoment.h file, however it is in there.
Here is the output:
**** Build of configuration Debug for project RoyOS ****
make all
Building file: ../src/royos/vision/ImageRecognizer.cpp
Invoking: GCC C++ Compiler
g++ -I/home/igvc/Documents/teamigvc/trunk/RoyOS -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/royos/vision/ImageRecognizer.d" -MT"src/royos/vision/ImageRecognizer.d" -o"src/royos/vision/ImageRecognizer.o" "../src/royos/vision/ImageRecognizer.cpp"
In file included from ../src/royos/vision/ImageRecognizer.cpp:8:0:
../src/royos/vision/ImageRecognizer.h:11:29: fatal error: AwarenessMoment.h: No such file or directory
compilation terminated.
make: *** [src/royos/vision/ImageRecognizer.o] Error 1
Anyone know why it's not seeing these header files?
Thanks
There's definitely something wrong with the include path given to the compiler. The preprocessor can't find the header from the source file you are attempting to compile.
I think you could fix this by replacing
#include "AwarenessMoment.h"
with
#include "../sensor/AwarenessMoment.h"
Either that or alter the compiler include path to include the sensor directory and use:
#include <AwarenessMoment>