* undefined reference to `adainit'
@ 2008-02-16 22:39 news.broadpark.no
2008-02-17 17:51 ` Simon Wright
2008-02-18 7:04 ` Martin Krischik
0 siblings, 2 replies; 6+ messages in thread
From: news.broadpark.no @ 2008-02-16 22:39 UTC (permalink / raw)
I must admit that I'm not very experienced with Ada. I'm working with an
interface since I need to be able to call a library written in Ada from
.NET. I made a small project and compiled it as follows:
gnatmake -c api
gnatbind -n api
gnatdll -d api.dll api.ali
Now, everything works fine. I'm able to call the library from a C# .NET
program. However, if I create a GPS project file an try to compile, I get
the following error:
i:\temp\adatest\adadll\obj\api.o:api.adb:(.text+0x38): undefined reference
to `adainit'
i:\temp\adatest\adadll\obj\api.o:api.adb:(.text+0x57): undefined reference
to `adafinal'
gnatmake: gcc execution error
Does anyone know what to do? The GPS project file look like this:
project Api is
for Library_Name use "api";
for Library_Dir use "dll";
for Library_Ali_Dir use "ali";
for Library_Kind use "dynamic";
for Languages use ("Ada");
for Object_Dir use "obj";
for Library_Interface use ("API");
for Library_Auto_Init use "False";
for Library_Src_Dir use "dll";
package Compiler is
for Default_Switches ("Ada") use ("-gnat95", "-gnatv", "-lgnat");
end Compiler;
package Linker is
for Linker_Options use ("-lgnat");
end Linker;
end Api;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: undefined reference to `adainit'
2008-02-16 22:39 undefined reference to `adainit' news.broadpark.no
@ 2008-02-17 17:51 ` Simon Wright
2008-02-17 19:07 ` news.broadpark.no
2008-02-18 7:04 ` Martin Krischik
1 sibling, 1 reply; 6+ messages in thread
From: Simon Wright @ 2008-02-17 17:51 UTC (permalink / raw)
Are you trying to make a GNAT project file to (re)build the library,
or to use the already-built library? The one you post looks like the
former.
I suspect your problem is the 'for Library_Auto_Init use
"False";'. Why is this here?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: undefined reference to `adainit'
2008-02-17 17:51 ` Simon Wright
@ 2008-02-17 19:07 ` news.broadpark.no
2008-02-17 22:12 ` Simon Wright
0 siblings, 1 reply; 6+ messages in thread
From: news.broadpark.no @ 2008-02-17 19:07 UTC (permalink / raw)
"Simon Wright" <simon.j.wright@mac.com> wrote in message
news:m24pc75v4t.fsf@mac.com...
> Are you trying to make a GNAT project file to (re)build the library,
> or to use the already-built library? The one you post looks like the
> former.
>
> I suspect your problem is the 'for Library_Auto_Init use
> "False";'. Why is this here?
I have a library with full source code that I will recompile. However, In
the example I provided I have written a small DLL that I'm compiling.
Compiling it thsi way works:
gnatmake -c api
gnatbind -n api
gnatdll -d api.dll api.ali
However, using GPS with the settings I provided does not work. Making the
project gives the following output:
gnatmake -PI:\Temp\ADATest\AdaDLL\api.gpr -d
gnatbind -n -o b~api.adb -Lapi -a api.ali
gcc -c b~api.adb
building dynamic library for project api
C:\GNAT\2007\bin\gcc.exe -shared -o
i:\temp\adatest\adadll\dll\api.dll -LC:/GNAT/2007/lib/gcc/pentium-mingw32msv/4.1.3/adalib/
i:\temp\adatest\adadll\obj\api.o
... -L.\ -Li:\temp\adatest\adadll\obj\ -LC:/GNAT/2007/lib/gcc/pentium-mingw32msv/4.1.3/adalib/
-Wl,--stack=0x2000000 -LC:/GNAT/2007/lib/gcc/pentium-mingw32msv/4.1.3/adalib/
-lgnat-2007
i:\temp\adatest\adadll\obj\api.o:api.adb:(.text+0x38): undefined reference
to `adainit'
i:\temp\adatest\adadll\obj\api.o:api.adb:(.text+0x57): undefined reference
to `adafinal'
collect2: ld returned 1 exit status
gnatmake: gcc execution error
process exited with status 4
I have problems seeing whats wrong. I have treid different settings for
Library_Auto_Init, but with the same result.
Eirik
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: undefined reference to `adainit'
2008-02-17 19:07 ` news.broadpark.no
@ 2008-02-17 22:12 ` Simon Wright
0 siblings, 0 replies; 6+ messages in thread
From: Simon Wright @ 2008-02-17 22:12 UTC (permalink / raw)
"news.broadpark.no" <etjensen@broadpark.no> writes:
> "Simon Wright" <simon.j.wright@mac.com> wrote in message
> news:m24pc75v4t.fsf@mac.com...
>> Are you trying to make a GNAT project file to (re)build the library,
>> or to use the already-built library? The one you post looks like the
>> former.
>>
>> I suspect your problem is the 'for Library_Auto_Init use
>> "False";'. Why is this here?
>
> I have a library with full source code that I will recompile. However,
> In the example I provided I have written a small DLL that I'm
> compiling. Compiling it thsi way works:
>
> gnatmake -c api
> gnatbind -n api
> gnatdll -d api.dll api.ali
>
> However, using GPS with the settings I provided does not work. Making
> the project gives the following output:
>
> gnatmake -PI:\Temp\ADATest\AdaDLL\api.gpr -d
> gnatbind -n -o b~api.adb -Lapi -a api.ali
> gcc -c b~api.adb
>
> building dynamic library for project api
> C:\GNAT\2007\bin\gcc.exe -shared -o
> i:\temp\adatest\adadll\dll\api.dll
> -LC:/GNAT/2007/lib/gcc/pentium-mingw32msv/4.1.3/adalib/
> i:\temp\adatest\adadll\obj\api.o ... -L.\
> -Li:\temp\adatest\adadll\obj\
> -LC:/GNAT/2007/lib/gcc/pentium-mingw32msv/4.1.3/adalib/
> -Wl,--stack=0x2000000
> -LC:/GNAT/2007/lib/gcc/pentium-mingw32msv/4.1.3/adalib/ -lgnat-2007
> i:\temp\adatest\adadll\obj\api.o:api.adb:(.text+0x38): undefined
> reference to `adainit'
> i:\temp\adatest\adadll\obj\api.o:api.adb:(.text+0x57): undefined
> reference to `adafinal'
> collect2: ld returned 1 exit status
> gnatmake: gcc execution error
I'm having trouble with Windows, but the Mac OS X .dylib I'm working
on does this:
gcc -c b~tash.adb -fPIC -O2 -fPIC -g -g
building dynamic library for project build_tash_library
/opt/gnat-gpl-2007-static/bin/gcc -dynamiclib -o /Users/simon/sf/tcladashell/lib/libtash.dylib -L/opt/gnat-gpl-2007-static/lib/gcc/powerpc-apple-darwin8.11.0/4.1.3/adalib/ -L./ -L/Users/simon/sf/tcladashell/src/.build_lib/ -L/opt/gnat-gpl-2007-static/lib/gcc/powerpc-apple-darwin8.11.0/4.1.3/adalib/ -L/usr/lib -ltk8.4 -ltcl8.4 -single_module -L/opt/gnat-gpl-2007-static/lib/gcc/powerpc-apple-darwin8.11.0/4.1.3/adalib/ -lgnarl-2007 -lgnat-2007 -Wl,-flat_namespace -shared-libgcc /Users/simon/sf/tcladashell/src/.build_lib/b~tash.o ...
which is quite similar except that (a) it works, (b) you have api.o
called up earlier.
HOWEVER -- it looks as though your api.adb itself explicitly calls
adainit, adafinal -- is that so? It shouldn't. My b~tash.adb defines
tashinit and tashfinal, and I believe these are what get called when
the dll is loaded/unloaded. adainit/adafinal are what GNAT generates
(by default?) when building an executable. I'd expect your b~api.adb
to define apiinit, apifinal.
I don't know why gnatdll doesn't give the same problem (it's not part
of the Mac build).
> I have problems seeing whats wrong. I have treid different settings
> for Library_Auto_Init, but with the same result.
I guess that's not the problem (but I think it should be "True", all
the same).
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: undefined reference to `adainit'
2008-02-16 22:39 undefined reference to `adainit' news.broadpark.no
2008-02-17 17:51 ` Simon Wright
@ 2008-02-18 7:04 ` Martin Krischik
2008-02-18 20:44 ` news.broadpark.no
1 sibling, 1 reply; 6+ messages in thread
From: Martin Krischik @ 2008-02-18 7:04 UTC (permalink / raw)
news.broadpark.no schrieb:
> .NET. I made a small project and compiled it as follows:
>
> gnatmake -c api
> gnatbind -n api
> gnatdll -d api.dll api.ali
>
> Does anyone know what to do? The GPS project file look like this:
And where is the "-P" option which tells gnat make to actually use the
project file?
You should use:
gnat make -P api
and nothing else. Using gnatbind and gnatdll is more or less depreciated
- an up to date "gnat make" can do it all for you.
Have a look at the mkutils project which solves a similar problem:
http://code.google.com/p/mkutils
and here especially the build script (gnat make and nothing else):
http://code.google.com/p/mkutils/source/browse/trunk/All.btm
and the main project file:
http://code.google.com/p/mkutils/source/browse/trunk/MK_Utils.gpr
Regards
Martin
--
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: undefined reference to `adainit'
2008-02-18 7:04 ` Martin Krischik
@ 2008-02-18 20:44 ` news.broadpark.no
0 siblings, 0 replies; 6+ messages in thread
From: news.broadpark.no @ 2008-02-18 20:44 UTC (permalink / raw)
"Martin Krischik" <krischik@users.sourceforge.net> wrote in message
news:47b92e0f$1@news.post.ch...
> news.broadpark.no schrieb:
>
>> .NET. I made a small project and compiled it as follows:
>>
>> gnatmake -c api
>> gnatbind -n api
>> gnatdll -d api.dll api.ali
>>
>> Does anyone know what to do? The GPS project file look like this:
>
> And where is the "-P" option which tells gnat make to actually use the
> project file?
The problem is that the GPS project file dows not work. Thus, no -P.
I found the solution to the problem. I added the following to the project
file:
for Library_Name use "Te";
for Library_Interface use ("api");
Now, I'm getting two default functions:
Teinit();
Tefinal();
I guess that's the same as adainit and adafinal. However, it seems that the
Ada core is still somewhat uninitialised. If I do the following call:
Ada.Text_IO.Put_Line("Error - Incorrect number of arguments");
Some kind of exception is raised and the program stops. If I do as follows:
Create(OutputFile, Name =>"C:\temp\dump.txt");
Ada.Text_IO.Set_Output(OutputFile);
Ada.Text_IO.Put_Line("Error - Incorrect number of arguments");
everything works fine.
Any idea?
Eirik
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-02-18 20:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-16 22:39 undefined reference to `adainit' news.broadpark.no
2008-02-17 17:51 ` Simon Wright
2008-02-17 19:07 ` news.broadpark.no
2008-02-17 22:12 ` Simon Wright
2008-02-18 7:04 ` Martin Krischik
2008-02-18 20:44 ` news.broadpark.no
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox