1

I am happy user of Ubuntu 16.04 LTS. Not so long ago I've tried both to build FreeImage from sourceforge page of FreeImage. Later I uninstalled it completely and installed the same version from apt-get by

sudo apt-get install libfreeimage3

command. Though, the problem is the same. I am using FreeImage in Linux version of Mono, though problem remains even from C++ code. Assume we have the main.cpp file with code like this in :

#include <FreeImage.h>
#include <iostream>

using namespace std;

int main()
{
    FreeImage_Initialise();
    FREE_IMAGE_FORMAT format = FreeImage_GetFIFFromFilenameU(L"/home/nikys/1.jpg");
    cout << format << endl;
    FreeImage_DeInitialise();
}

After compiling it like this (after "apt-get"-like install I added link for library to /usr/lib, so it could be found):

g++ -I. -c main.cpp -o main.o -lc -lfreeimage
g++ main.o -o main -lc -lfreeimage

I am receiving result "-1" for .exr and .jpg files.

Thing is, I have FreeImage library on Windows for .NET and it returns right format for the same objects (the same code on Linux Mono, linked with aforementioned shared object, gives me "-1" too without any DllNotFoundException or EntryPointNotFound). What could have gone wrong? Request info as I am for sure forgot to mention man significant information.

UPD1: If I use

FREE_IMAGE_FORMAT format = FreeImage_GetFIFFromFilename("/home/nikys/1.jpg");

or

FREE_IMAGE_FORMAT format = FreeImage_GetFileType("/home/nikys/1.jpg");

I am happy and have "2" as normal man would have. Though, for wide string nor FreeImage_GetFileTypeU, not FreeImage_GetFIFFromFilenameU tells me right result. :(

Community
  • 1
  • 1
Nikys
  • 31
  • 5

1 Answers1

1

Linux uses for files and inputs UTF8 encoding, not wide strings.

To make your code works in different OS's you need to enclose some commands with #if defined(OS1)...#else... or use a multiOS API like Qt or wxWidgets.

Ripi2
  • 7,031
  • 1
  • 17
  • 33
  • Well, this I can understand (about #ifndef), but how should I format paths for Linux? I am sure that I can create directory with, for example, with cyrillic symbols. Thus, it cannot be interpreted in char*. – Nikys Jun 15 '17 at 16:06
  • In Linux, if you have not-ASCII chars, the corresponding `char` sequence (i.e. the internal representation in UTF-8 encoding) should suffix. – Ripi2 Jun 15 '17 at 16:38