I've been trying to compile FreeImage for use in my program, using MinGW
version...er...well, the GCC version is 4.4.1. Anyway, I'm using MSYS to
compile it, using the commands:
set FREEIMAGE_LIBRARY_TYPE=STATIC
make -f Makefile.minGW
It compiles for several minutes, before I get the following errors:
Source/LibRawLite/./src/libraw_datastream.cpp: In constructor
'LibRaw_windows_datastream::LibRaw_windows_datastream(const TCHAR)':
Source/LibRawLite/./src/libraw_datastream.cpp:472: error: 'runtime_error' is
not a member of 'std'
Source/LibRawLite/./src/libraw_datastream.cpp: In member function
'LibRaw_windows_datastream::Open(void):
Source/LibRawLite/./src/libraw_datastream.cpp:504: error: 'runtime_error' is
not a member of 'std'
Source/LibRawLite/./src/libraw_datastream.cpp:507: error: '::GetFileSizeEx'
has not been declared
Source/LibRawLite/./src/libraw_datastream.cpp:508: error: 'runtime_error' is
not a member of 'std'
Source/LibRawLite/./src/libraw_datastream.cpp:512: error: 'runtime_error' is
not a member of 'std'
make: *** Error 1
I'm afraid to go messing around in the source code, I'm not the best
programmer... Anyone seen this before or know how to fix it?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Actually, I seem to be having a new problem now... I built FreeImage as a
static library (FREEIMAGE_LIBRARY_TYPE was set to STATIC in the Makefile), and
am now linking my program against FreeImage.a. However, for some reason I
still get "undefined reference to _imp__FunctionName@num" errors when
linking my program, at every invocation of a FreeImage function:
Ok, this is a problem not related to FreeImage. Obviously, you are having
problems to link against the GCC-generated static library file (*.a file). I
assume, that you compile your code that links to the static FreeImage library
also MinGW, too. Currently, I have no idea what's going wrong there. I
actually have never tested using that static FreeImage library from MinGW (at
least I can't remeber that). I will have a closer look at this next week and
hope to get back to you soon with some useful hints.
Carsten
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
OK, there are several problems with your build. First, when linking
statically, GCC assumes archive files (*.a) to be prefixed with 'lib'.
Basically, that's a shortcoming in the MinGW Makefile and I will provide an
updated version soon.
However, you can do two things to handle this. You could either rename file
FreeImage.a to libFreeImage.a or you could add the 'lib' prefix to file
Makefile.mingw in line 73. Just make this line appear STATICLIB =
lib$(TARGET).a an re-run the build process after a 'make clean'.
There is another problem with you build. When linking statically to FreeImage,
you need to define symbol FREEIMAGE_LIB prior to including header file
FreeImage.h. This header file is used for both creating and importing the DLL
as well as for static linking. With that symbol (among others), import/export
behavior as well as calling convention is controlled. By default, FreeImage.h
assumes that you link to FreeImage.dll. You can have a look at this in
FreeImage.h, starting at line 39. That's also described on the FreeImage
project page under FAQ http://freeimage.sourceforge.net/faq.html. So, I recommend adding -DFREEIMAGE_LIB to
both your C and C++ compiler flags.
Additionally, with static linking, you need to call FreeImage_Initialise
before you use FreeImage and also FreeImage_DeInitialise before you are done
with FreeImage or when you application exits. When linking dynamically, the
DLL does this job for you.
In the end, you also need to add both libraries wsock32 and ws2_32 to the list
of required libraries. These are the Windows Winsock libraries, needed by
LibRaw. So, you also need to add -lwsock32 -lws2_32 to your linker command
line.
Carsten
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've been trying to compile FreeImage for use in my program, using MinGW
version...er...well, the GCC version is 4.4.1. Anyway, I'm using MSYS to
compile it, using the commands:
set FREEIMAGE_LIBRARY_TYPE=STATIC
make -f Makefile.minGW
It compiles for several minutes, before I get the following errors:
Source/LibRawLite/./src/libraw_datastream.cpp: In constructor
'LibRaw_windows_datastream::LibRaw_windows_datastream(const TCHAR)':
Source/LibRawLite/./src/libraw_datastream.cpp:472: error: 'runtime_error' is
not a member of 'std'
Source/LibRawLite/./src/libraw_datastream.cpp: In member function
'LibRaw_windows_datastream::Open(void):
Source/LibRawLite/./src/libraw_datastream.cpp:504: error: 'runtime_error' is
not a member of 'std'
Source/LibRawLite/./src/libraw_datastream.cpp:507: error: '::GetFileSizeEx'
has not been declared
Source/LibRawLite/./src/libraw_datastream.cpp:508: error: 'runtime_error' is
not a member of 'std'
Source/LibRawLite/./src/libraw_datastream.cpp:512: error: 'runtime_error' is
not a member of 'std'
make: *** Error 1
I'm afraid to go messing around in the source code, I'm not the best
programmer... Anyone seen this before or know how to fix it?
A temporary fix for the MINGW makefile is available in the CVS.
See :
http://freeimage.cvs.sourceforge.net/viewvc/freeimage/FreeImage/Makefile.ming
w
The Libraw files will be updated by the Libraw team soon.
Thank you, that fixed the problem. Thanks very much for the help.
Actually, I seem to be having a new problem now... I built FreeImage as a
static library (FREEIMAGE_LIBRARY_TYPE was set to STATIC in the Makefile), and
am now linking my program against FreeImage.a. However, for some reason I
still get "undefined reference to
_imp__FunctionName@num
" errors whenlinking my program, at every invocation of a FreeImage function:
Ok, this is a problem not related to FreeImage. Obviously, you are having
problems to link against the GCC-generated static library file (*.a file). I
assume, that you compile your code that links to the static FreeImage library
also MinGW, too. Currently, I have no idea what's going wrong there. I
actually have never tested using that static FreeImage library from MinGW (at
least I can't remeber that). I will have a closer look at this next week and
hope to get back to you soon with some useful hints.
Carsten
Okay, thank you very much. I look forward to hearing your discoveries.
Hi,
OK, there are several problems with your build. First, when linking
statically, GCC assumes archive files (*.a) to be prefixed with 'lib'.
Basically, that's a shortcoming in the MinGW Makefile and I will provide an
updated version soon.
However, you can do two things to handle this. You could either rename file
FreeImage.a to libFreeImage.a or you could add the 'lib' prefix to file
Makefile.mingw in line 73. Just make this line appear STATICLIB =
lib$(TARGET).a an re-run the build process after a 'make clean'.
There is another problem with you build. When linking statically to FreeImage,
you need to define symbol FREEIMAGE_LIB prior to including header file
FreeImage.h. This header file is used for both creating and importing the DLL
as well as for static linking. With that symbol (among others), import/export
behavior as well as calling convention is controlled. By default, FreeImage.h
assumes that you link to FreeImage.dll. You can have a look at this in
FreeImage.h, starting at line 39. That's also described on the FreeImage
project page under FAQ http://freeimage.sourceforge.net/faq.html. So, I recommend adding -DFREEIMAGE_LIB to
both your C and C++ compiler flags.
Additionally, with static linking, you need to call FreeImage_Initialise
before you use FreeImage and also FreeImage_DeInitialise before you are done
with FreeImage or when you application exits. When linking dynamically, the
DLL does this job for you.
In the end, you also need to add both libraries wsock32 and ws2_32 to the list
of required libraries. These are the Windows Winsock libraries, needed by
LibRaw. So, you also need to add -lwsock32 -lws2_32 to your linker command
line.
Carsten