测试程序不是 运行
Test Programs are not running
我一直在创建游戏引擎。当我测试代码时,我收到以下错误:
Application.cpp
namespace SkyEngine {
__declspec(dllimport)void Print();
}
void main() {
SkyEngine::Print();
}
Test.cpp
#include "Test.h"
#include<stdio.h>
namespace SkyEngine {
void Print() {
printf("Welcome to the Sky Engine!");
}
}
Test.h
#pragma once
namespace SkyEngine {
__declspec(dllexport)void Print();
}
文件的位置附在下面。:
这是引擎的解决方案文件。
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30907.101
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sandbox", "Sandbox\Sandbox\Sandbox.vcxproj", "{891DE6BF-51D7-4567-AC16-1DB5D2031CBE}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SkyEngine", "SkyEngine\SkyEngine.vcxproj", "{3B9FCA09-C542-4F44-8107-823A690EF0D6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3B9FCA09-C542-4F44-8107-823A690EF0D6}.Debug|x64.ActiveCfg = Debug|x64
{3B9FCA09-C542-4F44-8107-823A690EF0D6}.Debug|x64.Build.0 = Debug|x64
{3B9FCA09-C542-4F44-8107-823A690EF0D6}.Release|x64.ActiveCfg = Release|x64
{3B9FCA09-C542-4F44-8107-823A690EF0D6}.Release|x64.Build.0 = Release|x64
{891DE6BF-51D7-4567-AC16-1DB5D2031CBE}.Debug|x64.ActiveCfg = Debug|x64
{891DE6BF-51D7-4567-AC16-1DB5D2031CBE}.Debug|x64.Build.0 = Debug|x64
{891DE6BF-51D7-4567-AC16-1DB5D2031CBE}.Release|x64.ActiveCfg = Release|x64
{891DE6BF-51D7-4567-AC16-1DB5D2031CBE}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {239872E8-05BB-4D0E-A724-11648DD172D0}
EndGlobalSection
EndGlobal
在我看来,您的构建设置有误。
- 如我所见,您的入口点位于“SkyEngine”项目中,但它是作为
dll
. 构建的
- 我猜,“沙盒”项目取决于“SkyEngine.dll”文件,但包含导出文件。我想它是您解决方案中的可执行文件。
- 由于您没有提供“构建”步骤的日志,我不能 100% 确定“SkyEngine”是否在“沙盒”之前编译。
我是怎么得出这个结论的?
“错误”选项卡中的“项目”列显示了哪个项目引发了该错误。第二行显示了要编译到的文件(是“SkyEngine.dll”)。
主要原因是导出函数在linker 可以解析对link 的依赖关系之前未编译。所以我想你需要做的是,考虑到你正在构建一个游戏引擎,
- 获取导出函数并将其移至“SkyEngine”(我猜是引擎)。
- 获取入口点(在“Application.cpp”文件中)并将其移动到“沙盒”(我猜这是使用该引擎的应用程序/可执行文件)。
如果我的假设是正确的,这应该可以解决问题。
我一直在创建游戏引擎。当我测试代码时,我收到以下错误:
Application.cpp
namespace SkyEngine {
__declspec(dllimport)void Print();
}
void main() {
SkyEngine::Print();
}
Test.cpp
#include "Test.h"
#include<stdio.h>
namespace SkyEngine {
void Print() {
printf("Welcome to the Sky Engine!");
}
}
Test.h
#pragma once
namespace SkyEngine {
__declspec(dllexport)void Print();
}
文件的位置附在下面。:
这是引擎的解决方案文件。
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30907.101
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sandbox", "Sandbox\Sandbox\Sandbox.vcxproj", "{891DE6BF-51D7-4567-AC16-1DB5D2031CBE}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SkyEngine", "SkyEngine\SkyEngine.vcxproj", "{3B9FCA09-C542-4F44-8107-823A690EF0D6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3B9FCA09-C542-4F44-8107-823A690EF0D6}.Debug|x64.ActiveCfg = Debug|x64
{3B9FCA09-C542-4F44-8107-823A690EF0D6}.Debug|x64.Build.0 = Debug|x64
{3B9FCA09-C542-4F44-8107-823A690EF0D6}.Release|x64.ActiveCfg = Release|x64
{3B9FCA09-C542-4F44-8107-823A690EF0D6}.Release|x64.Build.0 = Release|x64
{891DE6BF-51D7-4567-AC16-1DB5D2031CBE}.Debug|x64.ActiveCfg = Debug|x64
{891DE6BF-51D7-4567-AC16-1DB5D2031CBE}.Debug|x64.Build.0 = Debug|x64
{891DE6BF-51D7-4567-AC16-1DB5D2031CBE}.Release|x64.ActiveCfg = Release|x64
{891DE6BF-51D7-4567-AC16-1DB5D2031CBE}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {239872E8-05BB-4D0E-A724-11648DD172D0}
EndGlobalSection
EndGlobal
在我看来,您的构建设置有误。
- 如我所见,您的入口点位于“SkyEngine”项目中,但它是作为
dll
. 构建的
- 我猜,“沙盒”项目取决于“SkyEngine.dll”文件,但包含导出文件。我想它是您解决方案中的可执行文件。
- 由于您没有提供“构建”步骤的日志,我不能 100% 确定“SkyEngine”是否在“沙盒”之前编译。
我是怎么得出这个结论的?
“错误”选项卡中的“项目”列显示了哪个项目引发了该错误。第二行显示了要编译到的文件(是“SkyEngine.dll”)。
主要原因是导出函数在linker 可以解析对link 的依赖关系之前未编译。所以我想你需要做的是,考虑到你正在构建一个游戏引擎,
- 获取导出函数并将其移至“SkyEngine”(我猜是引擎)。
- 获取入口点(在“Application.cpp”文件中)并将其移动到“沙盒”(我猜这是使用该引擎的应用程序/可执行文件)。
如果我的假设是正确的,这应该可以解决问题。