X11 Problems when using CImg header in XCode on Mac OSX 10.11.6

跟風遠走 提交于 2019-12-02 12:31:25

问题


I added X11 to my header search paths, library search paths, and I linked the binary to the X11 library in the build settings and build phases in XCode however I am still getting the errors shown in the picture below. I am 99.999% Sure the problem is X11 because when I disable the display capabilities the warnings aren't there. Any ideas on what I can do next?


回答1:


I think you have your build settings a little incorrect. Here is a very simple program to get you started - you can choose to display PNG, TIFF or JPEG files by using libpng, libtiff or libjpeg which I am assuming you have installed using homebrew with:

brew install libpng libjpeg libtiff

Here is the code:

#define cimg_display  1
#define cimg_use_png  1
#define cimg_use_tiff 1
#define cimg_use_jpeg 1

#include "CImg.h"
using namespace cimg_library;

int main() {
    // Load image
    CImg<unsigned char> image("/Users/mark/Desktop/test.tif");

    // CImg<unsigned char> image("/Users/mark/Desktop/test.png");
    // CImg<unsigned char> image("/Users/mark/Desktop/test.jpg");
    // CImg<unsigned char> image("/Users/mark/Desktop/test.pnm");

    image.display();
}

The only build settings needed are as follows:

and

The /Users/mark/src/CImg one is for the CImg.h header file I manage with git, keeping it in sync with the CImg distribution on GitHub.

Note the following:

  • CImg can read NetPBM (PGM/PBM/PPM and actually PFM) images without any extra code or libraries or dependencies

  • CImg can read TIFF, PNG, JPEG without needing ImageMagick if you #define cimg_use_tiff or #define cimg_use_png or #define cimg_use_jpeg as long as you set the include path the library path and the library names as I have shown above.

  • CImg can read anything that ImageMagick can read if you install that package.



来源:https://stackoverflow.com/questions/48361737/x11-problems-when-using-cimg-header-in-xcode-on-mac-osx-10-11-6

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!