Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interfacing to C++ mention C++ symbols may have been stripped #4126

Open
dlangBugzillaToGithub opened this issue Aug 9, 2022 · 0 comments
Open

Comments

@dlangBugzillaToGithub
Copy link

Richard (Rikki) Andrew Cattermole reported this on 2022-08-09T14:06:45Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=23290

Description

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++
";
    }

    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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant