comp.lang.ada
 help / color / mirror / Atom feed
* Calling C from Ada - link problem
@ 2000-03-09  0:00 Ashley King
  2000-03-09  0:00 ` Rush Kester
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Ashley King @ 2000-03-09  0:00 UTC (permalink / raw)


Hello everybody. I hope someone can help me.

I am trying to call a C function from Ada. I am using ObjectAda 7.1.1
and MS Visual C++ 6. Everything compiles. When I try to link on the Ada
side, I get the following error:

whatever.lib: fatal error LNK1106: invalid file or disk full: cannot
seek to 0x...

My disk is definitely not full, and I have looked through past Usenet
messages using Deja and none of the other suggestions or comments that I
saw have made any difference.

The C project was created as a Win32 Dynamic-Link Library, and the build
produces .DLL, .EXP and .LIB files plus some others. I have put the path
that contains these files into the ObjectAda Project Settings under
Search links of type Normal.


The Ada code I am using is, essentially:

WITH INTERFACES.C ;
...
FUNCTION whatever RETURN INTERFACES.C.INT ;
PRAGMA IMPORT ( C, whatever, "whatever" ) ;


The C code I am using is, in full:

whatever.h:

#ifdef __cplusplus
extern "C" {
#endif
__declspec(dllexport) int whatever();
#ifdef __cplusplus
}
#endif

whatever.cpp:

#include "whatever.h"
int whatever()
{
  return 12345;
}


Thanks for any help.

Regards,
Ashley

--
Email won't work. Read here, post here.


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Calling C from Ada - link problem
  2000-03-09  0:00 Calling C from Ada - link problem Ashley King
  2000-03-09  0:00 ` Rush Kester
@ 2000-03-09  0:00 ` Robert Dewar
  2000-03-09  0:00   ` Larry Kilgallen
  2000-03-09  0:00 ` Tucker Taft
  2000-03-09  0:00 ` Mike Dimmick
  3 siblings, 1 reply; 10+ messages in thread
From: Robert Dewar @ 2000-03-09  0:00 UTC (permalink / raw)


In article <8a803u$906$1@nnrp1.deja.com>,
  Ashley King <ashleyking@my-deja.com> wrote:
> Hello everybody. I hope someone can help me.
>
> I am trying to call a C function from Ada. I am using
ObjectAda 7.1.1
> and MS Visual C++ 6. Everything compiles. When I try to link
on the Ada
> side, I get the following error:
>
> whatever.lib: fatal error LNK1106: invalid file or disk full:
cannot
> seek to 0x...


There is nothing wrong with your program (it compiles and
links and runs fine under GNAT on NT). It is impossible to
believe that any compiler would fail to handle this, so the
most likely thing is that your build procedures are incorrect,
so you probably want to check those (and perhaps ask the
vendor for assistance in following these procedures).


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Calling C from Ada - link problem
  2000-03-09  0:00 ` Robert Dewar
@ 2000-03-09  0:00   ` Larry Kilgallen
  0 siblings, 0 replies; 10+ messages in thread
From: Larry Kilgallen @ 2000-03-09  0:00 UTC (permalink / raw)


In article <8a80fo$9a1$1@nnrp1.deja.com>, Robert Dewar <robert_dewar@my-deja.com> writes:
> In article <8a803u$906$1@nnrp1.deja.com>,
>   Ashley King <ashleyking@my-deja.com> wrote:
>> Hello everybody. I hope someone can help me.
>>
>> I am trying to call a C function from Ada. I am using
> ObjectAda 7.1.1
>> and MS Visual C++ 6. Everything compiles. When I try to link
> on the Ada
>> side, I get the following error:
>>
>> whatever.lib: fatal error LNK1106: invalid file or disk full:
> cannot
>> seek to 0x...
> 
> 
> There is nothing wrong with your program (it compiles and
> links and runs fine under GNAT on NT). It is impossible to
> believe that any compiler would fail to handle this, so the
> most likely thing is that your build procedures are incorrect,
> so you probably want to check those (and perhaps ask the
> vendor for assistance in following these procedures).

