-1

I've spent the last 5 hours trying to link a binary file to my program, I am using eclipse + MinGW, and trying to include the FreeImage source (downloaded from internet), the thing is I am unable to include the .lib file since it doesn't work, so I am trying to convert it to .a file.

I used MSYS software in order to do it, but nothing is working, the errors go, but the the program just fails/crashes.

Is there a way to convert .lib files to .a files so I can include them to my program.

Please help me, I really need this, and I've looked so hard to find some solutions, nothing worked, someone please direct me. Thanks in advance <3

ConanCoder
  • 39
  • 2
  • 10
  • 1
    What platform is the ".lib" file targeted for? What platform is your program targeted for? – Thomas Matthews Aug 10 '17 at 00:20
  • 1
    You may have to download the source for the ".lib" and rebuild on your system into a ".a" format. – Thomas Matthews Aug 10 '17 at 00:21
  • Typically, .lib files are targeted for MS platforms. Are you absolutely certain you're using the proper version of the library for your OS? When you say *the .lib file since it doesn't work*, what **specific** problem are you having (before trying to convert it)? – Ken White Aug 10 '17 at 00:22
  • I am on windows, and my lib file is for texture purposing, I am building a game engine, and want to use a texture and image reading, so i took a one from the internet called FreeImage, but it's only in lib as I saw – ConanCoder Aug 10 '17 at 01:02
  • In Linux there are tools to 'investigate' archives (.a) and shared object files (.so). These allow you to extract objects, and insert objects (like maybe from .so to .a, when objects are compatible). mingw probably has something similar. Maybe start with search for "extract obj from .so". Try on google 'extract object from .so'. – 2785528 Aug 10 '17 at 01:06

2 Answers2

1

See this answer. It recommends http://code.google.com/p/lib2a/

fstop_22
  • 971
  • 5
  • 9
0

You must compile opencv with gcc-mingw. gcc-mingw compiles for a different operating system - mingw is a subset of Linux. Libraries compiled for Windows are simply not compatible.

You can easily find instructions for building opencv for mingw using google, or here:

Getting started with OpenCV 2.4 and MinGW on Windows 7

You'll also need to compile FreeImage, the source code for FreeImage is available at http://freeimage.sourceforge.net/download.html

Michaël Roy
  • 6,338
  • 1
  • 15
  • 19
  • So if I compile openvc with gcc-mingw, the compiler will be able to read lib file, if so, how do I compile with openvc? is it normal installation ? – ConanCoder Aug 10 '17 at 01:03
  • gcc creates .a files. And yes, you can say that compiling libraries with the same compiler and for the same OS as the rest of the application is standard procedure. – Michaël Roy Aug 10 '17 at 01:07