Nikys
Nikys

Reputation: 31

FreeImage on Linux returns -1 format

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. :(

Upvotes: 1

Views: 262

Answers (1)

Ripi2
Ripi2

Reputation: 7198

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.

Upvotes: 1

Related Questions