Mingw linker cannot find my static libraries

4,726 views
Skip to first unread message

Fred Philip

unread,
Sep 15, 2014, 12:37:20 PM9/15/14
to harbou...@googlegroups.com
hi fellows,
 
after a few days away from Clipper and Harbour, I am back on the scene :-)
 
And I have a new problem :(
 
I have two (home made) static libraries, let's call them mylib1 and mylib2.
 
In my hbmk2 make script (MyApps.hbp) I added the following lines:
1. "-LE:\harbour\lib" that's the location where the linker posted the libraries (*which have the names "libmy;ib1.a" and "libmylib2.a")
2. "-llibmylib1" and "-llibmylib2"
 
During the link process of my final executable I receive the error message:
<path to Harbour>/mingw/bin/lib/gcc/mingw32/4.6.1-dw2/../../../../mingw32bion/ld.exe: cannot find -lmylib1
and
<path to Harbour>/mingw/bin/lib/gcc/mingw32/4.6.1-dw2/../../../../mingw32bion/ld.exe: cannot find -lmylib2
 
Any ideas why the linker cannot find my libraries?
 
Any help is much appreciated
TIA
Fred
 
 
I'm using Harbour Vers 3.2.0d with MingW compiler.
 
 

Massimo Belgrano

unread,
Sep 15, 2014, 12:47:36 PM9/15/14
to harbou...@googlegroups.com

2014-09-15 18:37 GMT+02:00 Fred Philip <fphil...@gmail.com>:
mylib1

use mylib1 then lib is but prefix and a extension are 
not use reference in creation to lib*.a
so create and use a name as mylib2 instead libmylib2

--
Massimo Belgrano
Delta Informatica S.r.l. (Cliccami per scoprire 

Fred Philip

unread,
Sep 15, 2014, 1:26:30 PM9/15/14
to harbou...@googlegroups.com
Hi Massimo,
 
do you mean I should force during the linking of the libraries the output name as "mylib1" and "mylib2"?
 
Well, I did that in my hbmk2 script for the libraries with options -omylib1. The linker still created the libmylib1 and libmylib2.
I even renamed the libraries back to "mylib1" and "mylib2" (actually there is a version "mylib1" and "mlibmylib1" available), still the error is reported (see above).
 
So I think I covered everything and can't imagine what else I should do.
 :-(
 
TIA
Fred

Massimo Belgrano

unread,
Sep 15, 2014, 1:32:04 PM9/15/14
to harbou...@googlegroups.com
you not rename
ignore the prefix

post sample prg+hbmk2 hbp or command line  
who create fist library
then second sample +hbmk2 where you use



--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

elch

unread,
Sep 15, 2014, 1:38:49 PM9/15/14
to harbou...@googlegroups.com
Hi Fred,

what Massimo want to express:
a 'lib' PREfix is automatic added to the file name.

If you write: "-llibmylib1", liblibmylib1 is searched.
So leave that first 'lib' away ..

best regards
Rolf

Fred Philip

unread,
Sep 21, 2014, 11:22:35 AM9/21/14
to harbou...@googlegroups.com
Klas / Massimo

That is what I did initially (no prefix) - It didn't work.
After that, I changed the name (removed the prefix) - didn't work I neither.
I documented the path in the hbp file to these libs through <-L>. No success.

I am puzzled and don't know whats to do next.

Any reply much appreciated

TIA
Fred


On Monday, September 15, 2014 12:37:20 PM UTC-4, Fred Philip wrote:

Pritpal Bedi

unread,
Sep 21, 2014, 11:40:48 AM9/21/14
to harbou...@googlegroups.com
Hi

Any reply much appreciated


Show here the cntents of your .hbp.
We will try to fix that fo ryou.


Pritpal Bedi

Klas Engwall

unread,
Sep 21, 2014, 12:34:38 PM9/21/14
to harbou...@googlegroups.com
Hi Fred,

> That is what I did initially (no prefix) - It didn't work.
> After that, I changed the name (removed the prefix) - didn't work I neither.
> I documented the path in the hbp file to these libs through <-L>. No
> success.
>
> I am puzzled and don't know whats to do next.
>
> Any reply much appreciated

To understand what is happening, I think we need to see both the .hbp
file and a DIR listing of the directory pointed to with -L

Regards,
Klas

Fred Philip

unread,
Sep 21, 2014, 5:00:04 PM9/21/14
to harbou...@googlegroups.com
Klas..

basically I described the settings already before ... but ok -- here are the files (attached).
Something happening that makes no sense, if the directives are in the hbp file - it should work.

Please don't get confused with the different file names, the libs have changed (since last posting), the problem remains.
btw. the affected libraries as 3rd party libraries from OTC Poland for Mediator - Oracle 11g.

But perhaps you guys have an explanation.


TIA
Fred



On Monday, September 15, 2014 12:37:20 PM UTC-4, Fred Philip wrote:
libfolder.PNG
myApps.hbp

Pritpal Bedi

unread,
Sep 21, 2014, 6:28:38 PM9/21/14
to harbou...@googlegroups.com
Hi


#
# $Id$
#

# compiler options
-kmo 
-m 
-n2
-w0 
-es2

# with debug info - You will not need this swicth at all while debugging with HbIDE
-b

-inc

# include path
-incpath=E:\Harbour\MultiB\mbs-admin\incl

# libraries paths
-LE:\Medcl\Harbour\lib\build3201\mingw

#  next is for the MBS specific libs - are these Harbour's default libs ? If yes, you do not need to set it in .hbp
-LE:\harbour\lib


# libraries 3rd party
-lmedntx
-lcmnnet32

-static
# libraries home made   ???  What is the path to these libs - Add the -L__path_to_libs_below_ 
-lblib
-lmxlib01
-lmbsmed

# It should be ok, but this can be stated as above, here it is duplicated
-prgflag=/b 

# create a Exe file
-hbexe

# define the name of the output file
-ohbmbsAdm

# include other libraries during linking - better would be to use hbnf.hbc hboslib.hbc which you have done correctly down few lines
#-lhbnf
#-lhboslib

# additional compiler option files (package config files)
hbnf.hbc
hbblink.hbc
hboslib.hbc

-nulrdd-

# source code moduls
Module1.PRG
Module2.PRG
...
...
...
Module55.prg

===========================

Check my comments and 


Pritpal Bedi 

Fred Philip

unread,
Sep 21, 2014, 10:01:40 PM9/21/14
to harbou...@googlegroups.com
Hi Pritpbal,

thank you for your comment's, however they do not really addressing the problem that the linker can't find the libs "medntx" and "cmnnet32" :-(

In addition
- I do  not use HBIDE (at least not at this time)
- the libraries "blib", "mxlib01" and "mbsmed" using the path "harbour\lib" (-LE:\harbour\lib)
- as you can see, the lines '-lhbnf' and '-lhboslib' are marked as comment and being replaced by hbnf.hbc and hboslib.hbc

For me remains the questions, why can't the linker find the libs "medntx" and cmnnet32" ??????


Fred


On Monday, September 15, 2014 12:37:20 PM UTC-4, Fred Philip wrote:

Klas Engwall

unread,
Sep 21, 2014, 11:10:25 PM9/21/14
to harbou...@googlegroups.com
Hi Fred,

> basically I described the settings already before ... but ok -- here are
> the files (attached).
> Something happening that makes no sense, if the directives are in the
> hbp file - it should work.
>
> Please don't get confused with the different file names, the libs have
> changed (since last posting), the problem remains.
> btw. the affected libraries as 3rd party libraries from OTC Poland for
> Mediator - Oracle 11g.
>
> But perhaps you guys have an explanation.

# libraries 3rd party
-lmedntx
-lcmnnet32

These entries are fine, but MinGW expects the files themselves to have
"lib" prefixes, which are missing in the screenshot. Did you remove the
prefix of the files in the directory? The advice you got previously to
drop the prefix was referring to the entries in the .hbp file, not to
the files themselves.

So what seems to be confusing you is that the MinGW convention is to
have files with names that have a "lib" prefix but to skip that prefix
when referencing them.

Pritpal's (please note the spelling) comments also apply ...

Regards,
Klas

Klas Engwall

unread,
Sep 21, 2014, 11:13:37 PM9/21/14
to harbou...@googlegroups.com
Hi again,

> - as you can see, the lines '-lhbnf' and '-lhboslib' are marked as
> comment and being replaced by hbnf.hbc and hboslib.hbc

Sorry, can't see that

# include other libraries during linking
-lhbnf
-lhboslib

Regards,
Klas

Pritpal Bedi

unread,
Sep 22, 2014, 12:15:16 AM9/22/14
to harbou...@googlegroups.com
Hi Klas


 
Pritpal's (please note the spelling) comments also apply ...


Yep, I missed, seems I need a fresh pair of glasses.


Pritpal Bedi 

Fred Philip

unread,
Sep 23, 2014, 5:16:42 PM9/23/14
to harbou...@googlegroups.com

Hi Klas, Hi Pritbal,

for clarification here is a cutout of my HBP file (attached with a previous posting)
[.......

# libraries paths
-LE:\Medcl\Harbour\lib\build3201\mingw

# libraries 3rd party
-lmedntx
-lcmnnet32
.......]

These two libraries (medntx and cmnnet32) can not be found by the MingW linker even though the path is included in the hbp file (-LE:\Medcl\Harbour\lib\build3201\mingw).

The folder listing shows they are in this specific folder.

Why...why...why  .

TIA

Fred






On Monday, September 15, 2014 12:37:20 PM UTC-4, Fred Philip wrote:
On Monday, September 15, 2014 12:37:20 PM UTC-4, Fred Philip wrote:

Klas Engwall

unread,
Sep 23, 2014, 5:37:20 PM9/23/14
to harbou...@googlegroups.com
Hi Fred,

> Why...why...why .

Please check again my response yesterday to your post with the attachments

Regards,
Klas

Fred Philip

unread,
Sep 23, 2014, 10:15:10 PM9/23/14
to harbou...@googlegroups.com
Hi Klas,

staying focused on the two libraries discussed at the bottom of thread (medntx  and cmnnet32).
These are libraries that are part of the (provided) Mediator package for Harbour.

These two libs do not have the prefix "lib" in their name ("medntx" and not "libmedntx", "cmnnet32" and not "libcmnnet32").
The questions that comes into my mind is, can I use an option (in *.hbp) that suppresses the automatic use of prefix of "lib" in hbmk2?
Means: if I have  a library with the name "libfoo" - use "libfoo" in the hbp file, If I have a lib with the name "foo" - use the name "foo" in the hbmk2 file?

Why are they modifying inside of hbmk2 the use of library names in the first place ??

Do you have a clue why the dev team of Harbour is using these modification of file names?
It appears to me it shouldn't be needed and it's only confusing.

Anyway, thank you for your patience and your posting.

TIA
Fred

Klas Engwall

unread,
Sep 24, 2014, 12:58:44 AM9/24/14
to harbou...@googlegroups.com
Hi Fred,

> staying focused on the two libraries discussed at the bottom of thread
> (medntx and cmnnet32).
> These are libraries that are part of the (provided) Mediator package for
> Harbour.
>
> These two libs do not have the prefix "lib" in their name ("medntx" and
> not "libmedntx", "cmnnet32" and not "libcmnnet32").
> The questions that comes into my mind is, can I use an option (in *.hbp)
> that suppresses the automatic use of prefix of "lib" in hbmk2?
> Means: if I have a library with the name "libfoo" - use "libfoo" in the
> hbp file, If I have a lib with the name "foo" - use the name "foo" in
> the hbmk2 file?
>
> Why are they modifying inside of hbmk2 the use of library names in the
> first place ??
>
> Do you have a clue why the dev team of Harbour is using these
> modification of file names?
> It appears to me it shouldn't be needed and it's only confusing.
>
> Anyway, thank you for your patience and your posting.

It has nothing to do with hbmk2 and the Harbour team, but it is a
requirement of the GNU linker, which is the linker MinGW uses. And it is
not a MinGW peculiarity either but a Unix convention.

Try adding the "lib" prefix to the files in the directory.

Here is the explanation from the MinGW team:
http://www.mingw.org/wiki/specify_the_libraries_for_the_linker_to_use

Regards,
Klas

Jayadev U

unread,
Sep 24, 2014, 1:48:01 AM9/24/14
to harbou...@googlegroups.com

Hi,

 

As suggested earlier in the thread, please prefix lib with the libraries and all is well.  For example rename MedNtx.a libMedNtx.a .  I have successfully used this method to use Mediator with Harbour and Mysql.

 

Warm regards,

 

Jayadev

 

 

--

Fred Philip

unread,
Sep 24, 2014, 8:10:34 AM9/24/14
to harbou...@googlegroups.com
Hi Klas,
 
that is a really good answer and it makes me keeping my mouth shut now (regarding this subject).
 
In the meantime, I tweaked the two library names (added prefix "lib"() and e voila, it works (as Jayadev indicated).
 
I think this problem is resolved and I can move on to the next problem - hehe.
 
Another lesson learned :-)
 
Thank you all
 
Fred
 

On Monday, September 15, 2014 12:37:20 PM UTC-4, Fred Philip wrote:
Reply all
Reply to author
Forward
0 new messages