如何在 Ubuntu 上使用 DSFML2 和 D2 解决链接器错误?

发布于 2024-11-02 01:51:12 字数 4612 浏览 5 评论 0原文

我正在运行带有 DMDv2.052 的 64 位 Ubuntu Linux,试图让应用程序与 DSFML2 一起工作,但我不断遇到链接器错误。

我使用共享库+发布版本构建了 SFML 和 CSFML 库,并安装了它们,然后构建了 DSFML 绑定,如下所示:


me@lappy486:~/devl/sfml2/bindings/d/import/dsfml/system$ dmd -m64 -lib *.d -of../../../lib/libdsfml-system.a 
me@lappy486:~/devl/sfml2/bindings/d/import/dsfml/system$ cd ../window 
me@lappy486:~/devl/sfml2/bindings/d/import/dsfml/window$ dmd -m64 -lib *.d -of../../../lib/libdsfml-window.a 
me@lappy486:~/devl/sfml2/bindings/d/import/dsfml/window$ cd ../graphics 
me@lappy486:~/devl/sfml2/bindings/d/import/dsfml/graphics$ dmd -m64 -lib *.d -of../../../lib/libdsfml-graphics.a 
me@lappy486:~/devl/sfml2/bindings/d/import/dsfml/graphics$ cd ../audio 
me@lappy486:~/devl/sfml2/bindings/d/import/dsfml/audio$ dmd -m64 -lib *.d -of../../../lib/libdsfml-audio.a 

当尝试构建项目以使用它们时,我收到以下错误:


