Jon Taylor
Jon Taylor

Reputation: 301

gnatmake -o flag produces incorrect object file name

I am attempting to compile a .adb file with gnatmake, and the -o flag isn't producing the object file name I want:

$ gnatmake --GCC=g++ -D bin/src/ghdl_grt/ -f -u -c src/ghdl_grt/grt-vstrings_io.adb -o bin/src/ghdl_grt/grt-vstrings_io.adb.o

g++ -c -Isrc/ghdl_grt/ -I- -o /home/jon/controlix-code/bin/src/ghdl_grt/grt-vstrings_io.o src/ghdl_grt/grt-vstrings_io.adb

As you can see, it gets the path correct, but the filename should end with .adb.o and it only ends with .o. Any ideas?

Upvotes: 1

Views: 311

Answers (2)

Simon Wright
Simon Wright

Reputation: 25501

For gnatmake, -o 'chooses an alternate executable name'. But even using gcc (or g++) on its own fails, at any rate on macOS, because gnat1: incorrect object file name.

I found that you can compile to assembler and then compile that. Using a local file I happened to have lying about,

$ g++ -D $PWD -c gator2.adb -S -o gator2.adb.s
$ g++ -D $PWD -c gator2.adb.s

Upvotes: 6

egilhh
egilhh

Reputation: 6430

Well, that's a weird naming scheme, but... gnatmake only allows you to specify alternate executable names with -o:

-o name Choose an alternate executable name

You can, however, tell gnatmake to pass on options to the compiler:

-cargs opts opts are passed to the compiler

And similarly, to the binder and linker:

-bargs opts opts are passed to the binder

-largs opts opts are passed to the linker

Thus,

$ gnatmake --GCC=g++ -D bin/src/ghdl_grt/ -f -u -c src/ghdl_grt/grt-vstrings_io.adb -cargs -o bin/src/ghdl_grt/grt-vstrings_io.adb.o

Upvotes: 3

Related Questions