1

I'm trying to include the CImg library (CImg.h) in my project, but when I attempted to compile, I get the following error:

fatal error C1091: compiler limit: string exceeds 65535 bytes in length

I'm using Visual Studio 2010, and I have my compiler command line setting set to /Zm2000. I have no idea what to try next. Any insight is appreciated.

(And if anyone is wondering why I'm using CImg, I needed an image processing library that can calculate the gradient vectors of an image, and CImg seemed the most straight-forward to pick up)

Mel
  • 1,075
  • 1
  • 14
  • 24
  • Did you try using a recent GCC compiler? – Basile Starynkevitch Apr 07 '14 at 06:48
  • possible duplicate of [How do I include extremely long literals in C++ source?](http://stackoverflow.com/questions/2481998/how-do-i-include-extremely-long-literals-in-c-source) See also [this question](http://stackoverflow.com/questions/8018484/loading-an-image-from-a-c-source-file-exported-from-gimp?lq=1). – rubenvb Apr 07 '14 at 06:51
  • Are you sure you have not a string without termination (maybe indirectly, through a macro, for example)? Do you get that error just compiling a .c file with just one line: ´#include ´? – Gonmator Apr 07 '14 at 06:51
  • @BasileStarynkevitch I haven't. I'm fairly new to C++ and have only been coding within the Visual Studio IDE. I'm hoping I won't have to do any manual integration. – Mel Apr 07 '14 at 06:54
  • @rubenvb I saw that question before I posted. The solution doesn't fit my needs. I'm looking for a way to be able to include CImg.h without any edits to the library as it is. – Mel Apr 07 '14 at 06:56
  • @Gonmator Yes, I checked all the other files in my project. Everything builds fine. After adding the #include "CImg.h" line is when the project fails to compile. I'm assuming the CImg library itself doesn't have any strings without termination. – Mel Apr 07 '14 at 06:57
  • @Mel well, it's a limitation of the tool you're using (actually, more strictly the language you're using). You should complain to the CImg developers, use a different compiler, or use a different library that sticks to the limits set in the C++ standard. – rubenvb Apr 07 '14 at 07:03
  • @Mel I never used CImg.h, but that type error looks to be the typical silly mistake that one spend a lot of time with. I don't think the library is using explicit strings as long. Maybe that header (or one of its includes) was accidentally modified and a '"' character removed or added. Try to include *only* the header file (and not code) to discard any effect in your code. Try to open the header file and inspect the CImg.h file in the IDE: If that strings exits, it has to be easy to identify it with the color syntax. – Gonmator Apr 07 '14 at 07:10

2 Answers2

2

I had the the same problem with CImg 1.5.8 and VS 2010 (and with VS 2012 too). The solution is to roll back to CImg 1.5.7. In 1.5.8 they use different way to store font data:

const char *const data_font47x53 = " ...

instead of

const unsigned int font29x57[29*57*256/32] = {0x0,0x0 ...

in earlier versions. It looks like that's the problem.

Maxim
  • 36
  • 2
0

A bug report has been posted on the CImg bug tracker. Apparently, they will fix this in future releases.

bvalabas
  • 301
  • 1
  • 1