g++: error: `pkg-config: No such file or directory - c++

I installed cygwin and followed this for installation http://cs.calvin.edu/curriculum/cs/112/resources/installingEclipse/cygwin/
then I run this on my cmd
cd opencv
cd sources
cd samples
cd cpp
g++ -ggdb `pkg-config --cflags --libs opencv` facedetect.cpp -o facedetect
It resulted into this
g++: error: `pkg-config: No such file or directory
g++: error: opencv`: No such file or directory
g++: error: unrecognized command line option '--cflags'
g++: error: unrecognized command line option '--libs'
what I'm trying to do is to run facedetect.cpp in opencv to test my classifier any help to fix this issue or provide alternative approach is appreciated

Install the packages pkg-config and libopencv-devel
http://cygwin.com/packages/x86_64/pkg-config
http://cygwin.com/packages/x86_64/libopencv-devel

Related

Mac running OpenMP, "clang: error: unsupported option '-fopenmp'"

I am new to OpenMP, and my professor gives us a project to do. There are only three files in the folder: a C++ source code a0.cpp, a header a0.h, and a Makefile. When I want to run the code in my terminal, it says:
clang: error: unsupported option '-fopenmp'
clang: error: unsupported option '-fopenmp'
make: *** [a0] Error 1
I am using a Macbook, and I do not know how to fix this. Can you help me? Thanks.
After installing libomp with homebrew using:
brew install libomp
I was able to compile an OpenMP program with this:
clang -Xpreprocessor -fopenmp -I/usr/local/include -L/usr/local/lib -lomp main.c -o main
If you are using C++, you'd likely want:
clang++ -Xpreprocessor -fopenmp -I/usr/local/include -L/usr/local/lib -lomp main.cpp -o main

MINGW, Code::Blocks - No such file or directory error when compiling c++

When I try to compile C++ programm in Code::blocks it gives me this error:
-------------- Build: Debug in elcounter (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -Weffc++ -Wall -std=c++14 -fexceptions -Weffc++ -std=c++14 -g -I"C:\Users\Zahir\Box Sync\CPP projects\September_2k16\elcounter\" -c "C:\Users\Zahir\Box Sync\CPP projects\September_2k16\elcounter\main.cpp" -o obj\Debug\main.o
mingw32-g++.exe: error: Sync\CPP: No such file or directory
mingw32-g++.exe: error: projects\September_2k16\elcounter\main.cpp -o obj\Debug\main.o: No such file or directory
mingw32-g++.exe: fatal error: no input files
I am using MinGW g++ compiler.
Just for a test, I tried to compile simple "Hello, world" file and it gave me the same error.
Compiled the same "Hello, world" file in a command line using
"g++ test.cpp -o hello.exe" and in worked just fine, so I believe the compiler is installed correctly.
The error seems to be related to spaces in a file path.
C:\Users\Zahir\Box Sync\CPP projects\September_2k16\elcounter\
mingw32-g++.exe: error: Sync\CPP: No such file or directory
mingw32-g++.exe: error: projects\September_2k16\elcounter\main.cpp -o obj\Debug\main.o: No such file or directory
Might be a problem with a build system in Code::blocks? I tried to copy the command code::blocks using to a command line and it gave the same error. (mingw32-g++.exe -Weffc++ -Wall etc.)
EDIT: I don't want to change file path because "Box Sync" is used by the same name app that synchronizes file with a cloud.(box.com) The app doesn't support changing the main folders name and I'd prefer the project files stay synchronized.
Looks like you need to remove all spaces from file and folder names in your project.
In your case it's the 'CPP projects' folder and 'box sync'

Graphicsmagick C++ API

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

Windows - pip install with mingw - Fails - cc1.exe: error: unrecognized command line option '-mno-cygwin'

I am using Python27
My PATH contains
C:\MinGW\libexec\gcc\mingw32\4.6.2
C:\MinGW\bin
C:\MinGW\msys\1.0\bin
C:\Python27\
C:\Python27\Scripts
My PYTHONPATH contains
C:\Python27
C:\Python\Lib\site-packages
When I try to install certain packages I keep getting errors with gcc
cc1.exe: error: unrecognized command line option '-mno-cygwin'
seems like it is the culprit, but I've been unable to find information on how to fix this.
Some Examples of Errors:
pip install ctypes
....
building '_ctypes' extension
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -Isource/libffi_msvc -IC:\Python27\Lib\site-packages\numpy\core\include -IC:\boost_1_53_0 -IC:\Python27\include -IC:\Python27\PC -c source/_ctypes.c -o
build\temp.win32-2.7\Release\source\_ctypes.o
cc1.exe: error: unrecognized command line option '-mno-cygwin'
error: command 'gcc' failed with exit status 1
another with the same issue
pip install bzr
....
building 'bzrlib._annotator_pyx' extension
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -DWIN32 -IC:\Python27\Lib\site-packages\numpy\core\include -IC:\boost_1_53_0 -IC:\Python27\include -IC:\Python27\PC -c bzrlib/_annotator_pyx.c -o build\
temp.win32-2.7\Release\bzrlib\_annotator_pyx.o
cc1.exe: error: unrecognized command line option '-mno-cygwin'
Cannot build extension "bzrlib._annotator_pyx".
-mno-cygwin in Python\Lib\distutils\cygwinccompiler.py causes this problem: see Compiling with cython and mingw produces gcc: error: unrecognized command line option '-mno-cygwin' or http://korbinin.blogspot.com/2013/03/cython-mno-cygwin-problems.html.
My Python distribution (Anaconda)'s cygwinccompiler.py does not have that though. Anyway, after removing all -mno-cygwin in the definition of the Mingw32CCompiler class you should be able to compile.

g++ won't play nice with wx-config

I'm on windows using mingw and when i use the following to try and compile my wxWidgets code
g++ main.cpp `wx-config --libs` `wx-config --cxxflags`
I get the following error
g++: `wx-config: No such file or directory
g++: `wx-config: No such file or directory
cc1plus.exe: error: unrecognized command line option "-flibs`"
cc1plus.exe: error: unrecognized command line option "-fcxxflags`"
And I cannot figure out what to do to make g++ play nice with wx-config
Please help, thanks.
What shell are you using? Back quotes don't work on the Windows command prompt. You may need to use msys and bash.