I have read all of the related questions with no success trying anything mentioned anywhere. I am new to cross-compiling and have been working on this for over a week with no progress. So please forgive me if you think I am stupid or have overlooked something.
So I have an application running in C++ that works great on my development computer running Ubuntu 14.04 x64. I am trying to cross compile for my Banana Pro running Lubuntu. Based on the documentation from Lemaker I am supposed to cross compile using "arm-linux-gnueabihf-"
So far the farthest I have been able to get is to :
/usr/local/opencv-arm/usr/local/lib/libopencv_calib3d.so: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
I get this error regardless of what command I run, Here is a list of commands I have tried:
arm-linux-gnueabihf-g++ `arm-linux-gnueabihf-pkg-config arm-opencv --cflags` -Wall test.cpp -o vis-300 `arm-linux-gnueabihf-pkg-config arm-opencv --libs`
arm-linux-gnueabihf-g++ `pkg-config arm-opencv --cflags` -Wall test.cpp -o vis-300 `pkg-config arm-opencv --libs`
arm-linux-gnueabihf-gcc `pkg-config arm-opencv --cflags` -Wall test.cpp -o vis-300 `pkg-config arm-opencv --libs`
arm-linux-gnueabihf-g++ `pkg-config arm-opencv --cflags` test.cpp -o vis-300 `pkg-config arm-opencv --libs`
And there have been many more commands before those with different errors such as:
arm-linux-gnueabihf-gcc: error trying to exec 'cc1plus': execvp: No such file or directory
arm-linux-gnueabihf-cpp fatal error too many input files
I have tried with just normal arm-linux-gnueabihf-gcc/g++, 4.6, 4.7, and 4.8
I have built opencv making small changes for hf using these 2 guides and both produced the same results:
http://processors.wiki.ti.com/index.php/Building_OpenCV_for_ARM_Cortex-A8
http://www.ridgesolutions.ie/index.php/2013/05/24/building-cross-compiling-opencv-for-linux-arm/
and not included in either I install it using this command because it will conflict with my current x86_64 install:
sudo make install DESTDIR=/usr/local/opencv-arm
Also the above pkg-config lines point to my custom pkg config file named arm-opencv.pc
# Package Information for pkg-config
prefix=/usr/local/opencv-arm/usr/local
exec_prefix=${prefix}
libdir=
includedir_old=${prefix}/include/opencv
includedir_new=${prefix}/include
Name: OpenCV-arm
Description: Open Source Computer Vision Library
Version: 2.4.10
Libs: ${exec_prefix}/lib/libopencv_calib3d.so ${exec_prefix}/lib/libopencv_contrib.so ${exec_prefix}/lib/libopencv_core.so ${exec_prefix}/lib/libopencv_features2d.so ${exec_prefix}/lib/libopencv_flann.so ${exec_prefix}/lib/libopencv_gpu.so ${exec_prefix}/lib/libopencv_highgui.so ${exec_prefix}/lib/libopencv_imgproc.so ${exec_prefix}/lib/libopencv_legacy.so ${exec_prefix}/lib/libopencv_ml.so ${exec_prefix}/lib/libopencv_nonfree.so ${exec_prefix}/lib/libopencv_objdetect.so ${exec_prefix}/lib/libopencv_ocl.so ${exec_prefix}/lib/libopencv_photo.so ${exec_prefix}/lib/libopencv_stitching.so ${exec_prefix}/lib/libopencv_superres.so ${exec_prefix}/lib/libopencv_ts.a ${exec_prefix}/lib/libopencv_video.so ${exec_prefix}/lib/libopencv_videostab.so -lrt -lpthread -lm -ldl
Cflags: -I${includedir_old} -I${includedir_new}
Anyways I have tried a lot of stuff short of just installing everything on the board itself and compiling there. Any help is much appreciated and keep in mind I have never successfully cross-compiled before. I always give up and compile on the board.
Related
I use a Linux environment for code development and testing of a program and now I want to compile an Windows ".exe" file so that my program can run on Windows OS, after some internet research I tried to modified my makefile to use x86_64-w64-mingw32-g++ instead of g++ as its compiler but now I get a segmentation fault at the end of the compilation and I am not sure how to debug this. My makefile is below:
PROGRAM=output.exe
COMPILER=x86_64-w64-mingw32-g++
# PROGRAM=output
# COMPILER=g++
#BIN_FOLDER=bin
DEPS += Defs.h Structs.h
CXXFLAGS+=`sdl2-config --cflags`
CXXFLAGS+=-DVERSION=$(VERSION) -DREVISION=$(REVISION) -DDATA_DIR=\"$(DATA_DIR)\"
CXXFLAGS+=-Wall -Wempty-body -Werror -Werror=maybe-uninitialized -Warray-bounds
CXXFLAGS+=-g -lefence -std=c++20 -fopenmp
LDFLAGS+=-L/usr/local/lib -lSDL2 -lSDL2_mixer -lSDL2_image -lSDL2_ttf -fopenmp src/ECS/*.cpp #-pg
FILENAME:= $(patsubst %.cpp,%.o,$(wildcard src/*.cpp))
$(PROGRAM):$(FILENAME)
$(COMPILER) $(FILENAME) -o $# $(LDFLAGS)
clean:
rm src/*.o
this compiles without a problem in g++ but when using the mingw32 compiler I get this error:
x86_64-w64-mingw32-g++ src/ActionManager.o src/AStar.o ...[a bunch of .o files] -o output.exe
collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core dumped
compilation terminated.
make: *** [makefile:26: output.exe] Error 1
I tried compiling a simple helloWorld.cpp program using x86_64-w64-mingw32-g++ like this: x86_64-w64-mingw32-g++ 01_hello_world.c -o windowshello.exe and that works fine.
I also tried deleting all my LDFLAGS just to see what would happen and I get the same result.
Could anyone point me into the right direction as to how I might debug this? Is this a particular part of my code that is causing this or am I going about this entirely wrong?
I am trying to use the geos library on a Raspbery Pi 3, using Debian. I am trying to compile a program in C ++.
The same program can be compiled on other computers, this means that the source code of my program is correct.
When executing the command geos-config --version, version 3.7.1 is returned to me.
A while ago, a friend compiled and has been using the same code in Raspibian. However, I can't run it on Debian. My friend does not remember how he installed the geos library.
Would anyone know of anything that could help me?
make
Building target using GCC compiler: sources/geometry-manager.cpp
g++ -g -c sources/geometry-manager.cpp -std=c++17 -w -c -rdynamic -W `wx-config --cxxflags --libs --gl-libs` `geos-config --cflags` -lgeos -lglut -lGLU -lGL -lm -lGLEW -o builded/geometry-manager.o `pkg-config --libs geographiclib`
In file included from sources/geometry-manager.cpp:14:
sources/../include/geometry-manager.hpp:26:10: fatal error: geos.h: No such file or directory
#include <geos.h>
^~~~~~~~
compilation terminated.
make: *** [Makefile:37: builded/geometry-manager.o] Error 1
geos-config --includes : /usr/include.
geos-config --cflags : -I/usr/include.
geos-config --libs : -L/usr/lib/aarcg64-linux-gnu -lgeos-3.7.1 .
I installed via apt-get. However, as it didn't work, I installed it from the cloned github repository. –
Solution:
I uninstalled geos from my computer. Afterwards, I deleted all the folders related to geos that were still on the computer.
For some reason, the installation from the current repository did not work. So I cloned an old version of the geos.
https://github.com/libgeos/geos.git
I ran autogen.sh script (which didn't work before).
And this time it compiled and installed it successfully.
Thanks
I want to use dlib library for my c++ projects in linux. I have installed it successfully and able to compile and run the .cpp samples files given under the dlib. I have compiled the sample files through the
"g++ -std=c++11 -O3 -I.. ../dlib/all/source.cpp -lpthread -lX11 example_program_name.cpp" given in [http://dlib.net/compile.html][1]
but I am unable to use the same command to run .cpp files which are the outside dlib-18.18/examples directory
Can someone help me out with compiling c++ file (with dlib library usage) from any user directory in linux?
I came to know that we have to include the path of dlib installation folder while trying to compile it from any other user directory. So I tried the command
" g++ -O3 -I/home/praneeth/computervision/.. ../dlib/all/source.cpp -lpthread -lX11 project3_face.cpp -o project_face pkg-config --cflags opencv pkg-config --libs opencv"
but it gave me the result:
g++: error: ../dlib/all/source.cpp: No such file or directory
Note: dlib-18.18 folder is present in my /home/praneeth/computervision/
I don't know how correct is this but it got compiled when I ran the command like: g++ -O3 -I/home/praneeth/computervision/dlib-18.18 /home/praneeth/computervision/dlib-18.18/dlib/all/source.cpp -lpthread -lX11 project3_face.cpp -o project_face pkg-config --cflags opencv pkg-config --libs opencv any comments on this regarding why this works?
g++ -Wl,-V -std=c++11 -o3 -I/home/user/dlib-19.6 /home/user/dlib-19.6/dlib/all/source.cpp -lpthread -lX11 -o Test Test.cpp pkg-config opencv --cflags --libs
I want to use the C++ API for graphicsmagick
I need to convert image data directly from OpenCV and use graphicsmagick to save the file as tiff with group 4 compression
The command line
gm convert input -type bilevel -monochrome -compress group4 output.tif
Could anyone provide some code (see the above command line) to simply convert the output from OpenCV to tiff with group 4 compression
I'm new to C++ :)
testing graphicsmagick
I'm trying to make graphicsmagick work. Found a very simple code in the docs
I can't find Magick++.h
locate /Magick++.h returns nothing
but graphicsmagick is installed
# gm -version
GraphicsMagick 1.3.20 2014-08-16 Q8 http://www.GraphicsMagick.org/
code
/*
* Compile
* g++ gm_test.cpp -o gm_test `GraphicsMagick++-config --cppflags --cxxflags --ldflags --libs`
*/
#include <Magick++.h>
using namespace std;
using namespace Magick;
int main(int argc, char **argv){
InitializeMagick(*argv);
Image image( "100x100", "white" );
image.pixelColor( 49, 49, "red" );
image.write( "red_pixel.png" );
return 0;
}
compile
# g++ gm_test.cpp -o gm_test `GraphicsMagick++-config --cppflags --cxxflags --ldflags --libs`
-bash: GraphicsMagick++-config: command not found
gm_test.cpp:6:22: fatal error: Magick++.h: No such file or directory
#include <Magick++.h>
^
compilation terminated.
Updated Answer
Try looking for a file called GraphicsMagick-config under the directory where you installed GraphicsMagick like this:
find /usr -name "GraphicsMagick-config"
When you find that, you can ask it to tell you the compiler include flags and linker flags like this:
/usr/some/path/GraphicsMagick-config --cflags --libs
Then you can compile with:
gcc $(/usr/some/path/GraphicsMagick-config --cflags --libs) somefile.c -o somefile
Original Answer
Look in the directory where you installed GraphicsMagick for a file ending in .pc, which is the pkg-config file, e.g.
find /usr/local -iname "graphic*.pc"
Then pass this file to pkg-config to get the CFLAGS and LIBS you should use for compiling. So, if your graphicsmagick.pc is in /usr/local/Cellar/graphicsmagick/1.3.23/lib/pkgconfig/GraphicsMagick.pc, use:
pkg-config --cflags --libs /usr/local/Cellar/graphicsmagick/1.3.23/lib/pkgconfig/GraphicsMagick.pc
which will give you this:
/usr/local/Cellar/graphicsmagick/1.3.23/lib/pkgconfig/GraphicsMagick.pc
-I/usr/local/Cellar/graphicsmagick/1.3.23/include/GraphicsMagick -L/usr/local/Cellar/graphicsmagick/1.3.23/lib -lGraphicsMagick
Then you would compile with:
gcc $(pkg-config --cflags --libs somefile.c -o somefile
i don't know if it's helpful, last day i have the same error :no magick++.h when i compile ImageMagick (not graphicsmagick).
so i follows the steps in a official website to reinstall ImageMagick and finally i succeed.web:
1 http://www.imagemagick.org/script/install-source.php
2 http://www.imagemagick.org/script/magick++.php
i download the latest source code(ImageMagick6.9) in centOS-6.5
and then ./configure, make, make install.
i hope it's helpful.
On Ubuntu the GraphicsMagick++-config program you are using to get compile flags is correctly part of the same package which includes Magick++.h. Trying to run it tell you where to find it:
$ g++ gm_test.cpp -o gm_test `GraphicsMagick++-config --cppflags --cxxflags --ldflags --libs`
The program 'GraphicsMagick++-config' is currently not installed. You can install it by typing:
sudo apt-get install libgraphicsmagick++1-dev
gm_test.cpp:6:22: fatal error: Magick++.h: No such file or directory
compilation terminated.
So do what it says:
$ sudo apt-get install libgraphicsmagick++1-dev
Try the compile again and you will get a different error because GraphicsMagick++-config is linking to an uninstalled and unneeded library:
$ g++ gm_test.cpp -o gm_test `GraphicsMagick++-config --cppflags --cxxflags --ldflags --libs`
/usr/bin/ld: cannot find -lwebp
collect2: error: ld returned 1 exit status
You can manually specify the libs and the compile and link works:
$ g++ gm_test.cpp -o gm_test -I/usr/include/GraphicsMagick -Wall -g -fno-strict-aliasing -O2 -pthread -lGraphicsMagick++ -lGraphicsMagick -ljbig
$ ./gm_test
Or you can install the required library:
$ sudo apt-get install libwebp-dev
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
OpenCV on ubuntu 11.10
I am having a very hard time trying to install OpenCV on Ubuntu. I believe that I have already installed OpenCV; however, I am trying to compile one of the samples program kalman.cpp with Eclipse, and I am not able to compile it. My problem I believe is linking with the libraries.
I have seen a lot of tutorial, and I do not understand why after installing opencv in my computer, I get the following output after using the command pkg-confi opencv --libs:
manuel#manuel:~$ sudo pkg-config opencv --libs
/usr/local/lib/libopencv_calib3d.so
/usr/local/lib/libopencv_contrib.so /usr/local/lib/libopencv_core.so
/usr/local/lib/libopencv_features2d.so
/usr/local/lib/libopencv_flann.so /usr/local/lib/libopencv_gpu.so
/usr/local/lib/libopencv_highgui.so
/usr/local/lib/libopencv_imgproc.so /usr/local/lib/libopencv_legacy.so
/usr/local/lib/libopencv_ml.so /usr/local/lib/libopencv_nonfree.so
/usr/local/lib/libopencv_objdetect.so
/usr/local/lib/libopencv_photo.so
/usr/local/lib/libopencv_stitching.so /usr/local/lib/libopencv_ts.so
/usr/local/lib/libopencv_video.so
/usr/local/lib/libopencv_videostab.so
Every tutorial out there the libraries appear as:
-L/where/you/have/installed/opencv/lib -lcxcore -lcv -lhighgui -lcvaux
This is really annoying because Eclipse cannot find the library as libopencv_contrib.so. It is waiting for something as -lopencv_contrib
I really appreciate the help. Please let me know what I am doing wrong.
I have never used OpenCV with Eclipse. I basically compile it using gcc or g++ (depending on c or C++) file.
for C file,
$ gcc -ggdb `pkg-config --cflags opencv` -o `basename opencvtest.c .c` opencvtest.c `pkg-config --libs opencv`
for C++ file,
$ g++ -ggdb `pkg-config --cflags opencv` -o `basename opencvtest.cpp .cpp` opencvtest.cpp `pkg-config --libs opencv`
For more information, see http://jayrambhia.wordpress.com/2012/05/08/beginning-opencv/
If you are comfortable with this, I don't think you would need to use Eclipse.
Hope this helps.
To link to a library you need to specify the path to the directory where it is located using the -L /path/to/libraries flag.
You also need the specific libraries you want using -l my_library.
Usually you also need to specify the necessary include paths using -I /path/to/headers
pkg-config can be used as a helper to do this, as it returns the exact parameters you need in order to use a library.
You should rather use it like this:
echo `pkg-config opencv --cflags --libs`
resp.
g++ my_first_opencv_app.cc `pkg-config opencv --cflags --libs`
which on my system evaluates to
g++ my_first_opencv_app.cc -I/usr/include/opencv -lml -lcvaux -lhighgui -lcv -lcxcore
To get it to work with eclipse, you probably need to specify the include path (/usr/local/include/opencv ?), the library path (/usr/local/lib ?) and the libraries you need via some GUI element somewhere in the project settings. You probably shouldn't need pkgconfig then.