me@lappy486:~/devl/d/Gossamer$ dmd -m64 *.d game/*.d graphics/*.d -L"-L/home/me/devl/sfml2/bindings/d/lib -ldsfml-system -ldsfml-window -ldsfml-graphics -ldsfml-audio" 
collision.o:(.data+0xab0): undefined reference to `_D5dsfml8graphics5color12__ModuleInfoZ' 
collision.o:(.data+0xb18): undefined reference to `_D5dsfml6system9exception16LoadingException7__ClassZ' 
collision.o:(.data+0xbe0): undefined reference to `_D5dsfml8graphics3all12__ModuleInfoZ' 
collision.o:(.data+0xd38): undefined reference to `_D5dsfml8graphics3all12__ModuleInfoZ' 
collision.o:(.data+0xd40): undefined reference to `_D5dsfml6window3all12__ModuleInfoZ' 
collision.o:(.data+0xdd8): undefined reference to `_D5dsfml6system9exception16LoadingException7__ClassZ' 
collision.o:(.data+0xf40): undefined reference to `_D5dsfml8graphics3all12__ModuleInfoZ' 
collision.o: In function `_D8graphics5image5Image6__ctorMFAyaZC8graphics5image5Image': 
graphics/text.d:(.text._D8graphics5image5Image6__ctorMFAyaZC8graphics5image5Image+0x17): undefined reference to `_D5dsfml8graphics6sprite6Sprite7__ClassZ' 
graphics/text.d:(.text._D8graphics5image5Image6__ctorMFAyaZC8graphics5image5Image+0x2a): undefined reference to `_D5dsfml8graphics5image5Image7__ClassZ' 
graphics/text.d:(.text._D8graphics5image5Image6__ctorMFAyaZC8graphics5image5Image+0x67): undefined reference to `_D5dsfml8graphics5image5Image6__ctorMFAyaZC5dsfml8graphics5image5Image' 
graphics/text.d:(.text._D8graphics5image5Image6__ctorMFAyaZC8graphics5image5Image+0xa3): undefined reference to `_D5dsfml8graphics5color4RGBA5WHITEyS5dsfml8graphics5color4RGBA' 
graphics/text.d:(.text._D8graphics5image5Image6__ctorMFAyaZC8graphics5image5Image+0xac): undefined reference to `_D5dsfml8graphics6sprite6Sprite6__ctorMFC5dsfml8graphics5image5ImagefffffS5dsfml8graphics5color4RGBAZC5dsfml8graphics6sprite6Sprite' 
collision.o: In function `_D8graphics6screen6Screen5clearMFZv': 
graphics/text.d:(.text._D8graphics6screen6Screen5clearMFZv+0xa): undefined reference to `_D5dsfml8graphics5color4RGBA5BLACKyS5dsfml8graphics5color4RGBA' 
collision.o: In function `_D8graphics6screen6Screen6__ctorMFAyakkZC8graphics6screen6Screen': 
graphics/text.d:(.text._D8graphics6screen6Screen6__ctorMFAyakkZC8graphics6screen6Screen+0x24): undefined reference to `_D5dsfml8graphics12renderwindow12RenderWindow7__ClassZ' 
graphics/text.d:(.text._D8graphics6screen6Screen6__ctorMFAyakkZC8graphics6screen6Screen+0x73): undefined reference to `_D5dsfml8graphics12renderwindow12RenderWindow6__ctorMFS5dsfml6window9videomode9VideoModeAyaE5dsfml6window6window5StyleS5dsfml6window6window15ContextSettingsZC5dsfml8graphics12renderwindow12RenderWindow'
collision.o: In function `_D8graphics4text4Font6__ctorMFAyaZC8graphics4text4Font': 
graphics/text.d:(.text._D8graphics4text4Font6__ctorMFAyaZC8graphics4text4Font+0x17): undefined reference to `_D5dsfml8graphics4font4Font7__ClassZ' 
graphics/text.d:(.text._D8graphics4text4Font6__ctorMFAyaZC8graphics4text4Font+0x54): undefined reference to `_D5dsfml8graphics4font4Font6__ctorMFAyaZC5dsfml8graphics4font4Font' 
collision.o: In function `_D8graphics4text4Text6__ctorMFC8graphics4text4FontAyakS5dsfml8graphics5color4RGBAZC8graphics4text4Text': 
graphics/text.d:(.text._D8graphics4text4Text6__ctorMFC8graphics4text4FontAyakS5dsfml8graphics5color4RGBAZC8graphics4text4Text+0x19): undefined reference to `_D5dsfml8graphics4text4Text7__ClassZ' 
graphics/text.d:(.text._D8graphics4text4Text6__ctorMFC8graphics4text4FontAyakS5dsfml8graphics5color4RGBAZC8graphics4text4Text+0x3b): undefined reference to `_D5dsfml8graphics4text4Text6__ctorMFAyaC5dsfml8graphics4font4FontkZC5dsfml8graphics4text4Text' 
collect2: ld returned 1 exit status 
--- errorlevel 1 

有人可以帮忙吗?我还没能让它发挥作用。

I'm running 64-bit Ubuntu Linux with DMDv2.052, trying to get application working with DSFML2, but I keep running into linker errors.

I built the SFML and CSFML libraries using shared libs + release builds, and installed them, then built the DSFML bindings like this:


me@lappy486:~/devl/sfml2/bindings/d/import/dsfml/system$ dmd -m64 -lib *.d -of../../../lib/libdsfml-system.a 
me@lappy486:~/devl/sfml2/bindings/d/import/dsfml/system$ cd ../window 
me@lappy486:~/devl/sfml2/bindings/d/import/dsfml/window$ dmd -m64 -lib *.d -of../../../lib/libdsfml-window.a 
me@lappy486:~/devl/sfml2/bindings/d/import/dsfml/window$ cd ../graphics 
me@lappy486:~/devl/sfml2/bindings/d/import/dsfml/graphics$ dmd -m64 -lib *.d -of../../../lib/libdsfml-graphics.a 
me@lappy486:~/devl/sfml2/bindings/d/import/dsfml/graphics$ cd ../audio 
me@lappy486:~/devl/sfml2/bindings/d/import/dsfml/audio$ dmd -m64 -lib *.d -of../../../lib/libdsfml-audio.a 

When trying to build a project to use them, I get the following errors:


me@lappy486:~/devl/d/Gossamer$ dmd -m64 *.d game/*.d graphics/*.d -L"-L/home/me/devl/sfml2/bindings/d/lib -ldsfml-system -ldsfml-window -ldsfml-graphics -ldsfml-audio" 
collision.o:(.data+0xab0): undefined reference to `_D5dsfml8graphics5color12__ModuleInfoZ' 
collision.o:(.data+0xb18): undefined reference to `_D5dsfml6system9exception16LoadingException7__ClassZ' 
collision.o:(.data+0xbe0): undefined reference to `_D5dsfml8graphics3all12__ModuleInfoZ' 
collision.o:(.data+0xd38): undefined reference to `_D5dsfml8graphics3all12__ModuleInfoZ' 
collision.o:(.data+0xd40): undefined reference to `_D5dsfml6window3all12__ModuleInfoZ' 
collision.o:(.data+0xdd8): undefined reference to `_D5dsfml6system9exception16LoadingException7__ClassZ' 
collision.o:(.data+0xf40): undefined reference to `_D5dsfml8graphics3all12__ModuleInfoZ' 
collision.o: In function `_D8graphics5image5Image6__ctorMFAyaZC8graphics5image5Image': 
graphics/text.d:(.text._D8graphics5image5Image6__ctorMFAyaZC8graphics5image5Image+0x17): undefined reference to `_D5dsfml8graphics6sprite6Sprite7__ClassZ' 
graphics/text.d:(.text._D8graphics5image5Image6__ctorMFAyaZC8graphics5image5Image+0x2a): undefined reference to `_D5dsfml8graphics5image5Image7__ClassZ' 
graphics/text.d:(.text._D8graphics5image5Image6__ctorMFAyaZC8graphics5image5Image+0x67): undefined reference to `_D5dsfml8graphics5image5Image6__ctorMFAyaZC5dsfml8graphics5image5Image' 
graphics/text.d:(.text._D8graphics5image5Image6__ctorMFAyaZC8graphics5image5Image+0xa3): undefined reference to `_D5dsfml8graphics5color4RGBA5WHITEyS5dsfml8graphics5color4RGBA' 
graphics/text.d:(.text._D8graphics5image5Image6__ctorMFAyaZC8graphics5image5Image+0xac): undefined reference to `_D5dsfml8graphics6sprite6Sprite6__ctorMFC5dsfml8graphics5image5ImagefffffS5dsfml8graphics5color4RGBAZC5dsfml8graphics6sprite6Sprite' 
collision.o: In function `_D8graphics6screen6Screen5clearMFZv': 
graphics/text.d:(.text._D8graphics6screen6Screen5clearMFZv+0xa): undefined reference to `_D5dsfml8graphics5color4RGBA5BLACKyS5dsfml8graphics5color4RGBA' 
collision.o: In function `_D8graphics6screen6Screen6__ctorMFAyakkZC8graphics6screen6Screen': 
graphics/text.d:(.text._D8graphics6screen6Screen6__ctorMFAyakkZC8graphics6screen6Screen+0x24): undefined reference to `_D5dsfml8graphics12renderwindow12RenderWindow7__ClassZ' 
graphics/text.d:(.text._D8graphics6screen6Screen6__ctorMFAyakkZC8graphics6screen6Screen+0x73): undefined reference to `_D5dsfml8graphics12renderwindow12RenderWindow6__ctorMFS5dsfml6window9videomode9VideoModeAyaE5dsfml6window6window5StyleS5dsfml6window6window15ContextSettingsZC5dsfml8graphics12renderwindow12RenderWindow'
collision.o: In function `_D8graphics4text4Font6__ctorMFAyaZC8graphics4text4Font': 
graphics/text.d:(.text._D8graphics4text4Font6__ctorMFAyaZC8graphics4text4Font+0x17): undefined reference to `_D5dsfml8graphics4font4Font7__ClassZ' 
graphics/text.d:(.text._D8graphics4text4Font6__ctorMFAyaZC8graphics4text4Font+0x54): undefined reference to `_D5dsfml8graphics4font4Font6__ctorMFAyaZC5dsfml8graphics4font4Font' 
collision.o: In function `_D8graphics4text4Text6__ctorMFC8graphics4text4FontAyakS5dsfml8graphics5color4RGBAZC8graphics4text4Text': 
graphics/text.d:(.text._D8graphics4text4Text6__ctorMFC8graphics4text4FontAyakS5dsfml8graphics5color4RGBAZC8graphics4text4Text+0x19): undefined reference to `_D5dsfml8graphics4text4Text7__ClassZ' 
graphics/text.d:(.text._D8graphics4text4Text6__ctorMFC8graphics4text4FontAyakS5dsfml8graphics5color4RGBAZC8graphics4text4Text+0x3b): undefined reference to `_D5dsfml8graphics4text4Text6__ctorMFAyaC5dsfml8graphics4font4FontkZC5dsfml8graphics4text4Text' 
collect2: ld returned 1 exit status 
--- errorlevel 1 

Can somebody help with this? I haven't been able to get it to work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏日浅笑〃 2024-11-09 01:51:12

我不知道出了什么问题,但我首先要消除所有可能的复杂性:

  1. 在 D 中使用 .so 是...“有问题”,如果可能,请使用静态链接。
  2. 尝试以 32 位模式构建它(我上次听说 64 位仍然是 alpha)
  3. 尝试使用相同的 lib 设置构建一个 hello world 应用程序。
  4. 不要从 DMD 进行链接,而是通过 ld 显式进行链接。 (编译已经在详细模式下运行的内容,以获得您需要的命令行的起点。)

I don't know what's wrong, but I'd start by removing any complexities you can:

  1. Using .so in D is... "problematic", if possible, use static linkage.
  2. Try to build it in 32bit mode (64 bit is still alpha last I heard)
  3. Try and build a hello world app using the same lib setup.
  4. Don't do the link from DMD, do it explicitly via ld. (Compile something that already works in verbose mode to get a starting point for the command line you will need.)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文