Magick++.h header not found - c++

I am trying to get g++ to compile a program that uses Magick++, however despite installing the libraries, I get the below error when compiling the program with g++ WallFade.cpp `Magick++-config --cxxflags --cppflags --ldflags --libs` -o WallFade:
fatal error: Magick++.h: No such file or directory
4 | #include <Magick++.h>
| ^~~~~~~~~~~~
compilation terminated.
When I set an absolute path to the header file by replacing #include <Magick++.h> with #include "/usr/local/include/ImageMagick-7/Magick++.h" I then get the following error:
/usr/local/bin/Magick++-config: line 47: --cflags: command not found
/usr/local/bin/Magick++-config: line 50: --cflags: command not found
/usr/local/bin/Magick++-config: line 53: --libs: command not found
/usr/local/bin/Magick++-config: line 56: --libs: command not found
In file included from WallFade.cpp:4:
/usr/local/include/ImageMagick-7/Magick++.h:10:10: fatal error: Magick++/Include.h: No such file or directory
10 | #include <Magick++/Include.h>
| ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
I'm assuming I need to run some command to link the header files to g++, but I'm not sure what that command would be (currently running Arch Linux).

Install following package libmagick++-dev
packman -S libmagick++-dev
I think this is the way to install it on Arch.

Related

MacOS M1 -> fatal error: 'GLFW/glfw3.h' file not found

I have a project (here) that works both on Linux and intel MacOS, but in my Mac m1 it doesn't. Whenever I try to compile it, I get the following errors (ops.: I'm using vscode m1 native):
pedrohaccorsi#MacBook-Air-de-Pedro dev % make
g++ -o app src/glad.c src/AudioManager.cpp src/Character.cpp src/SceneManager.cpp src/Source.cpp src/Sprite.cpp src/stb_image.cpp -g -Iinclude -F/Library/Frameworks -lglfw -ldl -framework SDL2 -I/Library/Frameworks/SDL2.framework/Headers -framework SDL2_mixer -I/Library/Frameworks/SDL2_mixer.framework/Headers
In file included from src/AudioManager.cpp:1:
include/AudioManager.h:1:10: fatal error: 'SDL2/SDL.h' file not found
#include <SDL2/SDL.h>
^~~~~~~~~~~~
1 error generated.
In file included from src/Character.cpp:1:
In file included from include/Character.h:1:
In file included from include/Sprite.h:6:
include/Shader.h:13:10: fatal error: 'GLFW/glfw3.h' file not found
#include <GLFW/glfw3.h>
^~~~~~~~~~~~~~
1 error generated.
In file included from src/SceneManager.cpp:1:
In file included from include/SceneManager.h:3:
include/Shader.h:13:10: fatal error: 'GLFW/glfw3.h' file not found
#include <GLFW/glfw3.h>
^~~~~~~~~~~~~~
1 error generated.
src/Source.cpp:10:17: warning: using directive refers to implicitly-defined namespace 'std'
using namespace std;
^
In file included from src/Source.cpp:12:
In file included from include/SceneManager.h:3:
include/Shader.h:13:10: fatal error: 'GLFW/glfw3.h' file not found
#include <GLFW/glfw3.h>
^~~~~~~~~~~~~~
1 warning and 1 error generated.
In file included from src/Sprite.cpp:1:
In file included from include/Sprite.h:6:
include/Shader.h:13:10: fatal error: 'GLFW/glfw3.h' file not found
#include <GLFW/glfw3.h>
^~~~~~~~~~~~~~
1 error generated.
make: *** [app] Error 1
Before hand I ran these three commands and they worked successfully, no errors nor warnings at all, so I assumed it was all working fine.
brew install glfw
brew install sdl2
brew install sdl2_mixer
Anyone has any ideas?
My issue was partially solved. There were two problems, GLFWand SDL2.
GLFW
The fix was the same proposed in this thread; in a nutshell it consists in:
$ nano ~/.zshrc
> export CPATH=/opt/homebrew/include
> export LIBRARY_PATH=/opt/homebrew/lib
This will tell the compiler to look for things in opt/homebrew, which is where homebrew for m1 installs the packages, instead of usr/local.
SDL2
I downloaded the two .dmg files from the websites below
https://www.libsdl.org/download-2.0.php
https://www.libsdl.org/projects/SDL_mixer/
Then I went to the downloads and copied the .framework directory from both downloads and pasted into /Library/Frameworks.
This solved those errors from before, that the system could not find the includes, but a new error showed up: symbols not found for architecture arm64. I decided to quit trying and just removed the sound out of my game (it was a college assignment, no biggie in taking features out).
On MacOS Monterey 12.6 I fixed the issue by installing xcode, then installed with homebrew:
glew
glfw3
xquartz
brew install glew glfw3
brew install --cask xquartz
Then I pointed to the X11 folders and sample OpenGL program compiled.
The github source code was taken from: https://github.com/zamirmf/OpenGLOnMac
For example:
clang -o testopengl main.cpp \
-L/opt/X11/lib -L/opt/homebrew/lib \
-I/opt/X11/include -I/opt/homebrew/include \
-lglfw -framework OpenGL