But it would seem possible that the inability to tell the
difference between an "invalid file" (whatever that is) and
the disk being full might be caused by Microsoft.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Calling C from Ada - link problem
  2000-03-09  0:00 Calling C from Ada - link problem Ashley King
                   ` (2 preceding siblings ...)
  2000-03-09  0:00 ` Tucker Taft
@ 2000-03-09  0:00 ` Mike Dimmick
  2000-03-10  0:00   ` Ashley King
  3 siblings, 1 reply; 10+ messages in thread
From: Mike Dimmick @ 2000-03-09  0:00 UTC (permalink / raw)


"Ashley King" <ashleyking@my-deja.com> wrote in message
news:8a803u$906$1@nnrp1.deja.com...
> Hello everybody. I hope someone can help me.
>
> I am trying to call a C function from Ada. I am using ObjectAda 7.1.1
> and MS Visual C++ 6. Everything compiles. When I try to link on the
Ada
> side, I get the following error:
>
> whatever.lib: fatal error LNK1106: invalid file or disk full: cannot
> seek to 0x...
>
> My disk is definitely not full, and I have looked through past Usenet
> messages using Deja and none of the other suggestions or comments that
I
> saw have made any difference.

Dammit, why do people seem to refuse to read MSDN?  You get a copy with
Visual C++, look in it for the error message.

Following is copyright Microsoft Corporation, apologies to them if they
don't like me posting it:

-----

Linker Tools Error LNK1106
invalid file or disk full: cannot seek to location

The tool could not read or write to location in a memory-mapped file.

Tips

Your disk may be too full to complete the link. Free up some space and
try the link again.


The error may be a result of trying to link over a network. Some
networks do not fully support the memory-mapped files used by the
linker. Try linking on your local disk to see if that fixes the problem.


There may be a bad block on your disk. Although the operating system and
disk hardware should have detected such an error, you may want to run a
disk checking program.

-----

Make sure you're not doing any of the above, then try again.  If it
still fails, let us know.

--
Mike Dimmick






^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Calling C from Ada - link problem
  2000-03-09  0:00 Calling C from Ada - link problem Ashley King
@ 2000-03-09  0:00 ` Rush Kester
  2000-03-10  0:00   ` Ashley King
  2000-03-09  0:00 ` Robert Dewar
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Rush Kester @ 2000-03-09  0:00 UTC (permalink / raw)
  To: Ashley King

You should try saving ObjectAda's LINK.EXE, CVPACK.EXE & CVTRES.EXE and
replacing them with the same programs from Visual C then relinking.

P.S.  Subscribing to and posting this on intel-objectada@aonix.com would
better target people who could answer ObjectAda specific questions and you
will find it very useful.
I believe you can also check the email archives using a web browse, see
http://www.aonix.com/content/support/ada/mail_lists/lists-index.html


Rush Kester
Software Systems Engineer
AdaSoft at Johns Hopkins Applied Physics Lab.
email:  rush.kester@jhuapl.edu
phone: (240) 228-3030 (live M-F 9:30am-4:30pm, voicemail anytime)
fax:      (240) 228-6779
http://hometown.aol.com/rwkester/myhomepage/index.html

-------------------------------------

Ashley King wrote:

> Hello everybody. I hope someone can help me.
>
> I am trying to call a C function from Ada. I am using ObjectAda 7.1.1
> and MS Visual C++ 6. Everything compiles. When I try to link on the Ada
> side, I get the following error:
>
> whatever.lib: fatal error LNK1106: invalid file or disk full: cannot
> seek to 0x...
>
> My disk is definitely not full, and I have looked through past Usenet
> messages using Deja and none of the other suggestions or comments that I
> saw have made any difference.
>
> The C project was created as a Win32 Dynamic-Link Library, and the build
> produces .DLL, .EXP and .LIB files plus some others. I have put the path
> that contains these files into the ObjectAda Project Settings under
> Search links of type Normal.
>
> The Ada code I am using is, essentially:
>
> WITH INTERFACES.C ;
> ...
> FUNCTION whatever RETURN INTERFACES.C.INT ;
> PRAGMA IMPORT ( C, whatever, "whatever" ) ;
>
> The C code I am using is, in full:
>
> whatever.h:
>
> #ifdef __cplusplus
> extern "C" {
> #endif
> __declspec(dllexport) int whatever();
> #ifdef __cplusplus
> }
> #endif
>
> whatever.cpp:
>
> #include "whatever.h"
> int whatever()
> {
>   return 12345;
> }
>
> Thanks for any help.
>
> Regards,
> Ashley
>
> --
> Email won't work. Read here, post here.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Calling C from Ada - link problem
  2000-03-09  0:00 Calling C from Ada - link problem Ashley King
  2000-03-09  0:00 ` Rush Kester
  2000-03-09  0:00 ` Robert Dewar
@ 2000-03-09  0:00 ` Tucker Taft
  2000-03-10  0:00   ` Ashley King
  2000-03-09  0:00 ` Mike Dimmick
  3 siblings, 1 reply; 10+ messages in thread
