Making a D library for a C executable
Steven Schveighoffer
schveiguy at gmail.com
Thu Apr 27 21:34:17 UTC 2023
On 4/27/23 5:29 PM, Jan Allersma wrote:
> On Thursday, 27 April 2023 at 21:05:00 UTC, Mike Parker wrote:
>> That's a compilation error, not a linker problem. You need to tell the
>> compiler about the function with a prototype:
>
> Declaring the function does fix the compiler problem. However, I do get
> a linker error once I compile that:
>
> ```bash
> $ g++ ../build/libshared-api.so main.cpp
> /usr/bin/ld: /tmp/ccNMKxEE.o: in function `main':
> main.cpp:(.text+0x2a): undefined reference to `foo()'
> collect2: error: ld returned 1 exit status
> ```
>
>
You may have to link the library second. Sometimes linkers are
particular about object order.
Also, please include your commands for building the D library so
reproduction is possible.
-Steve
More information about the Digitalmars-d-learn
mailing list