gcc can't find libcurl header file in the directory it is located

I am trying to compile a cpp using with the following command:
g++ -IC:\Users\XXX\libcurl-7.56.0\libcurl-7.56.0\include\curl -LC:\Users\XXX\libcurl-7.56.0\libcurl-7.56.0\lib program.cpp
this program has a header file which uses libcurl. the curl library is at -
C:\Users\XXX\libcurl-7.56.0\libcurl-7.56.0\include\curl\curl.h
gcc gives the following error even though curl.h is in the path -I
mylibrary.h:26:10: fatal error: curl/curl.h: No such file or directory
#include <curl/curl.h>
what am I doing wrong?
The error message means the file curl/curl.h could not be found in the search path specified by -I. You updated the question with the path to the file so the command should be:
g++ -IC:\Users\XXX\libcurl-7.56.0\libcurl-7.56.0\include -LC:\Users\XXX\libcurl-7.56.0\libcurl-7.56.0\lib program.cpp
Also, can you please try using \ instead of / as path separator in your mylibrary.h file:
#include <curl\curl.h>

can not build cpp using clang pre-built binary: file wchar.h not found

I am using MacOS 10.15. Since the clang shipped with MacOS does not include clang-format. I installed another pre-built clang binary from here. I have added the binary file path to my PATH variable.
export PATH="$HOME/tools/clang+llvm-10.0.0-x86_64-apple-darwin/bin:$PATH"
I tried to compile a simple program:
#include <iostream>
int main(int argc, char *argv[]) {
std::cout << "Hello world!\n";
return 0;
}
using the following command:
clang++ hello.cpp -o hello
I got the following error:
In file included from hello.cpp:1:
In file included from /Users/jdhao/tools/clang+llvm-10.0.0-x86_64-apple-darwin/bin/../include/c++/v1/iostream:37:
In file included from /Users/jdhao/tools/clang+llvm-10.0.0-x86_64-apple-darwin/bin/../include/c++/v1/ios:214:
In file included from /Users/jdhao/tools/clang+llvm-10.0.0-x86_64-apple-darwin/bin/../include/c++/v1/iosfwd:95:
/Users/jdhao/tools/clang+llvm-10.0.0-x86_64-apple-darwin/bin/../include/c++/v1/wchar.h:118:15: fatal error: 'wchar.h' file not found
#include_next <wchar.h>
^~~~~~~~~
1 error generated.
I found that wchar.h bundled with this pre-built package is in the following directory:
/Users/jdhao/tools/clang+llvm-10.0.0-x86_64-apple-darwin/include/c++/v1/
So I added the -I flag:
clang++ -I /Users/jdhao/tools/clang+llvm-10.0.0-x86_64-apple-darwin/include/c++/v1 hello.cpp -o hello
The error still persists.
If I use clang++ shipped with MacOS, I have no problem compiling the source code:
# the following works without any error
/usr/bin/clang++ hello.cpp -o hello
I have seen post here, here, and here, but the solutions do not apply.
You got clang-format improperly. Reset the system to the state before you installed another pre-built clang binary. Then use Homebrew to install clang-format
brew install clang-format
clang+llvm-10.0.0-x86_64-apple-darwin is not suitable to your Mac. It depends on system frameworks that are not available, so you get the error finding wchar.h in a system framework. When you install clang+llvm-10.0.0-x86_64-apple-darwin you ignore framework dependencies. Homebrew will care about dependencies.

Problem with C++ compiler on macOS (building cmake project)