From: Tucker Taft @ 2000-03-09  0:00 UTC (permalink / raw)


Ashley King wrote:
> 
> Hello everybody. I hope someone can help me.
> 
> I am trying to call a C function from Ada. I am using ObjectAda 7.1.1
> and MS Visual C++ 6. Everything compiles. When I try to link on the Ada
> side, I get the following error:
> 
> whatever.lib: fatal error LNK1106: invalid file or disk full: cannot
> seek to 0x...
> 
> My disk is definitely not full, and I have looked through past Usenet
> messages using Deja and none of the other suggestions or comments that I
> saw have made any difference.
> 
> The C project was created as a Win32 Dynamic-Link Library, and the build
> produces .DLL, .EXP and .LIB files plus some others. I have put the path
> that contains these files into the ObjectAda Project Settings under
> Search links of type Normal.
> 
> The Ada code I am using is, essentially:
> 
> WITH INTERFACES.C ;
> ...
> FUNCTION whatever RETURN INTERFACES.C.INT ;
> PRAGMA IMPORT ( C, whatever, "whatever" ) ;

ObjectAda has a number of conventions other than simply "C" which
allow you to be more specific about the calling convention and/or
specify whether you are exporting/importing as part of a DLL.
You might want to consult that part of the ObjectAda documentation 
that explains the options available for the "convention" argument to 
pragma Import.

> The C code I am using is, in full:
> 
> whatever.h:
> 
> #ifdef __cplusplus
> extern "C" {
> #endif
> __declspec(dllexport) int whatever();
> #ifdef __cplusplus
> }
> #endif
> 
> whatever.cpp:
> 
> #include "whatever.h"
> int whatever()
> {
>   return 12345;
> }
> 
> Thanks for any help.
> 
> Regards,
> Ashley

-- 
-Tucker Taft   stt@averstar.com   http://www.averstar.com/~stt/
Technical Director, Distributed IT Solutions  (www.averstar.com/tools)
AverStar (formerly Intermetrics, Inc.)   Burlington, MA  USA




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Calling C from Ada - link problem
  2000-03-09  0:00 ` Rush Kester
@ 2000-03-10  0:00   ` Ashley King
  0 siblings, 0 replies; 10+ messages in thread
From: Ashley King @ 2000-03-10  0:00 UTC (permalink / raw)


In article <38C7E832.F5A265BB@jhuapl.edu>,
  Rush Kester <Rush.Kester@jhuapl.edu> wrote:
> You should try saving ObjectAda's LINK.EXE, CVPACK.EXE & CVTRES.EXE
and
> replacing them with the same programs from Visual C then relinking.
Thanks for the suggestion. I tried that and although ObjectAda doesn't
give the link1136 error any more, it just says that the build command
failed and no executable is created. Perhaps some more files need to
copied?


>
> P.S.  Subscribing to and posting this on intel-objectada@aonix.com
would
> better target people who could answer ObjectAda specific questions
and you
> will find it very useful.
> I believe you can also check the email archives using a web browse,
see
> http://www.aonix.com/content/support/ada/mail_lists/lists-index.html
I will certainly investigate this, it sounds interesting.

Regards,
Ashley

--
Email won't work. Read here, post here.


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Calling C from Ada - link problem
  2000-03-09  0:00 ` Tucker Taft
@ 2000-03-10  0:00   ` Ashley King
  0 siblings, 0 replies; 10+ messages in thread
