I've been creating a game engine. When I was testing the code I was receiving following errors:
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();
}
The location of the files are attached below.:
Here is the solution file of the engine.
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
It looks to me like you have set up the build incorrectly.
dll
.How did I come to this conclusion?
The "project" column in the "Error" tab shows you what project throwed that error. And the second row showed what file it was meant to be compiled to (which was "SkyEngine.dll").
The main reason for this is that the exporting functions are not compiled before the linker could resolve the dependencies to link it. So I guess what you need to do is, and considering that your building a game engine,
This should resolve the issue if my hypothesis is correct.