MinGW: Additional Library Installation Options...


I have been reading up, and it seems that all I need to do to finish up the installation of a library is to add in the search path for the library upon compile time.

Of course, I also read that directly copying the lib files can work too, but that may result in the over-writing of necessary files...

I read a more thorough document on mingw's linking processes and discovered that I could create a folder, install the library in that folder, and add the folder as a search path for mingw (so, basically, all i have to do is install all my libraries under that folder).

Since I am currently attempting to build a graphics library (quite successfuly now :), and since it was a long article with a ton of new information to absorb, my brain is fried...

Can anyone confirm this, or correct it?

Thanks for your help in advance!
> so, basically, all i have to do is install all my libraries under that folder
¿ /usr/lib/ ?
Oh, I meant a folder that I create... so mabey it's somthing like "C\:Additional_libraries" or somthing like that, and i would have an entire library in a folder under that, so "C:\additional_libraries\a_Library", but I would only need to use "\Additional_libraries" as the search option.

That's my understanding, tell me if I'm wrong... Sorry if it seems a bit poorly worded, I am mentally worn out...
you have to add this option in your linking process:
-LC:\additional_libraries
notice you must write that like above
without any spaces
You are correct.


But you may want more information.

MinGW is not a normal unix installation, so it doesn't search paths the normal way.

There are three options available to you.

Merge libraries with MinGW's stuff
Copy your library headers into C:\MinGW\include
Copy your library compiled lib files into C:\MinGW\lib

Personally, I also keep library documentation in C:\MinGW\doc
And DLLs in C:\MinGW\dlls
Just so I can find it all easily enough.

Command-line stuff
Use -I C:\Users\Jonathan\Programming\MyCoolLib\include
and -L C:\Users\Jonathan\Programming\MyCoolLib\lib

Makefiles help with this kind of thing, but you still have to explicitly link in the full paths of all the libraries you use for every project. This is a hassle, particularly if you plan to distribute your source to someone else.

GCC specs file
The MinGW specs file allows you to combine the best of both worlds: keep your stuff wherever you want, but have it in the compiler's search path without having to fiddle with command-line flags.

By default, the "specs" file exists only in GCC's imagination. To get one you can modify, open your command prompt and type:

    cd \MinGW\lib\gcc\mingw32\4.7.0
    gcc -dumpspecs > specs


My current version of GCC is 4.7. The latest version is 4.8.something (I need to upgrade). If you press TAB when you get to the version directory then the command shell will automatically fill in the directory name for you.

Now that you have a specs file, follow the recommendations given in the link to add your include and lib stuff to the proper sections of the "specs" file.
http://www.mingw.org/wiki/SpecsFileHOWTO

Hope this helps.
Last edited on
Thanks so much Duos, I'm hapy that you helped to clear that up for me. I've learned so much about my compiler today!

^^
Hopefully this may help..


On Windows Vista and newer, you'll need additional steps to make MSYS fully work if User Account Control is enabled (it is by default). Go to your MSYS folder (C:\MinGW\msys\1.0 here), open msys.bat with a text editor (right-click -> Open With -> Notepad or equivalents) and add the following line after @echo off: cd "C:\MinGW\msys\1.0"


Testing MinGW/MSYS installation

- Open the MinGW shell (MSYS) by running msys.bat.
- Run following commands:
make -v
gcc -v


Compilation and installation of the required packages
Run following commands:
mingw-get install msys-wget
mingw-get install msys-unzip
mingw-get install msys-patch


Installing Subversion
Run command:

wget http://sourceforge.net/projects/win32svn/files/1.7.6/apache22/svn-win32-1.7.6.zip/download
unzip svn-win32-1.7.6.zip
cd svn-win32-1.7.6
mv bin/* /usr/local/bin/
cd ..


Compiling zlib
Run command:

wget http://zlib.net/zlib-1.2.7.tar.gz
tar xvfz zlib-1.2.7.tar.gz
cd zlib-1.2.7
make -f win32/Makefile.gcc BINARY_PATH=/usr/local/bin INCLUDE_PATH=/usr/local/include LIBRARY_PATH=/usr/local/lib install
cd ..

Compiling libpng
Run command:

wget http://sourceforge.net/projects/libpng/files/libpng15/1.5.13/libpng-1.5.13.tar.xz/download
tar xvfJ libpng-1.5.13.tar.xz
cd libpng-1.5.13
mv INSTALL INSTALL.txt
./configure
make install
cd ..


Compiling liblzo2
Run command:

wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.06.tar.gz
tar xvfz lzo-2.06.tar.gz
cd lzo-2.06
./configure --enable-static
make install
cd ..


Compiling libfreetype
Run command:

wget http://sourceforge.net/projects/freetype/files/freetype2/2.4.10/freetype-2.4.10.tar.gz/download
tar zxvf freetype-2.4.10.tar.gz
cd freetype-2.4.10
./configure --enable-static
make install
cd ..


Compiling xz
Run command:

wget http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-runtime_0.18.1.1-2_win32.zip
unzip gettext-runtime_0.18.1.1-2_win32.zip -d /usr/local
wget http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.26/glib_2.26.0-2_win32.zip
unzip glib_2.26.0-2_win32.zip -d /usr/local
wget http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/pkg-config_0.23-3_win32.zip
unzip pkg-config_0.23-3_win32.zip -d /usr/local
wget http://tukaani.org/xz/xz-5.0.4.tar.gz
tar xvfz xz-5.0.4.tar.gz
cd xz-5.0.4
./configure --enable-static --disable-threads
make install
cd ..


Getting the source code
Run command:

cd && svn checkout svn://svn.openttd.org/trunk



Compiling OpenTTD

Start MSYS.
Run:
cd ~/<path_to_source>
./configure
make

(note that ~ means your MSYS home folder)

- The compiling is complete when the openttd.exe file is made. It will be copied to the ./bin subfolder.
- To test your compilation you can run (from the same folder in which you compiled OpenTTD):
./bin/openttd

- Don't forget to install a base graphics set before this step if you don't have one (the simplest solution is to install OpenGFX)

- If you want to generate a installation bundle you can use this command:
make bundle

After this command is done you will find a complete OpenTTD ready for distribution in the ~/<path_to_source>/bundle folder.
Patching the source code

Place the patch you want to apply into the directory the OpenTTD source code is located in (<MinGW installation folder>\MSYS\1.0\home\<your Windows user name>\trunk in this example). Then, in the MSYS shell:
cd ~/trunk
patch -p1/p0 < <patch name>
@Python7

Based on what I'm reading, I'm inferring that these are libraries... Would you mind elaborating on wat they do (or at least give their official names so I can look them up)?

I appreciate the help.
Alright, it seems I have had my first success at integrating a library!

But now I am getting errors, and I am not even sure what to look for. I think I copied all of the library and include files into MinGW, and I even renamed some of the library files (ex: from wxbase28ud.lib -> wxbase.lib) in case that was the issue...

Is there anything I'm missing?

I would post the error, but it is quite lengthy, and there are only a few functions it can't seem to define:

c:\mingw\include\wx\buffer.h:127:1: error: 'strdup' was not declared in this scope
c:\mingw\include\wx\buffer.h:134:1: error: '_wcsdup' was not declared in this scope
c:\mingw\include\wx\string.h:141:31: error: 'strcasecmp' was not declared in this scope


Those are the only functions it has a problem finding, but they are spread around a few files, like string.h, etc... If you need the full mingw output, let me know. I can not seem to figure this out, and I am not even slightly sure of what to search for.

Folders I copied into the MinGW:

.\lib\wx
.\include\wx

Do I have to modify the search paths for the compiler, or does it recursively search? I.E.: would it find the lib files in the .\include\wx folder because one of it's defaults is .\include??
Those are all non-standard functions, so you have to make sure to #include the right stuff (and be using the right system -- which for you looks like Windows).

For strdup() you need to #include <string.h> and use _strdup().

For _wcsdup() you should also #include <wchar.h>.

For strcasecmp() you should use stricmp().


For the lib files, no, it will not find it in subdirectories.

For the include files, it will only find it if you #include <subdir/foo.h>.

Hope this helps.
It does not seem to be working. I included string.h in the header that strdup() is in, after changing it to _strdup() (it also doesn't read strdup(), it reads strdup)

So far, it still says the same errors, but with _strdup now...
Topic archived. No new replies allowed.