From: Ashley King @ 2000-03-10  0:00 UTC (permalink / raw)


In article <38C7E615.A011C7FE@averstar.com>,
  Tucker Taft <stt@averstar.com> wrote:
> ObjectAda has a number of conventions other than simply "C" which
> allow you to be more specific about the calling convention and/or
> specify whether you are exporting/importing as part of a DLL.
> You might want to consult that part of the ObjectAda documentation
> that explains the options available for the "convention" argument to
> pragma Import.
Thanks, I did. I tried putting DLL in place of C in the import command,
and that made no difference.

Another attempt: I created a new c++ project where I said I wanted to
have a static library rather than a DLL, and removed the dllexport bit
from the C code. It linked in the static library successfully, but
complained that it couldn't find some other library. After putting the
path to that library in the project settings, I now get the same
lnk1136 error but this time on a Microsoft Visual Studio vc98 library
called mapi.lib. I again tried copying the files that Rush Kester had
suggested, and got the same result as before.

I even tried making the function a procedure and the return type of the
C code void. No change.

Perhaps the versions of ObjectAda and Visual C++ that I am using are
incompatible in some way. Robert Dewar said that he had built
successfully on his setup, so it's possible that specifying C rather
than DLL makes no real difference in this example and I have just
missed something from the Ada project settings.

Regards,
Ashley

--
Email won't work. Read here, post here.


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Calling C from Ada - link problem
  2000-03-09  0:00 ` Mike Dimmick
@ 2000-03-10  0:00   ` Ashley King
  2000-03-11  0:00     ` David Botton
  0 siblings, 1 reply; 10+ messages in thread
From: Ashley King @ 2000-03-10  0:00 UTC (permalink / raw)


In article <952640221.722.0.nnrp-03.d4e5bde1@news.demon.co.uk>,
  "Mike Dimmick" <mike@dimmick.demon.co.uk> wrote:
> Dammit, why do people seem to refuse to read MSDN?  You get a copy
with
> Visual C++, look in it for the error message.
I based my C code on an example in the MSDN library online help. In any
case, it was the Ada compi9ler which gave the error, how was I supposed
to know that the error messages are meant to be the same?


> Your disk may be too full to complete the link. Free up some space and
> try the link again.
Loads of space and memory.


>
> The error may be a result of trying to link over a network. Some
> networks do not fully support the memory-mapped files used by the
> linker. Try linking on your local disk to see if that fixes the
problem.
Two local disks. Does that count? Hold on, I'll try recreating
everything on my c drive... Nope, sorry.


>
> There may be a bad block on your disk. Although the operating system
and
> disk hardware should have detected such an error, you may want to run
a
> disk checking program.
Given that I have tried several different projects on two different
drives, then it is unlikely that this is the case. Of course, the bad
block may be in an ObjectAda executable, but I have been successfully
building other programs which include, for example, an import of a C
system call procedure. But I did run scandisk, and no bad blocks wwere
found.


>
> -----
>
> Make sure you're not doing any of the above, then try again.  If it
> still fails, let us know.
But thanks for the suggestions.

Regards,
Ashley

--
Email won't work. Read here, post here.


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Calling C from Ada - link problem
  2000-03-10  0:00   ` Ashley King
@ 2000-03-11  0:00     ` David Botton
  0 siblings, 0 replies; 10+ messages in thread
From: David Botton @ 2000-03-11  0:00 UTC (permalink / raw)


Are you using the link.exe that came with VC++ 6.0

There have been changes made in the lib file structure of VC 6.0 that will
frequently not work with older linkers.

David Botton










^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2000-03-11  0:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-09  0:00 Calling C from Ada - link problem Ashley King
2000-03-09  0:00 ` Rush Kester
2000-03-10  0:00   ` Ashley King
2000-03-09  0:00 ` Robert Dewar
2000-03-09  0:00   ` Larry Kilgallen
2000-03-09  0:00 ` Tucker Taft
2000-03-10  0:00   ` Ashley King
2000-03-09  0:00 ` Mike Dimmick
2000-03-10  0:00   ` Ashley King
2000-03-11  0:00     ` David Botton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox