OOLua link errors - c++

Code
#include <OOLua/oolua.h>
class foo
{
public:
int bar();
};
OOLUA_CLASS_NO_BASES(foo)//class has no bases
OOLUA_NO_TYPEDEFS
OOLUA_MEM_FUNC_0(int,bar)
OOLUA_CLASS_END
void test()
{
OOLUA::Script s;
s.register_class<foo>();
}
Compiler output
1>main.obj : error LNK2001: unresolved external symbol "public: static struct OOLUA::Proxy_class<class foo>::Reg_type_const * OOLUA::Proxy_class<class foo>::class_methods_const" (?class_methods_const#?$Proxy_class#Vfoo###OOLUA##2PAUReg_type_const#12#A)
1>main.obj : error LNK2001: unresolved external symbol "public: static struct OOLUA::Proxy_class<class foo>::Reg_type * OOLUA::Proxy_class<class foo>::class_methods" (?class_methods#?$Proxy_class#Vfoo###OOLUA##2PAUReg_type#12#A)
1>main.obj : error LNK2001: unresolved external symbol "public: static char const * const OOLUA::Proxy_class<class foo>::class_name" (?class_name#?$Proxy_class#Vfoo###OOLUA##2QBDB)
1>main.obj : error LNK2001: unresolved external symbol "public: static char const * const OOLUA::Proxy_class<class foo>::class_name_const" (?class_name_const#?$Proxy_class#Vfoo###OOLUA##2QBDB)
1>main.obj : error LNK2001: unresolved external symbol "public: static int const OOLUA::Proxy_class<class foo>::name_size" (?name_size#?$Proxy_class#Vfoo###OOLUA##2HB)
Using
Visual Studio 2008
OOLua 1.2.1
(OOLua .lib has been built and linked to)
(OOLua solution via premake 3 with test.unit and profile projects removed)
(OOLua obtained via SVN -> trunk | Jan 3rd)
Links
http://code.google.com/p/oolua/
OOLua compile errors
Question
How can it be fixed?
Solution
class foo
{
public:
int bar()
{
return 0;
}
};
OOLUA_CLASS_NO_BASES(foo)//class has no bases
OOLUA_NO_TYPEDEFS
OOLUA_MEM_FUNC_0(int,bar)
OOLUA_CLASS_END
EXPORT_OOLUA_FUNCTIONS_1_NON_CONST(foo /*name of class*/
,bar)/*function being exposed*/
EXPORT_OOLUA_FUNCTIONS_0_CONST(foo)
void test()
{
OOLUA::Script s;
s.register_class<foo>();
}

http://code.google.com/p/oolua/wiki/CheatSheet#Has_a_member_function_which_takes_no_parameters
Then in a source file expose the class
telling the framework that the
instance has a function of interest
yet no constant member functions, also
providing the name it will be
identified by in Lua code(foo).
EXPORT_OOLUA_FUNCTIONS_1_NON_CONST(foo /*name of class*/
,bar)/*function being exposed*/
EXPORT_OOLUA_FUNCTIONS_0_CONST(foo)

Related

#include <fileSystem> causing LNK2019 (unreal engine related)

recently I'm working on a UE5 project that uses filesystem to read and render a .obj file directly from a given path, but my code generates 58 LNK2019 errors around the read file process after compiling it. I have tried many possible solutions like #include everything that I may need. However, the LNK2019 still exists.
Then I comment everything out of my file and I found that even if my .cpp and .h are empty but have #include <filesystem> it causes 5 LNK2019 errors. When I delete this file and create another one, then include it, it happens again. I didn't found what the compiler version of UE5 working set is, but it's said to be C++17
Basically this is my .cpp
#include "OBJMeshComponent.h"
//yes literally just one line.
and this is my .h
#pragma once
#include "CoreMinimal.h"
#include "ProceduralMeshComponent.h"
#include <fstream>
#include <iostream>
#include <filesystem> // this causes 5 LNK2019
#include "OBJMeshComponent.generated.h"
UCLASS()
class PROJECT_API UOBJMeshComponent : public UProceduralMeshComponent
{
GENERATED_BODY()
//as you can see it is empty
};
for the build output file:
OBJProceduralMeshComponent.gen.cpp.obj : error LNK2019: 无法解析的外部符号 "void __cdecl std::_Xbad_alloc(void)" (?_Xbad_alloc#std##YAXXZ),函数 "protected: void __cdecl std::time_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::_Getvals<wchar_t>(wchar_t,class std::_Locinfo const &)" (??$_Getvals#_W#?$time_get#DV?$istreambuf_iterator#DU?$char_traits#D#std###std###std##IEAAX_WAEBV_Locinfo#1##Z) 中引用了该符号
OBJProceduralMeshComponent.cpp.obj : error LNK2001: 无法解析的外部符号 "void __cdecl std::_Xbad_alloc(void)" (?_Xbad_alloc#std##YAXXZ)
OBJProceduralMeshComponent.gen.cpp.obj : error LNK2001: 无法解析的外部符号 _Mbrtowc
OBJProceduralMeshComponent.cpp.obj : error LNK2001: 无法解析的外部符号 _Mbrtowc
OBJProceduralMeshComponent.gen.cpp.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: struct _Cvtvec __cdecl std::_Locinfo::_Getcvt(void)const " (__imp_?_Getcvt#_Locinfo#std##QEBA?AU_Cvtvec##XZ),函数 "protected: void __cdecl std::time_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::_Getvals<wchar_t>(wchar_t,class std::_Locinfo const &)" (??$_Getvals#_W#?$time_get#DV?$istreambuf_iterator#DU?$char_traits#D#std###std###std##IEAAX_WAEBV_Locinfo#1##Z) 中引用了该符号
OBJProceduralMeshComponent.cpp.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: struct _Cvtvec __cdecl std::_Locinfo::_Getcvt(void)const " (__imp_?_Getcvt#_Locinfo#std##QEBA?AU_Cvtvec##XZ)
OBJProceduralMeshComponent.gen.cpp.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: unsigned short const * __cdecl std::_Locinfo::_W_Getdays(void)const " (__imp_?_W_Getdays#_Locinfo#std##QEBAPEBGXZ),函数 "protected: void __cdecl std::time_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::_Getvals<wchar_t>(wchar_t,class std::_Locinfo const &)" (??$_Getvals#_W#?$time_get#DV?$istreambuf_iterator#DU?$char_traits#D#std###std###std##IEAAX_WAEBV_Locinfo#1##Z) 中引用了该符号
OBJProceduralMeshComponent.cpp.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: unsigned short const * __cdecl std::_Locinfo::_W_Getdays(void)const " (__imp_?_W_Getdays#_Locinfo#std##QEBAPEBGXZ)
OBJProceduralMeshComponent.gen.cpp.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: unsigned short const * __cdecl std::_Locinfo::_W_Getmonths(void)const " (__imp_?_W_Getmonths#_Locinfo#std##QEBAPEBGXZ),函数 "protected: void __cdecl std::time_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::_Getvals<wchar_t>(wchar_t,class std::_Locinfo const &)" (??$_Getvals#_W#?$time_get#DV?$istreambuf_iterator#DU?$char_traits#D#std###std###std##IEAAX_WAEBV_Locinfo#1##Z) 中引用了该符号
OBJProceduralMeshComponent.cpp.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: unsigned short const * __cdecl std::_Locinfo::_W_Getmonths(void)const " (__imp_?_W_Getmonths#_Locinfo#std##QEBAPEBGXZ)
C:\Users\liuyi\Documents\Unreal Projects\Assignment2\Binaries\Win64\UnrealEditor-Assignment2.patch_0.exe : fatal error LNK1120: 5 个无法解析的外部命令

Building Boost 1.70.0 with icu 64.2

I have built icu 64.2 (debug and release for both x86 and x64). My build passes all the tests, so I know icu is not the issue.
I have also built a 64-bit version of boost 1.70.0 using the following b2 build command:
b2 address-model=64 -sICU_PATH=C:\icu-release-64-2\icu4c threading=multi --build-type=complete --toolset=msvc-14.1 -j 6
b2 is detecting my icu build and is showing:
- has_icu builds : yes
When I try to build my project with this boost/regex/icu code:
bool is_valid_password(const icu::UnicodeString& password, const icu::UnicodeString& requirements)
{
return boost::u32regex_match(password, boost::make_u32regex(requirements));
}
I get the following error:
1>------ Build started: Project: URLParser, Configuration: Debug x64 ------
1>URLParser.obj : error LNK2019: unresolved external symbol u_tolower_64 referenced in function "public: int __cdecl boost::icu_regex_traits::translate_nocase(int)const " (?translate_nocase#icu_regex_traits#boost##QEBAHH#Z)
1>libboost_regex-vc141-mt-gd-x64-1_70.lib(icu.obj) : error LNK2001: unresolved external symbol u_tolower_64
1>URLParser.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __cdecl icu_64::UnicodeString::length(void)const " (__imp_?length#UnicodeString#icu_64##QEBAHXZ) referenced in function "class boost::basic_regex<int,class boost::icu_regex_traits> __cdecl boost::make_u32regex(class icu_64::UnicodeString const &,unsigned int)" (?make_u32regex#boost##YA?AV?$basic_regex#HVicu_regex_traits#boost###1#AEBVUnicodeString#icu_64##I#Z)
1>URLParser.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: char16_t const * __cdecl icu_64::UnicodeString::getBuffer(void)const " (__imp_?getBuffer#UnicodeString#icu_64##QEBAPEB_SXZ) referenced in function "class boost::basic_regex<int,class boost::icu_regex_traits> __cdecl boost::make_u32regex(class icu_64::UnicodeString const &,unsigned int)" (?make_u32regex#boost##YA?AV?$basic_regex#HVicu_regex_traits#boost###1#AEBVUnicodeString#icu_64##I#Z)
1>libboost_regex-vc141-mt-gd-x64-1_70.lib(icu.obj) : error LNK2019: unresolved external symbol u_isblank_64 referenced in function "public: bool __cdecl boost::icu_regex_traits::isctype(int,unsigned __int64)const " (?isctype#icu_regex_traits#boost##QEBA_NH_K#Z)
1>libboost_regex-vc141-mt-gd-x64-1_70.lib(icu.obj) : error LNK2019: unresolved external symbol u_isspace_64 referenced in function "public: unsigned __int64 __cdecl boost::icu_regex_traits::lookup_classname(int const *,int const *)const " (?lookup_classname#icu_regex_traits#boost##QEBA_KPEBH0#Z)
1>libboost_regex-vc141-mt-gd-x64-1_70.lib(icu.obj) : error LNK2019: unresolved external symbol u_charType_64 referenced in function "public: bool __cdecl boost::icu_regex_traits::isctype(int,unsigned __int64)const " (?isctype#icu_regex_traits#boost##QEBA_NH_K#Z)
1>libboost_regex-vc141-mt-gd-x64-1_70.lib(icu.obj) : error LNK2019: unresolved external symbol u_charFromName_64 referenced in function "public: class std::vector<int,class std::allocator<int> > __cdecl boost::icu_regex_traits::lookup_collatename(int const *,int const *)const " (?lookup_collatename#icu_regex_traits#boost##QEBA?AV?$vector#HV?$allocator#H#std###std##PEBH0#Z)
1>libboost_regex-vc141-mt-gd-x64-1_70.lib(icu.obj) : error LNK2019: unresolved external symbol u_digit_64 referenced in function "public: bool __cdecl boost::icu_regex_traits::isctype(int,unsigned __int64)const " (?isctype#icu_regex_traits#boost##QEBA_NH_K#Z)
1>libboost_regex-vc141-mt-gd-x64-1_70.lib(icu.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl icu_64::Locale::Locale(void)" (__imp_??0Locale#icu_64##QEAA#XZ) referenced in function "public: __cdecl boost::icu_regex_traits::icu_regex_traits(void)" (??0icu_regex_traits#boost##QEAA#XZ)
1>libboost_regex-vc141-mt-gd-x64-1_70.lib(icu.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl icu_64::Locale::Locale(class icu_64::Locale const &)" (__imp_??0Locale#icu_64##QEAA#AEBV01##Z) referenced in function "public: __cdecl boost::re_detail_107000::icu_regex_traits_implementation::icu_regex_traits_implementation(class icu_64::Locale const &)" (??0icu_regex_traits_implementation#re_detail_107000#boost##QEAA#AEBVLocale#icu_64###Z)
1>libboost_regex-vc141-mt-gd-x64-1_70.lib(icu.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl icu_64::Locale::Locale(class icu_64::Locale &&)" (__imp_??0Locale#icu_64##QEAA#$$QEAV01##Z) referenced in function "public: class icu_64::Locale __cdecl boost::basic_regex<int,class boost::icu_regex_traits>::getloc(void)const " (?getloc#?$basic_regex#HVicu_regex_traits#boost###boost##QEBA?AVLocale#icu_64##XZ)
1>libboost_regex-vc141-mt-gd-x64-1_70.lib(icu.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl icu_64::Locale::~Locale(void)" (__imp_??1Locale#icu_64##UEAA#XZ) referenced in function "public: __cdecl boost::icu_regex_traits::icu_regex_traits(void)" (??0icu_regex_traits#boost##QEAA#XZ)
1>libboost_regex-vc141-mt-gd-x64-1_70.lib(icu.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class icu_64::Collator * __cdecl icu_64::Collator::createInstance(class icu_64::Locale const &,enum UErrorCode &)" (__imp_?createInstance#Collator#icu_64##SAPEAV12#AEBVLocale#2#AEAW4UErrorCode###Z) referenced in function "public: __cdecl boost::re_detail_107000::icu_regex_traits_implementation::icu_regex_traits_implementation(class icu_64::Locale const &)" (??0icu_regex_traits_implementation#re_detail_107000#boost##QEAA#AEBVLocale#icu_64###Z)
1>C:\Users\nicho\source\repos\URLParser\x64\Debug\URLParser.exe : fatal error LNK1120: 13 unresolved externals
1>Done building project "URLParser.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I should also note that I built icu and boost with the same compiler and MSVC toolset. Any ideas why boost wouldn't be linking to icu?

QGIS: Error LNK2019 using QApplication

I'm trying to create a project using the QGIS class "QApplication" but it seems to fail due to an error I can´t understand.
I'm using this build version of QGIS made for QT5.7, VS2015, W10 x64 and my main.cpp just containts the following lines:
#define CORE_EXPORT __declspec(dllexport)
#include "QGisTest.h"
#include <QtWidgets/QApplication>
#include <qgsapplication.h>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QGisTest w;
w.show();
return a.exec();
}
And when I try to build it, these errors show up:
1>------ Build started: Project: QGisTest, Configuration: Release x64 ------
1> moc_qgsapplication.cpp
1> Creating library C:\Users\GRODRIGUEZ\Documents\Visual Studio 2015\Projects\QGisTest\x64\Release\QGisTest.lib and object C:\Users\GRODRIGUEZ\Documents\Visual Studio 2015\Projects\QGisTest\x64\Release\QGisTest.exp
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QMap<class QString,class QString> QgsApplication::mSystemEnvVars21800" (?mSystemEnvVars21800#QgsApplication##0V?$QMap#VQString##V1###A) referenced in function "public: static class QMap<class QString,class QString> __cdecl QgsApplication::systemEnvVars(void)" (?systemEnvVars#QgsApplication##SA?AV?$QMap#VQString##V1###XZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static class QMap<class QString,class QString> QgsApplication::mSystemEnvVars21800" (?mSystemEnvVars21800#QgsApplication##0V?$QMap#VQString##V1###A)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static bool QgsApplication::mRunningFromBuildDir21800" (?mRunningFromBuildDir21800#QgsApplication##0_NA) referenced in function "public: static bool __cdecl QgsApplication::isRunningFromBuildDir(void)" (?isRunningFromBuildDir#QgsApplication##SA_NXZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static bool QgsApplication::mRunningFromBuildDir21800" (?mRunningFromBuildDir21800#QgsApplication##0_NA)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QString QgsApplication::mBuildSourcePath21800" (?mBuildSourcePath21800#QgsApplication##0VQString##A) referenced in function "public: static class QString __cdecl QgsApplication::buildSourcePath(void)" (?buildSourcePath#QgsApplication##SA?AVQString##XZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static class QString QgsApplication::mBuildSourcePath21800" (?mBuildSourcePath21800#QgsApplication##0VQString##A)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QString QgsApplication::mCfgIntDir21800" (?mCfgIntDir21800#QgsApplication##0VQString##A) referenced in function "public: static class QString __cdecl QgsApplication::cfgIntDir(void)" (?cfgIntDir#QgsApplication##SA?AVQString##XZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static class QString QgsApplication::mCfgIntDir21800" (?mCfgIntDir21800#QgsApplication##0VQString##A)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QString QgsApplication::mBuildOutputPath21800" (?mBuildOutputPath21800#QgsApplication##0VQString##A) referenced in function "public: static class QString __cdecl QgsApplication::buildOutputPath(void)" (?buildOutputPath#QgsApplication##SA?AVQString##XZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static class QString QgsApplication::mBuildOutputPath21800" (?mBuildOutputPath21800#QgsApplication##0VQString##A)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QStringList QgsApplication::mGdalSkipList21800" (?mGdalSkipList21800#QgsApplication##0VQStringList##A) referenced in function "public: static class QStringList __cdecl QgsApplication::skippedGdalDrivers(void)" (?skippedGdalDrivers#QgsApplication##SA?AVQStringList##XZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static class QStringList QgsApplication::mGdalSkipList21800" (?mGdalSkipList21800#QgsApplication##0VQStringList##A)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static int QgsApplication::mMaxThreads21800" (?mMaxThreads21800#QgsApplication##0HA) referenced in function "public: static int __cdecl QgsApplication::maxThreads(void)" (?maxThreads#QgsApplication##SAHXZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static int QgsApplication::mMaxThreads21800" (?mMaxThreads21800#QgsApplication##0HA)
1>C:\Users\GRODRIGUEZ\Documents\Visual Studio 2015\Projects\QGisTest\x64\Release\\QGisTest.exe : fatal error LNK1120: 7 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I also added to the project this "moc_qgsapplication.cpp" and wrote the line:
#define CORE_EXPORT __declspec(dllexport)
to avoid other compilation problems and linked to the project the QGIS and QT 5.7 libs.
Any idea how to fix it?
EDIT:
I have changed the two lines of main.cpp as suggested and now contains the following code:
#define CORE_EXPORT __declspec(dllimport)
#include "QGisTest.h"
#include <QApplication>
#include <qgsapplication.h>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QGisTest w;
w.show();
return a.exec();
}
but when I try to build it, these erros still show up:
1>------ Build started: Project: QGisTest, Configuration: Release x64 ------
1> moc_qgsapplication.cpp
1> main.cpp
1> Generating Code...
1> Creating library C:\Users\GRODRIGUEZ\Documents\Visual Studio 2015\Projects\QGisTest\x64\Release\QGisTest.lib and object C:\Users\GRODRIGUEZ\Documents\Visual Studio 2015\Projects\QGisTest\x64\Release\QGisTest.exp
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QMap<class QString,class QString> QgsApplication::mSystemEnvVars21800" (?mSystemEnvVars21800#QgsApplication##0V?$QMap#VQString##V1###A) referenced in function "public: static class QMap<class QString,class QString> __cdecl QgsApplication::systemEnvVars(void)" (?systemEnvVars#QgsApplication##SA?AV?$QMap#VQString##V1###XZ)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static bool QgsApplication::mRunningFromBuildDir21800" (?mRunningFromBuildDir21800#QgsApplication##0_NA) referenced in function "public: static bool __cdecl QgsApplication::isRunningFromBuildDir(void)" (?isRunningFromBuildDir#QgsApplication##SA_NXZ)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QString QgsApplication::mBuildSourcePath21800" (?mBuildSourcePath21800#QgsApplication##0VQString##A) referenced in function "public: static class QString __cdecl QgsApplication::buildSourcePath(void)" (?buildSourcePath#QgsApplication##SA?AVQString##XZ)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QString QgsApplication::mCfgIntDir21800" (?mCfgIntDir21800#QgsApplication##0VQString##A) referenced in function "public: static class QString __cdecl QgsApplication::cfgIntDir(void)" (?cfgIntDir#QgsApplication##SA?AVQString##XZ)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QString QgsApplication::mBuildOutputPath21800" (?mBuildOutputPath21800#QgsApplication##0VQString##A) referenced in function "public: static class QString __cdecl QgsApplication::buildOutputPath(void)" (?buildOutputPath#QgsApplication##SA?AVQString##XZ)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QStringList QgsApplication::mGdalSkipList21800" (?mGdalSkipList21800#QgsApplication##0VQStringList##A) referenced in function "public: static class QStringList __cdecl QgsApplication::skippedGdalDrivers(void)" (?skippedGdalDrivers#QgsApplication##SA?AVQStringList##XZ)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static int QgsApplication::mMaxThreads21800" (?mMaxThreads21800#QgsApplication##0HA) referenced in function "public: static int __cdecl QgsApplication::maxThreads(void)" (?maxThreads#QgsApplication##SAHXZ)
1>C:\Users\GRODRIGUEZ\Documents\Visual Studio 2015\Projects\QGisTest\x64\Release\\QGisTest.exe : fatal error LNK1120: 7 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

error LNK2019: unresolved external symbol classes

I get the error below when i call new TerrainClass() from the main, tried for hours to fix it, help please.
error LNK2019: unresolved external symbol "public: __thiscall TerrainClass::TerrainClass(void)" (??0TerrainClass##QAE#XZ) referenced in function "void __cdecl init(void)" (?init##YAXXZ)
GLDrawObject.h
#pragma once
class GLDrawObject
{
};
Terrain.cpp
#pragma once
TerrainClass::TerrainClass() : GLDrawObject()
{
}
Terrain.h
#pragma once
#include "GLDrawObject.h"
class TerrainClass : public GLDrawObject
{
public:
TerrainClass();
};
Firstly, your Terrain.cpp should be as follows:
#include "Terrain.h"
TerrainClass::TerrainClass() : GLDrawObject()
{
}
Secondly, you are getting a linker error, not a compiler error; once compiled, you need to link Terrain.o with the rest of your object files.

Receiving an error based on template class and it's child class's function calls

1>main.obj : error LNK2019: unresolved external symbol "public: virtual bool __thiscall LinkedSortedList<int>::getfirst(int &)" (?getfirst#?$LinkedSortedList#H##UAE_NAAH#Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: virtual void __thiscall LinkedSortedList<int>::clear(void)" (?clear#?$LinkedSortedList#H##UAEXXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: virtual void __thiscall LinkedSortedList<int>::print(void)const " (?print#?$LinkedSortedList#H##UBEXXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: virtual bool __thiscall LinkedSortedList<int>::insert(int)" (?insert#?$LinkedSortedList#H##UAE_NH#Z) referenced in function _main
1>main.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall LinkedSortedList<int>::find(int)const " (?find#?$LinkedSortedList#H##UBE_NH#Z)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall LinkedSortedList<int>::size(void)const " (?size#?$LinkedSortedList#H##UBEHXZ)
1>c:\users\chris\documents\visual studio 2010\Projects\lab0\Debug\lab0.exe : fatal error LNK1120: 6 unresolved externals
This is what I recieve when trying to compile my code. I've narrowed it down to (i believe) this section of code here:
#ifndef _LinkedSortedListClass_
#define _LinkedSortedListClass_
#include "LinkedNode.h"
#include "SortedList.h"
template <class Elm>
class LinkedSortedList: public SortedList<int> {
public:
void clear();
bool insert(Elm newvalue);
bool getfirst(Elm &returnvalue);
void print() const;
bool find(Elm searchvalue) const;
int size() const;
private:
LinkedNode<Elm>* head;
};
#endif
This is the child class of the SortedList, which is this, in case it's needed..
#ifndef _SortedListClass_
#define _SortedListClass_
template <class Elm> class SortedList {
public:
// -------------------------------------------------------------------
// Pure virtual functions -- you must implement each of the following
// functions in your implementation:
// -------------------------------------------------------------------
// Clear the list. Free any dynamic storage.
virtual void clear() = 0;
// Insert a value into the list. Return true if successful, false
// if failure.
virtual bool insert(Elm newvalue) = 0;
// Get AND DELETE the first element of the list, placing it into the
// return variable "value". If the list is empty, return false, otherwise
// return true.
virtual bool getfirst(Elm &returnvalue) = 0;
// Print out the entire list to cout. Print an appropriate message
// if the list is empty. Note: the "const" keyword indicates that
// this function cannot change the contents of the list.
virtual void print() const = 0;
// Check to see if "value" is in the list. If it is found in the list,
// return true, otherwise return false. Like print(), this function is
// declared with the "const" keyword, and so cannot change the contents
// of the list.
virtual bool find(Elm searchvalue) const = 0;
// Return the number of items in the list
virtual int size() const = 0;
};
#endif
Thanks so much for any help; our last class taught us nothing of inheritance, but this is project #1 for this class, without being taught inheritance here either, so this is all touch and go for me, despite what I managed to look up on Google.
Your methods aren't defined. So the linker is complaining because it can't link to their definitions.
Maybe it helps if you placed the definitions of your functions in your header file. This makes it easier for the compiler to resolve these external symbols.
I hope this will help.
Regards,
Philinator