installing Lingua::LinkParser on Win32

N

natdavis_2000

I am trying to install Lingua::LinkParser on a Win32 machine. I have
downloaded and installed the Win32 version of the Link Parser tool. I
can build the makefile successfully, but when I run nmake I get the
following errors:

LinkParser.obj : error LNK2001: unresolved external symbol
_dictionary_create
LinkParser.obj : error LNK2001: unresolved external symbol
_dictionary_delete
LinkParser.obj : error LNK2001: unresolved external symbol
_dictionary_get_max_cost
LinkParser.obj : error LNK2001: unresolved external symbol
_linkage_and_cost

TIA,
Nat
 
S

Sisyphus

I am trying to install Lingua::LinkParser on a Win32 machine. I have
downloaded and installed the Win32 version of the Link Parser tool. I
can build the makefile successfully, but when I run nmake I get the
following errors:

LinkParser.obj : error LNK2001: unresolved external symbol
_dictionary_create
LinkParser.obj : error LNK2001: unresolved external symbol
_dictionary_delete
LinkParser.obj : error LNK2001: unresolved external symbol
_dictionary_get_max_cost
LinkParser.obj : error LNK2001: unresolved external symbol
_linkage_and_cost

Looks like you're failing to link to whichever library ('.lib' file) it is
that resolves those symbols - I guess it's a library that's part of the
"Link Parser tool" you referred to. (Actually, looking at the module source,
it appears that you're expected to link to object files rather than a
library archive.)

If you installed from
http://www.link.cs.cmu.edu/link/ftp-site/link-grammar/link-4.1b/windows/link41b.zip
then, unfortunately that package doesn't contain a '.lib' file or any object
files - and therein lies a problem.

Did you get your "Link Parser tool" from there ?
Do you have either a library or object files to link to ?

Cheers,
Rob
 
N

natdavis_2000

Rob - I sure did download from there.
From my working directory in the blib\arch\auto\Lingua\LinkParser
directory there is a lib file named LinkParser.lib, but is created when
I run nmake. There is no *.obj file.

So I am tough out of luck?

Thanks,
Nat
 
S

Sisyphus

Rob - I sure did download from there.

directory there is a lib file named LinkParser.lib, but is created when
I run nmake.

That's not the '.lib' file that we need. We need a '.lib' file built using
the '.c' and '.h' files from the link41b.zip file.

I did the following:
1) Unzip link41b.zip to F:/link_parser
2) Copy the '.h' files from F:/link_parser/include to F:/link_parser/src
3) cd to the F:/link_parser/src folder
4) In F:/link_parser/src/resources.c change the 2 occurrences of '#if
!defined(WIN32)' to '#ifndef _WIN32'. On my box at least, it seems that
'WIN32' is not defined, though _WIN32 is defined. (If resources.c compiles
ok, then that's all that matters.)
5) run 'cl /MD -c *.c' (you'll get errors wrt constituent-example.c - I
don't think that matters)
6) then run 'lib /out:linkparser.lib *.obj'

Then, in the Lingua::LinkParser source, place copies of the afore-mentioned
'.h' files in the top level folder (same folder as the Makefile.PL), and
change the Makefile.PL so that it consists simply of:

---start---
use ExtUtils::MakeMaker;

WriteMakefile(
'NAME' => "Lingua::LinkParser",
'VERSION_FROM' => "LinkParser.pm",
'LIBS' => "-LF:/link_parser/link41b/src -llinkparser",
'OBJECT' => "LinkParser.o @objects",
'DEFINE' => "",
'INC' => "-L$LP_DIR/obj -I$LP_DIR/include"
);
---finish---

You'll probably need to change the 'LIBS' entry to specify the path to your
link41b/src folder. (You should also be able to delete the 'OBJECT',
'DEFINE' and 'INC' entries entirely if you wish - though it didn't seem to
matter for me.)

Then open 'LinkParser.pm' and edit the value of $DATA_DIR so that it
specifies the location of the 'data' directory. In my case:

$DATA_DIR='F:/link_parser/link41b/data';

Then run 'nmake clean' (to get rid of any previously built makefile, blib,
etc.), followed by 'perl Makefile.PL' , and 'nmake'.

That should get the thing compiled ok - but the problems don't quite end
there. When I run 'nmake test', I get:

Microsoft (R) Program Maintenance Utility Version 7.00.9466
Copyright (C) Microsoft Corporation. All rights reserved.

F:\perlvc7\bin\perl.exe "-Iblib\lib" "-Iblib\arch" test.pl
1..15
ok 1
Dictionary creation failed at test.pl line 19
NMAKE : fatal error U1077: 'F:\perlvc7\bin\perl.exe' : return code '0xff'
Stop.

Not quite sure why that is - looks to have something to do with the
'dictionary_create()' function. I'll leave that part of it up to you for the
moment - but if you have trouble getting it sorted, then let us know, and
I'll take a look. (I'll probably take another look later anyway - in which
case I'll post again if I work out what's needed.)

Hth.

Cheers,
Rob
 
S

Sisyphus

Sisyphus said:
When I run 'nmake test', I get:

Microsoft (R) Program Maintenance Utility Version 7.00.9466
Copyright (C) Microsoft Corporation. All rights reserved.

F:\perlvc7\bin\perl.exe "-Iblib\lib" "-Iblib\arch" test.pl
1..15
ok 1
Dictionary creation failed at test.pl line 19
NMAKE : fatal error U1077: 'F:\perlvc7\bin\perl.exe' : return code '0xff'
Stop.


Ok ... the problem is with the utilities.c function 'dictopen'. You'll find
these comments about dictopen in that file:

"This function is used to open a dictionary file or a word file,
or any associated data file (like a post process knowledge file).
It works as follows. If the file name begins with a "/", then
it's assumed to be an absolute file name and it tries to open
that exact file.
If the filename does not begin with a "/", then it uses the
dictpath mechanism to find the right file to open. This looks
for the file in a sequence of directories until it finds it. The
sequence of directories is specified in a dictpath string, in
which each directory is followed by a ":".
The dictpath that it uses is constructed as follows. If the
dictname is non-null, and is an absolute path name (beginning
with a "/", then the part after the last "/" is removed and this
is the first directory on the dictpath. After this comes the
DICTPATH environment variable, followed by the DEFAULTPATH."

(This is a very non-portable thing to be doing, btw. If you care enough, you
might like to inform the developers .... though given that that they have
produced an executable that works on Win32, they are probably aware of the
issue. Still - if they care about being portable, they shouldn't be doing
this.)

For me, one solution was as simple as changing $DATA_DIR from
'F:/link_parser/link41b/data' to simply '/link_parser/link41b/data'. But
that only works because I'm running in the F drive. If ever I try to 'use
Lingua::LinkParser;' in a script when my current working directory is in a
drive other than F, then that script is going to crash. If you need to work
across different drives then you'll have to take a closer look at the way
dictopen() operates and work it out from that - which may mean you have to
hack at the dictopen() code in utilities.c.

Anyway .... I now get:

F:\comp_vc7\Lingua-LinkParser-1.09>nmake test

Microsoft (R) Program Maintenance Utility Version 7.00.9466
Copyright (C) Microsoft Corporation. All rights reserved.

F:\perlvc7\bin\perl.exe "-Iblib\lib" "-Iblib\arch" test.pl
1..15
ok 1
Opening /link_parser/link41b/data/words/words.n.p
Opening /link_parser/link41b/data/words/words.n.1
Opening /link_parser/link41b/data/words/words.n.2.s
Opening /link_parser/link41b/data/words/words.n.2.x
Opening /link_parser/link41b/data/words/words.n.3
Opening /link_parser/link41b/data/words/words.n.4
Opening /link_parser/link41b/data/words/words.s
Opening /link_parser/link41b/data/words/words.n.t
Opening /link_parser/link41b/data/words/words.y
Opening /link_parser/link41b/data/words/words.v.1.1
Opening /link_parser/link41b/data/words/words.v.1.2
Opening /link_parser/link41b/data/words/words.v.1.3
Opening /link_parser/link41b/data/words/words.v.1.4
Opening /link_parser/link41b/data/words/words.v.5.1
Opening /link_parser/link41b/data/words/words.v.5.2
Opening /link_parser/link41b/data/words/words.v.5.3
Opening /link_parser/link41b/data/words/words.v.5.4
Opening /link_parser/link41b/data/words/words.v.2.1
Opening /link_parser/link41b/data/words/words.v.2.2
Opening /link_parser/link41b/data/words/words.v.2.3
Opening /link_parser/link41b/data/words/words.v.2.4
Opening /link_parser/link41b/data/words/words.v.2.5
Opening /link_parser/link41b/data/words/words.v.6.1
Opening /link_parser/link41b/data/words/words.v.6.2
Opening /link_parser/link41b/data/words/words.v.6.3
Opening /link_parser/link41b/data/words/words.v.6.4
Opening /link_parser/link41b/data/words/words.v.6.5
Opening /link_parser/link41b/data/words/words.v.4.1
Opening /link_parser/link41b/data/words/words.v.4.2
Opening /link_parser/link41b/data/words/words.v.4.3
Opening /link_parser/link41b/data/words/words.v.4.4
Opening /link_parser/link41b/data/words/words.v.4.5
Opening /link_parser/link41b/data/words/words.v.8.1
Opening /link_parser/link41b/data/words/words.v.8.2
Opening /link_parser/link41b/data/words/words.v.8.3
Opening /link_parser/link41b/data/words/words.v.8.4
Opening /link_parser/link41b/data/words/words.v.8.5
Opening /link_parser/link41b/data/words/words.v.1.p
Opening /link_parser/link41b/data/words/words.v.10.1
Opening /link_parser/link41b/data/words/words.v.10.2
Opening /link_parser/link41b/data/words/words.v.10.3
Opening /link_parser/link41b/data/words/words.v.10.4
Opening /link_parser/link41b/data/words/words.adj.1
Opening /link_parser/link41b/data/words/words.adj.2
Opening /link_parser/link41b/data/words/words.adj.3
Opening /link_parser/link41b/data/words/words.adv.3
Opening /link_parser/link41b/data/words/words.adv.1
Opening /link_parser/link41b/data/words/words.adv.2
ok 2
ok 3
ok 4
ok 5
ok 6
ok 7
ok 8
ok 9
ok 10
ok 11
ok 12
ok 13
ok 14
ok 15
'No tests defined for Lingua::LinkParser::Definitions extension.'
'No tests defined for Lingua::LinkParser::Dictionary extension.'
'No tests defined for Lingua::LinkParser::Linkage::Sublinkage::Link
extension.'
'No tests defined for Lingua::LinkParser::Linkage::Word extension.'
'No tests defined for Lingua::LinkParser::Sentence extension.'
'No tests defined for Lingua::LinkParser::Simple extension.'

which looks pretty good to me .....

Cheers,
Rob
 
N

natdavis_2000

Rob - Thanks a lot for your help. At first I still got the LNK2001
errors, but then I decided to not include the constituent-example.c
file by renaming to .old, since it was creating all those errors. Then
I was able to successfully nmake everything and even install it so I
could run it from perl. As you pointed out the script has to run from
the same drive as the link4lb is located. Not a huge problem, just
means I need to relocate my scripts or recompile.

Cheers,
Nat
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top