I have a 16inch MacBook pro with latest updates (macOS Catalina 10.15.2 (19C57)), the latest version of XCode and Command line tools for macOS (the tools being installed in the usual path /Library/Developer/CommandLineTools/).. Not sure if this is relevant to my issue or not, but I also have the latest version of JetBrains’s CLion installed on my machine (running without issues).
Here is the problem: When trying to build a project with cmake, the build FAILS, giving me this error message:
In file included from /Users/basavyr/Pipeline/DevWorkspace/Github/xrootd/bindings/python/src/PyXRootDFile.cc:25:
In file included from /Users/basavyr/Pipeline/DevWorkspace/Github/xrootd/bindings/python/src/PyXRootD.hh:28:
In file included from /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:38:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string.h:61:15: fatal error:
'string.h' file not found
#include_next <string.h>
1 error generated.
error: command '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc' failed with exit status 1
make[2]: *** [bindings/python/python_bindings] Error 1
make[1]: *** [bindings/python/CMakeFiles/python_target.dir/all] Error 2
make: *** [all] Error 2
and this is probably related to my C++ compiler not having the correct path to the include files. To see what the issue could be, I’ve made a simple C++ file and I tried to compile it.
main.cpp
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
int main()
{
std::string name = "NAMEX";
std::cout << name;
}
First, I tried with the usual “g++” and it worked just fine:
basavyr#Roberts-MacBook-Pro stringTestCLANG % g++ main.cpp
basavyr#Roberts-MacBook-Pro stringTestCLANG % ./a.out
NAMEX% basavyr#Roberts-MacBook-Pro stringTestCLANG %
Then, I tried with /Applications/Xcode.app/Contents/Developer/usr/bin/g++ main.cpp and it worked just fine.
Checking the version of “g++” on my machine gives me this:
g++ -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin19.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
This is interesting, because I was expecting that the default compiler is installed in /usr/bin/ instead. Going into that “InstalledDir” folder I saw that there is no “g++” binary, but only “clang++” and “c++”, so I tried to compile with both and it turns out that both compilers are giving the same error as the one in the project that I trying to build:
basavyr#Roberts-MacBook-Pro stringTestCLANG % /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ main.cpp
In file included from main.cpp:1:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iostream:38:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ios:216:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__locale:15:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:505:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string_view:176:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__string:57:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:642:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstring:61:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string.h:61:15: fatal error:
'string.h' file not found
#include_next <string.h>
^~~~~~~~~~
1 error generated.
basavyr#Roberts-MacBook-Pro stringTestCLANG %
Since I also have Command Line Tools installed, I tried to compile with both “g++” and “clang++” from /Library/Developer/CommandLineTools/usr/bin/ and the first one compiles successfully, while the second one throws the same error with regards to the string header file.
basavyr#Roberts-MacBook-Pro stringTestCLANG % /Library/Developer/CommandLineTools/usr/bin/c++ main.cpp
In file included from main.cpp:1:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iostream:38:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ios:216:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__locale:15:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:505:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string_view:176:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__string:57:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:642:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:61:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string.h:61:15: fatal error: 'string.h' file not found
#include_next <string.h>
^~~~~~~~~~
1 error generated.
So, I assume that when I build that project with cmake, it is using one of these compilers (from the XCodeDefault.xctoolchain folder) and it has issues with the string header.
Q1: How can I solve this issue? Q2: And also, why does my “g++” installation directory points to this XCodeDefault.xctoolchain instead of “/usr/bin/’ or “/Applications/Xcode.app/Contents/Developer/usr/bin/”. Is there a way to change that in macOS?
Thank you in advance

SpiderMonkey 38 compilation error

I was using Spidermonkey 24 earlier but then moved to version 38 yesterday. But the problem is I'm unable to compile any program using this version. I tried compiling the sample code that came within but it gives the following error:
sudo g++ -I /home/pi/mozjs-38.0.0/js/src/build_OPT.OBJ/dist/include/ -L /home/pi/mozjs-38.0.0/js/src/build_OPT.OBJ/dist/lib/ sample.cpp -o sample -lmozjs-38 -lz -lpthread -ldl
In file included from sample.cpp:1:0:
sample.h:6:21: fatal error: jscntxt.h: No such file or directory
#include "jscntxt.h"
^
compilation terminated.
Note: The path to that header is already specified in the command.
I was successfully compiling the program using the same command with spidermonkey24.
Thanks!