Cannot build C++ libraries in MinGW

Pages: 12
OK, now you have 32 bit compiler, to use this compiler and compile 32 bit libosmscout code use mingw32_shell.bat and repeat the steps from 32 bit shell.

it should work now.

I know this is hard, I was going tru same steps and there is learning curve involved, in the end it might not work at all for any reason, but how else you can learn?


After "make" it seems to be compiling fine now, we will see soon enough I believe.

Yes it seems hard to me and I can't thank you enough for your patience to walk me through the process. I really respect people with such skill (+ kindness). And honestly I don't see how I could learn this process myself. Unlike basic programming skills which I got from books and practice, this thing looks like an impenetrable barrier =/

EDIT:

Compilation is done and it looks fine at first sight. Source code folder now has a .libs folder containing 5 files, 2 of them being libosmscout.a and libosmscout-0.dll which I believe are most important ones (don't quite understand the zero in dlls name).
Last edited on
Congrats!

the '0' in the dll name could be indicating a binary version or something, the code is beta so it makes sense.

to link your program against the library which you have just built use libosmscout.a in code::blocks.

header search directory should be set to libosmscout\include

Note that you'll need to set up code::blocks to use MSYS2 version of the compiler and not the bundled one.
Last edited on
Thanks! I'm glad it succeeded this time, it is all thanks to you.

So I believe I should do same with the rest of the libarry components, right?
I tried the same procedure with libosmscout-map

but I got error:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
... stuff before ...
.......
checking for WIN32... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for LIBOSMSCOUT... no
configure: error: Package requirements (libosmscout) were not met:

No package 'libosmscout' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBOSMSCOUT_CFLAGS
and LIBOSMSCOUT_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.


How can I solve this and avoid it when trying to build the rest of components?

edit:
Linking against libosmscout.a will produce a large executable, while libosmscout-0.dll can be just added to exe directory, right?
Last edited on
the rest of the components obviously depend on libosmscout.

As the output tells you:
you need to adjust PKG_CONFIG_PATH environment variable which will tell where the libosmscout is.

run:
echo $PKG_CONFIG_PATH
to see where is this path.

run:
pkg-config --modversion libosmscout
to see if the library is installed.

If the library is not installed (ex. pkg-config tell's there is no such library) then you'll need to go back to previous directory (path/to/libosmscout) by using correct MSYS2 shell and run following only:
1
2
cd path/to/libosmscout
make install


then again:
pkg-config --modversion libosmscout
to see if that worked.
echo gives:
1
2
$ echo $PKG_CONFIG_PATH
/mingw32/lib/pkgconfig:/mingw32/share/pkgconfig


and then:
1
2
3
4
5
$  pkg-config --modversion libosmscout
Package libosmscout was not found in the pkg-config search path.
Perhaps you should add the directory containing `libosmscout.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libosmscout' found 


Response is same even after make install

EDIT

I followed the hint by shell and it seems to have worked, will see what happens now with other packages
Last edited on
this is probably because configure script was run without specifying a --prefix

can you check manually /mingw32/lib/pkgconfig and /mingw32/share/pkgconfig
and see if there is a file libosmscout.pc

if not manually copy libosmscout.pc from libosmscout root directory (the one where you built the library) into /mingw32/lib/pkgconfig

then again run:
pkg-config --modversion libosmscout

Note that building other components might depend on whole host of dependencies not jsut libosmscout.

you should check if libosmscout is enough for your application.

edit:

libosmscout-0.dll is an import library for your application to link against the dll.
libosmscout.a is a static library, and does not require libosmscout DLL.

executable will be much smaller by using libosmscout-0.dll but ti will depend on the DLL.
Last edited on
What you said is exactly what I needed to do.

I expect to be needing only three components of the library (libosmscout, libosmscout-map, and libosmscout-map-cairo).

libosmscout-map built fine it seems but of course cairo is being a problem, since it's another 3rd party library. I got it with GTK installation but now it is missing yet another library (pixman). So my chase continues here, which is probably way out of the scope of this topic already I'm afraid.
Last edited on
you now have all the tools and knowledge you need, just install missing stuff and compile.

use pacman -Ss to find stuff.

for example:
pacman -Ss pixman

output:
mingw32/mingw-w64-i686-pixman 0.33.2-1
The pixel-manipulation library for X and cairo (mingw-w64)
mingw64/mingw-w64-x86_64-pixman 0.33.2-1
The pixel-manipulation library for X and cairo (mingw-w64)



use pacman -S to install missing stuff.

From the above output you can tell how to do this:

pacman -S mingw-w64-i686-pixman

edit:

do the same for any missing package.
if pacman -Ss does not find the package you need then you need to build it manually, as you did with the libosmscout

Code::Blocks will now perform better with MSYS2 since all you need is there ;)
Last edited on
Thank you. I did the pacman -S mingw-w64-i686-pixman and apparently it installed well. However now when trying to "make" some messages appeared which I have no idea how to interpret, and compilation didn't return dynamic libraries, only static.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
$ make
Making all in src
make[1]: Entering directory '/n/projektiCPP/libosmscout/libosmscout-map-cairo/src'
  CXX      osmscout/LoaderPNG.lo
  CXXLD    libosmscoutmapcairo.la

*** Warning: linker path does not have real file for library -losmscoutmap.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libosmscoutmap but no candidates were found. (...for file magic test)

*** Warning: linker path does not have real file for library -lpangocairo-1.0.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libpangocairo-1.0 but no candidates were found. (...for file magic test)

*** Warning: linker path does not have real file for library -lpangoft2-1.0.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libpangoft2-1.0 but no candidates were found. (...for file magic test)

*** Warning: linker path does not have real file for library -lpangowin32-1.0.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libpangowin32-1.0 but no candidates were found. (...for file magic test)

*** Warning: linker path does not have real file for library -lpango-1.0.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libpango-1.0 and none of the candidates passed a file format test
*** using a file magic. Last file checked: C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/../../../../i686-w64-mingw32/lib/../lib/libgdi32.a

*** Warning: linker path does not have real file for library -lgobject-2.0.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libgobject-2.0 and none of the candidates passed a file format test
*** using a file magic. Last file checked: C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/../../../../i686-w64-mingw32/lib/../lib/libgdi32.a

*** Warning: linker path does not have real file for library -lgmodule-2.0.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libgmodule-2.0 and none of the candidates passed a file format test
*** using a file magic. Last file checked: C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/../../../../i686-w64-mingw32/lib/../lib/libgdi32.a

*** Warning: linker path does not have real file for library -lglib-2.0.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libglib-2.0 and none of the candidates passed a file format test
*** using a file magic. Last file checked: C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/../../../../i686-w64-mingw32/lib/../lib/libgdi32.a

*** Warning: linker path does not have real file for library -lintl.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libintl and none of the candidates passed a file format test
*** using a file magic. Last file checked: C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/../../../../i686-w64-mingw32/lib/../lib/libgdi32.a

*** Warning: linker path does not have real file for library -lcairo.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libcairo and none of the candidates passed a file format test
*** using a file magic. Last file checked: C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/../../../../i686-w64-mingw32/lib/../lib/libgdi32.a

*** Warning: linker path does not have real file for library -lfreetype.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libfreetype and none of the candidates passed a file format test
*** using a file magic. Last file checked: C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/../../../../i686-w64-mingw32/lib/../lib/libgdi32.a

*** Warning: linker path does not have real file for library -lfontconfig.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libfontconfig and none of the candidates passed a file format test
*** using a file magic. Last file checked: /mingw32/lib/libz.dll.a

*** Warning: linker path does not have real file for library -lpng12.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libpng12 and none of the candidates passed a file format test
*** using a file magic. Last file checked: /mingw32/lib/libpixman-1.dll.a
*** The inter-library dependencies that have been dropped here will be
*** automatically added whenever a program is linked with this library
*** or is declared to -dlopen it.

*** Since this library must not contain undefined symbols,
*** because either the platform does not support them or
*** it was explicitly requested with -no-undefined,
*** libtool will only create a static version of it.


Can you explain me why this happened and if there is a way I could also build DLL libraries?

EDIT

Also, when trying to compile demos (looking at makefile I suppose it will try to compile all demos, but skip those for which needed libraries aren't present), I get this error:
cannot find -losmscoutmap

I don't understand it, since library compiled well and also pkg-config --modversion libosmscout gives a positive result =/
Last edited on
You've just opened a can of worms (joke).

The easiest way to interpret such messages is by getting comfortable with using the provided help system.

for example if you run:
./configure --help

you will see in the output that there are many options available and one of them is an option to build DLL's.

for example
./configure --enable-shared
will build DLL's and their associated import and export libraries.

another possible reason for these messages is that linker does not have correct search paths.
by running configure --help you can see how to adjust these paths.

for linker you'll see that adjusting this is done by setting the LDFLAGS variable

for example:
./configure --enable-shared LDFLAGS='-L/path/to/import_lib -lmy_lib.dll.lib'

the -L is used to specify library path, and -l (lower case L) is used to specify library file name.

You are supposed to learn what compiler and linker flags are available and how to set them by using the compiler documentation, as well as whole host of other kind of documentation, and then using this knowledge with configure --help

You have no other choice but to run configure --help and simply prepare all the flags you might need, and provide them to configure script as needed, in order for compilation to go nice and smooth.

Don't expect to learn all the stuff over one night, there is a lot of details.
Last edited on
I see, it really is a lot of details. And surely I won't learn all the stuff over one night because this night is halfway through already =)) Thank you very much for your help Sir and all the best to you.
Topic archived. No new replies allowed.
Pages: 12