D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 23290 - Interfacing to C++ mention C++ symbols may have been stripped
Summary: Interfacing to C++ mention C++ symbols may have been stripped
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dlang.org (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-09 14:06 UTC by Richard (Rikki) Andrew Cattermole
Modified: 2024-12-15 15:27 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Richard (Rikki) Andrew Cattermole 2022-08-09 14:06:45 UTC
When compiling against C++ object files, it is possible that the compiler has stripped symbols out of the object file.

For instance, if you have the following code in a cpp file:


```c++
#include <iostream>
struct Foo
{
    void print()
    {
        std::cout << "foo: " << a << ": hello from c++\n";
    }

    int a;
};
```

And try to link against it when compiling with ``clang -c`` it will result in the linker error: ``undefined reference to 'Foo::print()'``.

This is worth mentioning in the docs for Interfacing to C++ page as it could be a gotcha that can lead to people spinning their wheels (it was encountered by someone on Discord).
Comment 1 dlangBugzillaToGithub 2024-12-15 15:27:31 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dlang.org/issues/4126

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB