共享库无法编译,*.a 文件丢失
Shared Library won't compile, *.a file missing
我正在尝试在 Linux 中创建一个共享库,它是一个 *.so。我的 DMD 版本是 2,最新的。我只是想用 Mono-D(MonoDevelop 的插件)创建的代码编译一个简单的空共享库。当我尝试编译它时,它告诉我检查构建日志,这是构建日志中的内容:
</p>
<pre><code>Building Solution: QScr (Debug)
Building: QScr (Debug)
Performing main compilation...
Current dictionary: /home/nafees/Desktop/Projects/QScr/QScr
dmd -debug -gc "myclass.d" "dllmain.d" "-I/usr/include/dmd" "-L/IMPLIB:/home/nafees/Desktop/Projects/QScr/QScr/bin/Debug/libQScr.a" "-odobj/Debug" "-of/home/nafees/Desktop/Projects/QScr/QScr/bin/Debug/libQScr.so" -w -vcolumns
/usr/bin/ld: cannot find /IMPLIB:/home/nafees/Desktop/Projects/QScr/QScr/bin/Debug/libQScr.a: No such file or directory
collect2: error: ld returned 1 exit status
--- errorlevel 1
Exit code 1
Build complete -- 1 error, 0 warnings
---------------------- Done ----------------------
Build: 1 error, 0 warnings
这是 dllmain 包含的内容:
module dllmain;
在myclass.d中:
module myclass;
class MyClass
{
//TODO: Enter class code here
}
export:
extern(D):
MyClass createMyClass()
{
return new MyClass();
}
我不知道那个文件是什么,我对 D 还是很陌生,Linux。
我如何让它编译?谁能给我解释一下什么是 .a 文件?
编辑:不,它不是重复的,我正在尝试编译,而那个问题是关于加载库的。
EDIT2:我检查了目录,.a 文件不存在。
/usr/bin/ld: cannot find /IMPLIB:/home/nafees/Desktop/Projects/QScr/QScr/bin/Debug/libQScr.a: No such file or directory
/IMPLIB
是一个 Windows 链接器开关。您的 IDE 配置错误(或有问题)。
尝试更改 IDE 中的项目设置或针对 IDE 提交错误。
几件事。
- 自由函数不需要 extern(D),因为它是默认值
- 您根本不需要 createMyClass 函数,new 就可以了
- -shared 必须传递给 dmd 才能创建共享库
如果您不知道,在编译主机二进制文件时,您会将共享库中的文件作为导入文件传递。
我正在尝试在 Linux 中创建一个共享库,它是一个 *.so。我的 DMD 版本是 2,最新的。我只是想用 Mono-D(MonoDevelop 的插件)创建的代码编译一个简单的空共享库。当我尝试编译它时,它告诉我检查构建日志,这是构建日志中的内容:
</p>
<pre><code>Building Solution: QScr (Debug)
Building: QScr (Debug)
Performing main compilation...
Current dictionary: /home/nafees/Desktop/Projects/QScr/QScr
dmd -debug -gc "myclass.d" "dllmain.d" "-I/usr/include/dmd" "-L/IMPLIB:/home/nafees/Desktop/Projects/QScr/QScr/bin/Debug/libQScr.a" "-odobj/Debug" "-of/home/nafees/Desktop/Projects/QScr/QScr/bin/Debug/libQScr.so" -w -vcolumns
/usr/bin/ld: cannot find /IMPLIB:/home/nafees/Desktop/Projects/QScr/QScr/bin/Debug/libQScr.a: No such file or directory
collect2: error: ld returned 1 exit status
--- errorlevel 1
Exit code 1
Build complete -- 1 error, 0 warnings
---------------------- Done ----------------------
Build: 1 error, 0 warnings
这是 dllmain 包含的内容:
module dllmain;
在myclass.d中:
module myclass;
class MyClass
{
//TODO: Enter class code here
}
export:
extern(D):
MyClass createMyClass()
{
return new MyClass();
}
我不知道那个文件是什么,我对 D 还是很陌生,Linux。 我如何让它编译?谁能给我解释一下什么是 .a 文件?
编辑:不,它不是重复的,我正在尝试编译,而那个问题是关于加载库的。
EDIT2:我检查了目录,.a 文件不存在。
/usr/bin/ld: cannot find /IMPLIB:/home/nafees/Desktop/Projects/QScr/QScr/bin/Debug/libQScr.a: No such file or directory
/IMPLIB
是一个 Windows 链接器开关。您的 IDE 配置错误(或有问题)。
尝试更改 IDE 中的项目设置或针对 IDE 提交错误。
几件事。
- 自由函数不需要 extern(D),因为它是默认值
- 您根本不需要 createMyClass 函数,new 就可以了
- -shared 必须传递给 dmd 才能创建共享库
如果您不知道,在编译主机二进制文件时,您会将共享库中的文件作为导入文件传递。