1

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?

enter image description here xcode settings1

xcode setting2

xcode settings3

xcode settings4

errors in XCode

1 Answers1

0

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:

enter image description here

and

enter image description here

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.

Community
  • 1
  • 1
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
  • Yay! That got rid of the locale errors! Now XCode can't find the XLib.h file though. The file is located in /opt/X11/include/X11/ but idk how to tell Xcode that... Update: If I replace the path included in CImg with the absolute path of the Xlib.h file it works. I feel like I shouldn't have to do that though since others haven't had to rewrite the CImg code. – Tiffany Montgomery Jan 23 '18 at 14:41
  • The `header search path` should be set to `/opt/X11/include` because inside `CImg.h` it does `#include – Mark Setchell Jan 23 '18 at 14:57
  • What does it mean when the value is next to the header search paths? I only typed in /opt/X11/include but its displaying multiple values. Would that have an affect? – Tiffany Montgomery Jan 23 '18 at 18:18
  • Just read your update. I get 20 more errors within the cwchar file (No member named "x" in the global namespace) after adding the new header and library paths. Is there something else I need to install? – Tiffany Montgomery Jan 23 '18 at 22:43
  • Just a guess, but have you tried putting all those headers under "User Header Search Paths"? – saagarjha Jan 24 '18 at 05:53
  • Yep. That doesn't help. – Tiffany Montgomery Jan 24 '18 at 13:42
  • Could you maybe try creating a small, fresh, brand-new Xcode project, just with the suggested settings I gave you and the code I gave you? I fear you have maybe tried lots of different things in desperation and left something set to a non-default value... – Mark Setchell Jan 24 '18 at 13:56
  • I made a new project with the given settings and I got the same errors. I think the problem might be something outside of Xcode. I'm going to reinstall XQuartz and see if that makes a difference. – Tiffany Montgomery Jan 24 '18 at 20:16
  • If you have changed `CImg.h` grab a new copy of that too - it should not need changing at all. – Mark Setchell Jan 24 '18 at 20:25